This is a follow-up to How can I automate the workflow for producing multiple versions of a document?
Here is toy example of my problem. I want to automate the generation of two slightly different versions of a document. Each one should be generated using latexmk. In one version, no class option should be used:
\documentclass{article}
\begin{document}
foo
\end{document}
In the other, some class option should be used, e.g.:
\documentclass[twocolumn]{article}
\begin{document}
foo
\end{document}
Of course, I could
- compile once without the class option,
- edit my
.texfile and manually add the class option, - compile a second time,
but this approach lacks automation. Alternatively, I could use two files:
% withoutoption.tex
\documentclass{article}
\begin{document}
foo
\end{document}
and
% withoption.tex
\PassOptionsToClass{twocolumn}{article}
\input{withoutoption.tex}
but, ideally, I'd like to only have one file to maintain, and pass class options from outside the .tex file (in a makefile). From Martin Scharrer's answer, I know I can pass a class option without having to edit the file, like so:
pdflatex "\PassOptionsToClass{twocolumn}{article}\input{foo}"
I'd like to use latexmk instead of pdflatex, though, and I can't figure out how the approach above would translate to latexmk. I must admit I'm not very familiar with the latexmk syntax, but I've scanned the documentation, and it appears latexmk can only accept a filename, not an argument of the form
"\PassOptionsToClass{twocolumn}{article}\input{foo}"
Did I miss something? Can latexmk be used in this fashion?
-latex="..."argument? You could pass that with an hard-coded call tolatexwith the appropriate arguments...I thinklatexmk"needs" files is that it tries to detect changes, if you onlyrun it once this should be fine... – Bordaigorl Oct 09 '14 at 13:06