The best tool for this particular case (which wasn't obvious from your initial question) would to use the TeXShop arara
engine and use arara
rules to compile the file.
See:
In this case you can simply put the following lines at the top of your document:
% !TEX TS-program = arara
% arara: pdflatex
% arara: pdflatex { synctex: true }
The first line tells TeXShop to use the arara
engine, and the next two lines tell arara
to process the file twice. Since results of the first compilation will never be viewed pdflatex
can be run with no options; on the second run, the synctex
option is added so that you have synchronization between source and preview. Obviously you can adjust the tool to run lualatex
or xelatex
, etc. if that's the engine you are using.
For other use cases (particularly resolving citations and references), the latexmk
approach is very helpful.
TeXShop comes with a pdflatexmk
engine which will compile your document (and also run bibtex
or biber
and other tools) as many times as is required, but not more.
This is better than blindly requiring the document to be compiled twice. The easiest way to use it is to add:
% !TEX TS-program = pdflatexmk
to the first line of your document. There are other versions for different engines (xelatexmk
, lualatexmk
, etc.)
If the engine doesn't show up in the pulldown Typeset menu, then you need to move it from the Inactive
folder to the Engines
folder within ~/Library/TeXShop
.
See:
Of course the two approaches can be combined, so if you are using arara
you could have the first compilation be plain pdflatex
and the second compilation use latexmk
and have the best of both worlds:
% !TEX TS-program = arara
% arara: pdflatex
% arara: pdflatexmk { synctex: true }