I am having a problem converting this pdflatex command to use latexmk:
pdflatex --file-line-error --shell-escape --synctex=1 \
-jobname=foobar "\def\MyCustomDef{} \input{file-name.tex}"
I attempt to use this with latexmk as:
latexmk -pdf -silent \
-pdflatex=/usr/texbin/pdflatex --file-line-error --shell-escape --synctex=1 \
-jobname=foobar "\def\MyCustomDef{} \input{file-name.tex}"
but this results in
Latexmk: Could not find file [\def\MyCustomDef{} \input{file-name.tex}]. -- Use the -f option to force complete processing.
Removing the double quotes in the above results in:
Latexmk: Need to specify at most one filename if jobname specified, but 2 were found (after defaults and wildcarding).
My earlier attempt was:
latexmk -pdf -silent \
-pdflatex=/usr/texbin/pdflatex --file-line-error --shell-escape --synctex=1 "\def\MyCustomDef{}" \
-jobname=foobar file-name.tex
but after having figured out the syntax to get pdflatex to work, I am assuming that one must use \input{} to specify the file name when defining macros on the command line.
Update:
I was able to get the solution form mph working on the command line, but then when I attempt to place that in my script I run into further issues. I suspect these are due to the need to escape things until the right moment that David Carlisle mentioned. Hmmm... This sounds a bit like TeX's expansion related issues -- no wonder I am having trouble. :-)
Here is my shell script :
#!/bin/csh
set LATEX_MAKE = latexmk
set PDFLATEX = pdflatex
set LATEX_MAKE_OPTIONS = "-f -silent "
set PDFLATEX_OPTIONS = "-pdf -pdflatex=$PDFLATEX --file-line-error --shell-escape --synctex=1 "
set PDFLATEX_OPTIONS_WITH_DEF = "$PDFLATEX_OPTIONS %O '\def\MyCustomDef{}\input{%S}'"
set TEX_FILE = "mf2"
echo "----- Normal build:"
$LATEX_MAKE $LATEX_MAKE_OPTIONS $PDFLATEX_OPTIONS $TEX_FILE.tex
echo "----- Custom build (with jobname & def):"
$LATEX_MAKE -jobname=$TEX_FILE-def '$LATEX_MAKE_OPTIONS $PDFLATEX_OPTIONS_WITH_DEF' $TEX_FILE.tex
exit(0)
and test file:
\documentclass{article}
\begin{document}
hello
\ifdefined\MyCustomDef
My CustomDef was used.
\else
My CustomDef was not used.
\fi
\end{document}
pdflatex. – Peter Grill Jul 22 '12 at 03:36