0

I'm creating a shell script that performs several steps before running lualatex to create a final pdf document. The first step I have in this script is to clear out a "build" directory and start fresh.

BUILD=$DIR/build
if [ ! -d "$BUILD" ]; then
    mkdir $BUILD
fi
rm $BUILD/*

lualatex --output-directory build --interaction=batchmode main.tex

For the most part this works fine, however neither the table of contents nor the section headers appear in the output PDF. But If I modify the script to run lualatex twice:

lualatex --output-directory build --interaction=batchmode main.tex
lualatex --output-directory build --interaction=batchmode main.tex

...the PDF is perfect!

Under what circumstances would running the command twice cause everything to work fine?

Alan Munn
  • 218,180
mpr
  • 145
  • 1
    The ToC requires two runs at least –  Apr 17 '18 at 16:17
  • 1
    use latexmk.... –  Apr 17 '18 at 16:24
  • Thanks all, I'm switching to latexmk now. Apparently it thinks I need three passes, not just two! – mpr Apr 17 '18 at 16:43
  • 3
    @mpr unless you use roman numbers for the front matter page numbers then three passes is quite likely, the first pass collects the data, the second pass inserts the table of contents but that moves everything along 1 or 2 pages so changes all the page numbers, so it is on the third pass that you input a table of contents with the correct page numbers. – David Carlisle Apr 17 '18 at 17:10

0 Answers0