# Conditional Compiling and \documentclass

I am quite new to latex and don't quite get it how to compile different versions of my presentation. If this is important: I am using pdflatex and beamer.

There are three documentclasses I am currently using:

• \documentclass{beamer}
• \documentclass[notes=only]{beamer}
• \documentclass[handout]{beamer}

I am currently using a makefile to compile the whole stuff which basicly invokes pdflatex like this: pdflatex '\documentclass[notes=only]{beamer} \input{\$(INPUT_FILE)}'

Which of course means my .tex file is missing the documentclass and can not easily be compiled without knowledge of my Makefile. And of course thats not quite desirable ...

But how would I do better?

-
–  Andrew Stacey Feb 7 '11 at 10:24
I'm voting to close this as a duplicate to tex.stackexchange.com/questions/1492/…. But maybe all the questions above (and the new answers to this one) can be merged into a single question? –  Caramdir Feb 7 '11 at 16:20

Put the \documentclass{beamer} back into your main file (e.g. presentation.tex), add required default options valid for all modes if there are any and execute it like that:

pdflatex  '\PassOptionsToClass{notes=only}{beamer} \input{presentation}'


This will still create presentation.pdf and overwrite the normal version of the PDF.

Alternatively create the following documents:

% notes.tex
\PassOptionsToClass{notes=only}{beamer}
\input{presentation}

% handout.tex
\PassOptionsToClass{handout}{beamer}
\input{presentation}


which have the benefit of creating notes.pdf and handout.pdf instead without any need for a Makefile or compiler options.

The main file can now easily be compiled simply using pdflatex presentation and the notes and handout with pdflatex notes and pdflatex handout, respectively.

-
doesn't pdflatex have an optional argument that tells you where to compile the file to? You could have a single file and use the \PassOptionsToClass trick but also include an output filename for each version in the makefile... –  Seamus Feb 7 '11 at 11:13
@Seamus: Yes you can use -jobname notes as well, but I like extra files more. Its easier if you use a Makefile but also execute pdflatex manually from the command line. I also got the impression that the OP want to share the files to other user which should not rely on a Makefile and command line options. –  Martin Scharrer Feb 7 '11 at 11:21
Yes, I am looking for a solution that still allows easy compiling of a "basic" version. Optimally a pdflatex beamer.tex would be enough. –  Marcus Riemer Feb 7 '11 at 12:44
@Marcus, @Seamus: I now updated my answer to be more explicit. This way it is more clearer to people which have the same issue and find this answer using Google. I used presentation as example main file to distinguish it more from the beamer class. –  Martin Scharrer Feb 7 '11 at 13:33
pdflatex '\PassOptionsToClass{notes=only}{beamer} \input{file}'

then your TeX file can be the default file for a presentation with the \documentclass line