Setting class options after \documentclass

I did the same thing for my dissertation. Crappy copies for the University library, decent copies for myself and the committee. The easiest thing to do might be to have two versions of the master tex file, which then \input individual chapters. This lets you tweak each one, while using the same content.

BTW: Playing with LaTeX formatting is a great way to procrastinate, while maintaining the illusion that you are doing something useful.


Yes, but like many of the kernel class options it was not exactly designed for this. You'd by much better off simply having two potential document class lines, or something as simple as

\documentclass[
   twoside
 ]{book}

so you can comment out the option as necessary.


Joseph's answer is the most pragmatic one -- there's no need to complicate things.

Answering the question you didn't quite ask, however....

In some circumstances, it can be useful to exercise some control over LaTeX from 'outside' – perhaps you want to be able to produce two different versions of a document from a Makefile. One way to do that is to create a file containing some LaTeX and \input it at some strategic point. The other is to use a not very well known feature of the TeX program (at least on Unix systems, but probably on Windows ones, too).

The \documentclass doesn't have to be the first thing in the file. Consider this:

\providecommand\pointsize{10pt}
\documentclass[\pointsize]{article}
\begin{document}
Here is some text.
\end{document}

That defines \pointsize to be 10pt if it's not defined already. How could it be defined before the beginning of the file? Easy! If this file is doc.tex, then you can do:

% latex '\def\pointsize{12pt}\input{doc}'

Voilà!

This is an occasionally useful escape hatch. I suspect it's also very easy to get carried away, and start writing something horribly obfuscated.

Edited to use \providecommand rather than TeX arcana (thanks to comments from @user1129682)