1

Is there a way to print out the command line used to compile the latex document? The document is compiled using an editor and I'd like to get what it is specifically using.

1
  • If you happen to use Linux, you could alias the name of the latex-compiler used by your editor into a shell script that just prints out its parameters
    – Raven
    Sep 26, 2019 at 13:39

1 Answer 1

6

In Linux you can print all processes from within your document and grep the relevant line. The output of this command can be printed to the document. Adapted from Write18: capturing shell (script) output as command/variable?:

\documentclass{article}
\begin{document}
Command used is

{\catcode`_=12 \ttfamily
\input{|"ps aux|grep -Eoh '[a-z]+latex.*\jobname.*'|head -n 1" }

}
\end{document}

Example result:

enter image description here

Note that this requires to set --shell-escape, and probably if you know how to set that you can also find the default compile options, but that is not really the point.

Note also that this does not work when you change things like -progname or -jobname, in that case you should modify the grep regex accordingly. The same holds for using a non-LaTeX compiler, like pdfTeX or ConTeXt.


In Windows you can do something similar with the wmic command (Windows Management Instrumentation Command-Line Utility). However, because this includes file paths with backslashes, it results in undefined command sequence errors when it is used directly in \input (i.e., LaTeX thinks that C:\Program Files contains the command \Program and tries to execute this command). So you can save the output of the wmic command to a file instead and print the contents of this file with for example \lstinputlisting from the listings package, which allows to break lines.

MWE:

 \documentclass{article}

\usepackage{listings}

\begin{document}

Command used is

\immediate\write18{wmic process get commandline /format:list |findstr escape > cmdout.tmp}

\lstinputlisting[breaklines]{cmdout.tmp}

\end{document}

Result:

enter image description here

3
  • This is what I want but Is there an equivalent for windows?
    – user184375
    Sep 26, 2019 at 16:38
  • @Chieron see edit.
    – Marijn
    Sep 26, 2019 at 20:05
  • Thanks, exactly what I wanted... and look ma! no MWE!
    – user184375
    Sep 26, 2019 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy