I would like to control class options such as draft and geometry package's showframe from a Makefile. Is there a way I can parameterise a document using LaTeX itself, or will I need to preprocess the document using sed from the Makefile?


This is something I use quite often.

In your document you do this:


The \expandafter shouldn't be necessary, however, I always provide them.

The \providecommand only adds the command if it didn't already exist. So you just need to create the command beforehand and then you can switch between different schemes.

In your makefile you can then do:

    pdflatex "\def\classopts{draft}\input{document}"
    pdflatex document

And then you have two different compilations, one with draft and the other with regular settings.

I typically use it for switching between compiling handouts and the presentation for a beamer presentation.

  • This works great! I've used pdflatex "\def\classopts{,draft}\input{document}" (note the leading comma) so that I can append options to a list of standard class options such as a4paper – hertzsprung Apr 2 '14 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.