I have a single XeLaTeX source file which can generate two versions of the document depending on whether a certain command sequence testcs exists. I typically have a shell script which generates both versions, which looks like this:

set file = "Document"
xelatex -jobname="${file}-v1" "\def\testcs{1} \input{${file}.tex}"
xelatex ${file}.tex

I have now included an index in my document and typesetting it now requires several passes through xelatex. I would typically use latexmk, such as

latexmk -pdfxe Document

but I now would like to generate the two versions of the document using my script.

In other words, I would like to modify my shell script to use latexmk, but I seem unable to pass the arguments to xelatex. I can pass the -jobname but I've had no such luck passing the \def\textcs{1} via any of the options: -xelatex, -pdfxelatex, -pretex,...

Question Is there a simple way to do that?

1 Answer 1


The following answer is due to user @samcarter in Stack Overflow:

set file = "Document"
latexmk -pdfxe -jobname=${file}"-v1" -pretex="\def\testcs{1}" -usepretex ${file}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .