How to use the exact same file for handout and presentation modes in beamer
My answer to this question came from exactly this situation. The code is there, I shan't repeat that, but I'll try to explain what it does so that you can see if it's worth clicking through to that question.
My solution is exactly what you outline in your first paragraph. I have a main file that contains all the code, say seminar.tex
, and then a set of symlinks which all point to this file and are of the form seminar.beamer.tex
, seminar.handout.tex
and the same for trans
or article
if appropriate. The class that I load is actually a wrapper class which looks at various parameters - both the \jobname
and any passed to it from the document - to decide which real class to load (and with what options). Thus the start of my real document is something like:
\documentclass[beamer,defaults]{myclass}
beamer
tells it to load the beamer class, defaults
sets up some stuff that I almost always use. Then it looks at the \jobname
to see what type of document it is: beamer
, handout
, etc, and passes the appropriate option to the beamer
class.
For lectures, I have a further option in that the format for my symlinks is actually:
main_file[.type[.lecture_name]].tex
When I'm editing the document, I make sure that I load it via the symlink that I'm most interested in (usually the beamer
version) and then my editor correctly compiles that version.
I used to use a method like the one Seamus outlines. I switched to this method because:
When doing a lecture series, it's much easier to create a batch load of symlinks than a batch load of files with specific content.
If I do compile the master document, it falls back to something sensible.
It doesn't actually need all the symlinks to still work. Since you can reset the jobname via the commandline, you could just do
pdflatex -jobname=seminar.beamer.tex seminar.tex
to get the right version compiled.
Here's my workflow for this sort of thing. It differs quite a lot from your idea, but it achieves more or less the same goal. [edit: it differs so much that your question excludes this sort of answer. But other people looking for similar solutions might find this acceptable]
I have one file for the presentation and one for the handout. Each of them includes \input{content}
. Then I have a third content.tex
file that contains the actual content of the talk.
%%% presentation
\documentclass{beamer}
\input{content}
Above: the presentation; below: the handout
%%% handout
\documentclass[handout]{beamer}
\input{content}
But what if I accidentally compile the content.tex
? this will break because it doesn't have a document class declaration. I use my editor of choice's multiple documents capabilities: I specify that the master document for content.tex
is presentation.tex
. Then compiling content actually compiles the presentation.
In emacs, this would be the content file:
\begin{document}
\begin{frame}
...
\end{frame}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "presentation.tex"
%%% End:
I guess I could make a makefile that runs pdflatex on both, but I don't need my handout compiled as often as my presentation: I'm often playing with overlays and compulsively recompiling to check a particular slide transition looks how I want...
Using the idea of Martin Scharrer's answer from a related question the following solution is quite elegant.
Assuming there is a presentation talk.tex
:
$ ls talk.tex
talk.tex
$ head -1 talk.tex
\documentclass{beamer}
Then you can supply the handout
class option via the command line like this:
$ pdflatex -jobname talk_print "\PassOptionsToClass{handout}{beamer}\input{talk}
$ pdflatex -jobname talk_print "\PassOptionsToClass{handout}{beamer}\input{talk}
That means that talk_print.pdf
contains only full pages for handouts or reference.
$ pdflatex talk
$ pdflatex talk
This generates just the presentation version talk.pdf
where the \pause
etc. commands work as expected.