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 – Raven Sep 26 '19 at 13:39
1 Answers
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:
- 37,699

