First, I realise that there are a lot of questions on this topic on TeX.SE. I have read through a lot of these, but have not been able to work out how to set up my current configuration.
I am very unfamiliar with the majority of the terms used and this is causing issues when I try to translate it from the set-up of the other questions to mine.
In particular, one that looked promising said that it does not work with \input
, which I use.
My set-up is (I feel) pretty simple. I have the following project.
main.tex
preamble_main.tex
preamble_aux.tex
I compile main.tex
with the following command:
pdflatex.exe -synctex=1 -interaction=nonstopmode "main".tex
.
main.tex
contains \input{premable_main.tex}
and preamble_main.tex
contains \input{preamble_aux.tex}
.
I pre-compile the passive preamble with the following command:
pdflatex -ini -jobname="main" "&pdflatex" mylatexformat.ltx main.tex
.
This creates a file called main.fmt
.
This means that main.tex
starts as follows:
%&main
\documentclass{CLASS}
\input{preamble_main.tex}
\endofdump
...
If I change preamble_main.tex
(or preamble_aux.tex
which is \input
into preamble_main.tex
), then this has no effect on the compilation of main.tex
unless I recompile the preamble.
I would like to have a make
-type file which does the following.
- Check dates on
main.fmt
(.fmt
, not.tex
or.pdf
),preamble_main.tex
andpreamble_aux.tex
. - If either
preamble
s have been changed more recently than the.fmt
, then runpdflatex -ini -jobname="main" "&pdflatex" mylatexformat.ltx main.tex
. - (Whether or not the previous "if" held,) run
pdflatex.exe -synctex=1 -interaction=nonstopmode "main".tex
.
It certainly seems that make
files or latexmk
are suited for this type of question.
However, they seem to handle slightly different things.
Advice---or solutions!---would be most appreciated.
I'm not worried about setting up the bibliography stuff. I can easily handle this myself. Maybe in the future I try to improve it to handle that, but for now I just want the basics. Walk before you can run!
%&preamble_main
here (on systems that read the magic comment) you are specifying the format ispreamble_main
but here-jobname="main"
you are forcing it to be calledmain
. You can call it anything you like but need to be consistent. rather than rely on the comment in the file I'd normally specify the format on the commandline sopdflatex.exe "&main" -synctex=1 -interaction=nonstopmode "main".tex
%&main
rather than%&preamble_main
. Thank you for spotting this. I shall also bear in mind your other suggestion. That seems like a pretty easy change to implementmylatexformat
route (that I use a lot) is not intended for a document with a frequently changing preamble. But as you use the\endofdump
trick, you could simply\input
the changing part ofpreamble_aux.tex
between\endofdump
and\begin{document}
.\endofdump
, I have the 'active' (let's call it) premable which I update---that section is quite short and didn't seem relevant to this question. I've changed the phrasing to callpreamble_main
nowpreamble_passive
to emphasise that it doesn't change frequently. Just occasionally I do change stuff in the 'passive' preamble. It would be nice not to have to go and manually precompile it on these occasions---but it does change infrequently, so it's not the end of the world if I don't find a nice automated solution