Hello everyone.
I'm trying to determine when a re-run of Xe(La)TeX is required because of undefined references. I've posted a related question on the SCons mailing list, and the problem is as follows:
Page counts and other references that require multiple runs of XeLaTeX are sometimes not at present detected by SCons and other build systems. Here's an example file (which we'll call job.tex
):
\documentclass[oneside,12pt]{memoir}
\usepackage{xltxtra}
\usepackage[T1]{fontenc}
\makepagestyle{plain}
\makeoddfoot{plain}{}{}{Page \thepage\ of \arabic{lastpage}}
\makeevenfoot{plain}{}{}{Page \thepage\ of \arabic{lastpage}}
\begin{document}
\pagestyle{plain}
Page 1
\newpage
Page 2
\newpage
Page 3
\newpage
\end{document}
If you run xelatex job
, the .pdf that's produced has page numbers "Page 1 of 0", "Page 2 of 0", and "Page 3 of 0" for the three pages. If you run xelatex job
a second time you get "Page 1 of 3", etc. (i.e. the correct page count).
To fix this, I've suggested on the SCons mailing list that the check for whether to run xelatex to resolve undefined references is to change the following regular expression (in SCons.Tools.tex
at line 71 of version 2.0.1.beta.20100627.r5064):
- warning_rerun_str = '(^LaTeX Warning:.*Rerun)|(^Package \w+ Warning:.*Rerun)'
+ warning_rerun_str = '(^LaTeX Warning:.*Rerun)|(^Package \w+ Warning:.*Rerun)'\
+ '|(^No file \w+\.\w{3}\.$)'
In practice, this is a check for "No file job.aux". It turns out this works in all cases because Xe(La)TeX will always print "No file job.aux" on the first run, and therefore Xe(La)TeX always runs twice. In effect, this is the same as having job.aux
become an interim build target between job.tex
and job.pdf
.
Therein lies the problem: Even if there is no undefined reference (e.g. remove the \arabic{lastpage}
from job.tex
above) Xe(La)TeX is called twice, once to produce the .aux
, once to produce the .pdf
. Obviously, if there are no undefined references, this second call is superfluous.
Thus my question: how can one detect - presumably by way of a regular expression testing against the job.log
- when there are or are not undefined references (e.g. \arabic{lastpage}) that require recompilation.
Thank you for reading.
Best regards,
Brian