4

Recently I've discovered latexmk if I understand correct then it can replace several commands needed to compile latex just with one command. Is it possible to show which commands were executed when I issue e.g. latexmk -pdf thesis.tex? Or even better is it possible to run latexmk in some 'no action mode' to just print what commands should be issued to compile latex manually? I do not guess that latest is possible because during compilation are generated '.aux', '.bbl' files etc. which are read again and again as described here and here. So I guess some compilation must took place before we know if compilation is needed in next step or nor, but I will rather ask. Thanks

PS: I'm wondering of exact sequence of commands that were executed e.g.:

pdflatex thesis.tex
pdflatex thesis.tex
pdflatex thesis.tex

or

pdflatex thesis.tex
bibtex thesis.tex
pdflatex thesis.tex
pdflatex thesis.tex
  • 1
    At least on Linux, latexmk is actually (a symbolic link to) a long perl script (being long due to documentation and comments) but it does basically nothing more than to call the regular commands such as latex, pdflatex etc. –  May 27 '16 at 09:20
  • I know that it is basically calling regular commands but I'm wondering which commands are called for particular project. AFAIK latexmk somehow determine which commands to call to optimize compilation process. Or am I wrong and same set of commands are called every time I run latexmk regardless of if BibTeX, glossaries etc. is used or nor? – Wakan Tanka May 27 '16 at 10:09
  • You can work out from the terminal output which commands latexmk ran on any particular call... – Seamus May 27 '16 at 10:10
  • @Seamus is this correct approach: latexmk -pdf thesis.tex 2>&1 | grep '^Running' – Wakan Tanka May 27 '16 at 10:17
  • 2
    In case you don't want to dig through the terminal output, run latexmk -time -pdf thesis.tex. This is intended to get timing information, but as a side effect it summarises all the steps at the end of the output. – samcarter_is_at_topanswers.xyz May 27 '16 at 10:23
  • 1
    I think @samcarter has a better solution. – Seamus May 27 '16 at 10:26

3 Answers3

6

latexmk already provides the informations which of its rules it currently runs during it's terminal output. But in case you don't want to dig through the terminal output, run latexmk -time -pdf thesis.tex. This is originally intended to get timing information, but as a side effect it summarises all the steps at the end of the output.

'pdflatex  -recorder  "Thesis.tex"': time = 10.21
'biber  "Thesis"': time = 11.21
'pdflatex  -recorder  "Thesis.tex"': time = 11.52
'pdflatex  -recorder  "Thesis.tex"': time = 11.45
'pdflatex  -recorder  "Thesis.tex"': time = 11.48
Accumulated processing time = 57.02
3

latexmk --commands provides the following list:

   To run latex, I use "latex %O %S"
   To run pdflatex, I use "pdflatex %O %S"
   To run biber, I use "biber %O %B"
   To run bibtex, I use "bibtex %O %B"
   To run makeindex, I use "makeindex %O -o %D %S"
   To make a ps file from a dvi file, I use "dvips %O -o %D %S"
   To make a ps file from a dvi file with landscape format, I use "dvips -tlandscape %O -o %D %S"
   To make a pdf file from a dvi file, I use "dvipdf %O %S %D"
   To make a pdf file from a ps file, I use "ps2pdf  %O %S %D"
   To view a pdf file, I use "open %S"
   To view a ps file, I use "NONE"
   To view a ps file in landscape format, I use "NONE"
   To view a dvi file, I use "NONE"
   To view a dvi file in landscape format, I use "NONE"
   To print a ps file, I use "lpr %O %S"
   To print a dvi file, I use "NONE $lpr_dvi variable is not configured to allow printing of dvi files"
   To print a pdf file, I use "lpr %O %S"
   To find running processes, I use "ps -ww -u scmbradley", 
      and the process number is at position 1
Notes:
  Command starting with "start" is run detached
  Command that is just "start" without any other command, is
     used under MS-Windows to run the command the operating system
     has associated with the relevant file.
  Command starting with "NONE" is not used at all
Seamus
  • 73,242
0

For some reason in my distribution, the -time output is abbreviated:

'lualatex': time = 0.99
'makeindex a.idx': time = 0.02
'lualatex': time = 1.11
'lualatex': time = 1.07

As such, a simpler way is to simply grep for the string "Running" in latexmk output (it was mentioned above that the commands are already printed, just buried in the output):

$ latexmk    -lualatex  a 2> /dev/null |grep Running
Running 'lualatex  -recorder  "a.tex"'
Running 'makeindex -s gind.ist  -o "a.ind" "a.idx"'
Running 'lualatex  -recorder  "a.tex"'
Running 'lualatex  -recorder  "a.tex"'

(on e.g. Windows there would not be grep however.)

Of course it's trivial to construct some way for this to be wrong e.g. with a \message command in the TeX file, but that's not a large concern in normal use.

(side note, if you want to find out the commands of a "full run" do latexmk -C a to remove all auxiliary files beforehand; otherwise it might only do one run or similar.)

user202729
  • 7,143