# Controlling draft options from a Makefile

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:

\providecommand\classopts{}
\expandafter\documentclass\expandafter[\classopts]{article}


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:

draft:
pdflatex "\def\classopts{draft}\input{document}"
pdf:
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