# Displaying slides with Beamer and Article class

(Edited to include a MWE; note that the current version is much simpler than what was mentioned in the original question and is essentially acceptable.)

Right now, I create an article version of my beamer presentation where each slide is specifically included explicitly using a \showslide command follows:

\begin{frame}<presentation>[label=slide1]
...
\end{frame}
\showslide{slide1}


and where I use the option to avoid duplication of the slide content in the text. Is it possible to (re)define an environment so that this is automatically done (ideally with automatic slide label numbering.)? Ideally I would have like to be able to either redefine frame or define a new environment and just type

\begin{myframe}
...
\end{myframe}


thus avoiding having to specify the mode every time and avoiding having to specify a new label.

MWE example using 3 files follows. Note that, sometimes, the explanatory text included for a given slide in the article version may be a few pages long.

%minitest.beamer.tex

\documentclass[ignorenonframetext]{beamer}
\input{minitest.tex}


%minitest.article.tex

\documentclass{article}
\usepackage{beamerarticle}
\usepackage{pgf}

\setjobnamebeamerversion{minitest.beamer}

\newcommand{\showslide}[1]{\begin{figure}
\center \fbox{\includeslide[width=12cm]{#1}}
\end{figure}}

\input{minitest.tex}


%minitest.tex

\begin{document}

\begin{frame}<presentation>[label=slide1]
\frametitle{First slide}
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
\end{frame}
\showslide{slide1}

Some text included only in the article mode.
\newpage

\begin{frame}<presentation>[label=slide2]
Second slide
\end{frame}
\showslide{slide2}

Yet more text included here for the second slide.
\end{document}

-
So does your article version have to include the slides as-is? There is a beamerarticle package that typesets the contents of your beamer presentation in article form (section 21.2 Creating Handouts Using the Article Mode, p 206 of the beamer documentation). –  Werner Dec 12 '11 at 23:24
@Werner: yes. I want to use this to make videos (screencasts) for teaching purpose, and use the article version as a handout for students - for them to follow along and take notes. In my experiments so far, I found it easier to follow if a copy of the slides was included as it appeared on screen - and less confusing if the information was not repeated essentially verbatim below in the text. –  André Dec 13 '11 at 0:54
Are you sure you don't want beamer handouts instead of an article? Are you adding supplemental material besides the slides themselves? See this question about adding pre-written notes to slides or this article about adding ruled space for people to write their own notes, perhaps? –  Mike Renfro Dec 13 '11 at 1:27
@MikeRenfro I have tried the handout but I really don't like how it looks. I am really happy with the way things look when I use the method described in my post, but it is tedious to do. –  André Dec 13 '11 at 2:04
Could you include a little more code, preferably a MWE. If the only problem with the handout mode is how it looks then that can be configured and it might be easier than redefining the frame. But knowing which route is best depends a lot on what the outcome should look like. –  Andrew Stacey Dec 13 '11 at 11:12
show 1 more comment

I think you can get that with modifying the notes page template. One example that's not exactly what you want, but is close, and pretty easy to work with:

%%% For normal presentations
%\documentclass{beamer}
%%%

%%% For handouts with lots of extra notes
\documentclass[handout]{beamer}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] % could also use letterpaper
\setbeameroption{show notes on second screen=bottom} % Beamer manual, section 19.3
%%%

\setbeamertemplate{note page}[plain] % Beamer manual, section 19.1
\newlength{\parskipbackup}
\setlength{\parskipbackup}{\parskip}
\newlength{\parindentbackup}
\setlength{\parindentbackup}{\parindent}
\newcommand{\baselinestretchbackup}{\baselinestretch}
\usetemplatenote{\rmfamily \scriptsize%
\setlength{\parindent}{1em} \setlength{\parskip}{1ex}%
\renewcommand{\baselinestretch}{1}%
\noindent \insertnote%

\setlength{\parskip}{\parskipbackup}%
\setlength{\parindent}{\parindentbackup}%
\renewcommand{\baselinestretch}{\baselinestretchbackup}%
}

\title{The Title}
\author{The Author}
\usetheme{Copenhagen}

\begin{document}
\begin{frame}
Here's some content, with no notes added.
\end{frame}
\begin{frame}
Here's some content, with notes added.
\end{frame}
\note{
Here are things to remember:
\begin{enumerate}
\item Stress this first. (We probably need to ensure that this item wraps properly, too.)
\item Then this.
\end{enumerate}
Afterwards, talk about other things. Stall for as long as possible. Eventually, we'll
run out of room on this line, and will spill over onto another one.

And if we need a second paragraph, we can add one of those, too. Math like Euler's
identity
$1+e^{i \pi}=0$
isn't hard to add, but you may want to adjust the default math font family back to the
Roman default.

For some unknown reason, it appears that the last paragraph gets some weird line
spacing unless we put an extra paragraph break in the template before resetting the
paragraph-related lengths.
}
\end{document}

-
This is very nice. However, it fails when the note content is longer than the space available at the bottom of the page. I think I will stick with what I have so far as the article class has a bit more flexibility. Still, I'll probably try to play with your proposed solution and compare with what I have so far. –  André Dec 13 '11 at 16:01

Very good question! Here is my approach. It is far from perfect, but I am not an expert TeXnician. I encourage other people to improve this method, because I think this very much improves the value of beamerarticle.

We define a counter baslide, and tweak the definition of the frame environment to automatically “label and increase”.

# Slides

For the slides, we have the file minitest.slides.tex:

\documentclass[handout,ignorenonframetext]{beamer}
\input{minitest}


# Handout

In minitest.handout.tex:

\documentclass[handout,ignorenonframetext]{beamer}
\newcounter{baslide}
\setcounter{baslide}{1}

\let\oldframe
\frame
\let\oldendframe
\endframe

\def\frame{\oldframe \label{baslide\roman{baslide}}%
\def\endframe{\oldendframe}

\input{minitest}


Note the handout option when loading beamer. It ensures that we include the final version of each slide in our notes.

# Notes

In minitest.article.tex:

\documentclass{article}
\usepackage{beamerarticle}

\usepackage{verbatim}

\newcounter{baslide}
\setcounter{baslide}{1}

\let\oldframe\frame
\let\oldendframe\endframe

\setjobnamebeamerversion{minitest.handout}
\def\frame{\noindent%
{\par \centering%
\includeslide[width=.8\textwidth]{baslide\roman{baslide}}%
\par}
\comment}
\def\endframe{\endcomment}


This redefines the frame environment to include slide number baslide from minitest.handout.pdf. (I use 80% of \textwidth, + centering.) It then increases the counter baslide with 1, for the next frame. Finally, it acts like a comment environment (hence the verbatim package) for all the text contained in the frame environment. This effectively removes the old frame output from the document.

# Makefile

I also made a Makefile for this kind of workflow:

all: slides handout article

projname = minitest
compile = pdflatex

slides: $(projname).slides.tex$(projname).tex
$(compile)$(projname).slides.tex

handout: $(projname).handout.tex$(projname).tex
$(compile)$(projname).handout.tex

article: $(projname).article.tex$(projname).tex $(projname).handout.pdf$(compile) $(projname).article.tex clean: cleans cleanh cleana cleans: rm -f$(projname).slides.{aux,fdb_latexmk,fls,log,nav,out,snm,toc}

cleanh:
rm -f $(projname).handout.{aux,fdb_latexmk,fls,log,nav,out,snm,toc} cleana: rm -f$(projname).article.{aux,fdb_latexmk,fls,log,nav,out,snm,toc}


I am afraid that TeX.sx removes the tabbing from the Makefile sourcecode. Make tends to be quite picky about this, so maybe you need to convert tabs to spaces.

This is a hack, definitively. It is probably quite fragile, but as far as I could see, it got the job done in the test that I did. I hope it works for you!

-

Since you're producing a PDF of your slides anyway, why not just include the pages of that PDF in the handouts.

Assuming you have a handout version of the slides, say in a PDF file called a.pdf, I'd define \showslide as follows:

\newcommand\showslide{
\clearpage % new page for each slide
\begin{center}
\framebox{\includegraphics[page=\arabic{slidenum},width=.95\textwidth]{a.pdf}}
\stepcounter{slidenum}
\end{center}
}


where a new page of a.pdf is included each time you invoke the command \showslide. The \framebox is just added to mark the border of the slides, and can be removed if wanted.

• Only two .tex files, instead of three
• No need to label every frame in Beamer
• Explanations after each frame can be as long as you'd like

The downside, of course, is only that you'd have to produce a PDF file with the Beamer option handout turned on.

# Full code

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum} % dummy texts

\newcounter{slidenum}
\setcounter{slidenum}{1} % set to 2 if want to exclude title page of presentation

\newcommand\showslide{
\clearpage
\begin{center}
\framebox{\includegraphics[page=\arabic{slidenum},width=.95\textwidth]{a.pdf}}
\stepcounter{slidenum}
\end{center}
}

\begin{document}
\showslide
\lipsum[1-5] % explanations exceeding one page

\showslide
\lipsum[2]
\end{document}


-