From d92287afe0d055319ad7e3df95732be72d693d09 Mon Sep 17 00:00:00 2001 From: snailed Date: Wed, 10 Aug 2022 11:53:24 +0000 Subject: [PATCH] Parse tex root for more complex latex files Allows parsing texroot comments so that you can compile a LaTeX document from outside of the document root, as long as it contains the usual magic comment format: % !TEX root = doc.tex --- .local/bin/compiler | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.local/bin/compiler b/.local/bin/compiler index 67992be..85a0c58 100755 --- a/.local/bin/compiler +++ b/.local/bin/compiler @@ -18,6 +18,8 @@ cd "$dir" || exit 1 textype() { \ command="pdflatex" + texroot=$(grep -Poi "^ *% *\! *tex root *= *\w+(?:\.\w*)?" "$file" | cut -d "=" -f 2 | tr -d "[:blank:]") + [ -n "$texroot" ] && base=$texroot && echo "Compiling from TeX root: $texroot" ( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex" $command --output-directory="$dir" "$base" && grep -qi addbibresource "$file" &&