Take the 2-minute tour ×

I want to use the exact same file for my beamer presentation and handout. I do not like the need to comment out lines in order to create the handout or presentation (my current solution), nor do I want to have multiple files with an \input command. I realized that I can have a link (I work in linux or bsd) pointing to my main file, say

talk_handout.tex -> talk.tex

then the macro \jobname will let me know if I'm compiling the main file or the link. Using \endswith from the xifthen package I could then figure out if I should do handout or presentation mode.

This is all nice in theory, but in practice I have no idea how to do this. I usually have either [handout] or [beamer] in my \documentclass line and I don't know how to combine that with my desired use of \jobname.

Of course, I could have to files with an \input command right after the \document class line.....but I was wondering if there's another way.

Any ideas?

share|improve this question
I just noticed that you specifically vetoed a solution that involves \include. But, perhaps you could explain why this is not a good solution... –  Seamus Nov 24 '10 at 16:22
You should use \input, not \include... –  Jukka Suomela Nov 24 '10 at 20:11
see also “Passing parameters to a document” for a variety of ways to do this (another possible duplicate?). –  Caramdir Nov 24 '10 at 20:29
@Seamus: I don't like having many files "cluttering" up my directories. I don't like having to worry about setting master documents. I don't like having files that don't compile. I like the challenge. –  Yossi Farjoun Nov 24 '10 at 21:29
@Henrik, @Caramdir: although the answers are closely related, the questions are different and this actually seems like the kind of question that might get asked quite often. So I disagree with the duplicate, but agree that the three questions should be clearly connected. –  Andrew Stacey Nov 25 '10 at 8:18
show 2 more comments

3 Answers

up vote 8 down vote accepted

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:


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:


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:

  1. 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.

  2. If I do compile the master document, it falls back to something sensible.

  3. 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.

share|improve this answer
add comment

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

Above: the presentation; below: the handout

%%% handout

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:


%%% 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...

share|improve this answer
add comment

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
$ head -1 talk.tex

Then you can supply the handout class option via the command line like this:

$ 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.

share|improve this answer
add comment

Your Answer


