9

I'm preparing a beamer slideshow, and I will have to print slides.

I would rather use landscape mode slides, but it is possible that I need to use portrait mode ones. Sadly, I won't know until a few minutes before the talk, so I have to prepare two copies of the presentation.

I've tried to use conditional compilation, but it doesn't seem to work pretty well. Basically, I would like to have something like this:

    \newif\ifwide
    \widetrue

And then I would write something like this:

    \begin{frame}{A frame}
        Some text (...)
\ifwide
    \end{frame}

    \begin{frame}{A second frame}
\fi
        Some text (continued)
    \end{frame}

This particular example doesn't work (pdflatex reports Extra }, or forgotten \endgroup. \end{frame} (followed by: )). What should I do to have the frame contents split on two frames in landsape mode, but not in portrait mode?

Martin Scharrer
  • 262,582
Clément
  • 4,004
  • 1
    The frame environment of beamer is a pseudo-environment, i.e. actually a macro which reads everything until \end{frame} as argument. This is the reason why if-switches don't work here. – Martin Scharrer Mar 03 '11 at 16:04
  • I see, thanks. Is there a way to have the \ifs processed before the pseudo-environment expands? – Clément Mar 03 '11 at 17:27
  • Related to http://tex.stackexchange.com/questions/1492/passing-parameters-to-a-document (and see my answer). This is a place I like to use docstrip. Wish I could write up an answer for you right now, but I don't have the time. – Matthew Leingang Mar 03 '11 at 18:22

1 Answers1

5

The following solution wraps each potential frame in its own environment and both of these in a parent environment. In wide mode the inner ones are not doing anything except setting the frame title and the outer environment is the frame. In the other mode the outer is a no-op and the inner are the frames. This uses the environment key of the frame environment to tell it which \end ends the frame content.

This might not (yet) support the full range of frame optional arguments (<>, [< >] etc.).

\documentclass{beamer}

\newif\ifwide
\widetrue

\ifwide

\newenvironment<>{frames}[1][]{%
  \begin{frame}#2[environment=frames,#1]%
}{%
  \end{frame}%
}
\newenvironment<>{firstframe}[2][]{
  \frametitle{#2}%
}{}%
\newenvironment<>{secondframe}[2][]{}{}%

\else

\newenvironment<>{frames}[1][]{%
}{%
}
\newenvironment<>{firstframe}[1][]{
  \begin{frame}#2[environment=firstframe,#1]%
}{%
  \end{frame}%
}%
\newenvironment<>{secondframe}[1][]{
  \begin{frame}#2[environment=firstframe,#1]%
}{%
  \end{frame}%
}%

\fi

\begin{document}

\begin{frames}
\begin{firstframe}{A frame}
    Some text (...)
\end{firstframe}
\begin{secondframe}{A second frame}
    Some text (continued)
\end{secondframe}
\end{frames}

\end{document}
Martin Scharrer
  • 262,582