9
3
I am currently working with LaTeX. I have a big document split up in several sub documents. When I am workin in a sub document, I'd love to compile the master file when pressing ctrl+b, not the file I am currently in. How do I do that?
9
3
I am currently working with LaTeX. I have a big document split up in several sub documents. When I am workin in a sub document, I'd love to compile the master file when pressing ctrl+b, not the file I am currently in. How do I do that?
9
I just found the answer myself! As mentioned here, one just has to put
%!TEX root = protokoll.tex
as the first line of the sub documents!
1
If you have 3 different files you need, you can use first-line (or second if you need utf8 stuff) comments. I use it to compile the main TeX file from one of the children.
%!../main_file.tex
\documentclass[12pt,a4paper]{scrartcl}
\usepackage[czech,english]{babel}
I have a script, which looks at the first line:
match=`head -n1 $1 | grep %!`
if [[ $match ]]
then
# do stuff with the parent's name, which is ${match:2:100}
else
# no match :/
fi
and a simple build file aiming at my custom script:
{
"cmd": ["/path/to/build/script.sh", "$file"],
"selector": "whatever"
}
This way, you can have as many "references" in your files as you want. Just switch the value of head -n1
.
To end with, I present to you my XeLaTeX build script ;)
#!/bin/bash
file="$1"
flag="-halt-on-error"
match=`head -n1 $file | grep %!`
if [[ $match ]]
then
if [ ${match:2:3} = ../ ]
then
cd .. &&
target=${match:5:100}
else
target=${match:2:100}
fi
else
target=$file
fi
rubber -c 'set arguments -shell-escape' -f -m xelatex -W all $target
exit 0
I really appreciate it!!! This problem has confused me for a while. – Zhigong Li – 2015-05-08T05:48:48.907