DEV Community

Brian J. Cardiff
Brian J. Cardiff

Posted on

Generating LaTeX Beamer Handouts without changing files

When using LaTeX, it's common to use Beamer to create slides for presentations. Typically, a Beamer document starts like this:

\documentclass{beamer}
% Presentation content...
Enter fullscreen mode Exit fullscreen mode

You can use transitions like \pause to reveal content step by step. However, when preparing handouts, it's often desirable to remove these transitions for clarity.

The Standard Approach: Using the handout Option

A common method to create handouts is to modify the \documentclass line:

\documentclass[handout]{beamer}
% Presentation content...
Enter fullscreen mode Exit fullscreen mode

This effectively removes all transitions, producing a clean, static document. However, constantly toggling this line on and off can be tedious. Below are alternative approaches to simplify this process.

Alternative 1: Using \PassOptionsToClass

A more flexible method is to use \PassOptionsToClass, which allows you to toggle handout mode with a simple comment:

\PassOptionsToClass{handout}{beamer}
\documentclass{beamer}
Enter fullscreen mode Exit fullscreen mode

To switch back to transition mode, just comment out the first line:

% \PassOptionsToClass{handout}{beamer}
\documentclass{beamer}
Enter fullscreen mode Exit fullscreen mode

This avoids direct modifications to the \documentclass line, making toggling easier.

Alternative 2: Using a Separate Handout File

If you frequently need both presentation and handout versions, consider creating a separate file. If your main Beamer file is main.tex, create a new handout.tex file containing:

\PassOptionsToClass{handout}{beamer}
\input{main}
Enter fullscreen mode Exit fullscreen mode

Now, compiling main.tex gives you the regular slides with transitions, while compiling handout.tex produces a transition-free handout.

Alternative 3: On-the-Fly Handout Generation

For even greater flexibility, you can generate the handout dynamically using a shell command. If you use Makefile or automation scripts, this method fits well into workflows:

echo '\\PassOptionsToClass{handout}{beamer}\\input{main}' | pdflatex -jobname=handout
Enter fullscreen mode Exit fullscreen mode

Note that when piping LaTeX source to pdflatex you will need to pass -jobname to setup the output file name.

Conclusion

By using \PassOptionsToClass, separate handout files, or shell scripting, you can streamline the process of generating handouts from Beamer presentations. Choose the method that best fits your workflow and avoid the hassle of manually toggling the handout option!

Top comments (0)