Print out command line used

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.

• 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 Sep 26, 2019 at 13:39

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:

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:

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