In my opinion, the cleanest approach here is to make \AtBeginSection
work in a beamerarticle
. The reason why it doesn't is that the \AtBeginSection
macro works by defining hooks to be executed at the beginning of theses sections. In article mode, however, the \section
macro as defined by the document class is used, so these hooks are never executed.
To overcome this, a redefinition of the \section
macro is necessary. This is a bit complicated because it calls \@startsection
internally, so simply adding the hook to the end of the macro won't work. Instead, a complete "wrapper" around the original command is necessary:
\mode<article>
\usepackage{xparse}
\makeatletter
\expandafter\let\expandafter\originalsection\expandafter=\csname @orig\string\section\endcsname
\RenewDocumentCommand{\section}{ D<>{} s o m }
{
\alt<#1>
{
\IfBooleanTF {#2}
{
\originalsection*{#4}
%\beamer@atbeginsections % breaks because section* is also used e.g. in the TOC
}
{
\IfNoValueTF {#3} { \originalsection{#4} } { \originalsection[#3]{#4} }
\beamer@atbeginsection
}
}
{
\beamer@secgobble
}
}
\makeatother
\mode<all>
Insert this code into the preamble of your document, after having loaded beamerarticle
. What it does is to save the original, beamer
-free meaning of the \section
macro stored in the macro with the "weird" name @orig\section
to \originalsection
. Afterwards, \section
is redefined to execute the original sectioning command and the hook \beamer@atbeginsection
afterwards. As \section
has a starred and non-starred version, an optional argument and an (optional) overlay specification, I used xparse
which allows you to define such macros in a very convenient way.
Now you can use \AtBeginSection
as usual to insert the section start frames. As you probably don't want them to actually show up in article mode, you should use \begin{frame}<article:0>
for these (the frame number is still incremented). Additionally, you need to \def\insertsection{}
because this command is unknown to beamerarticle
and would result in an error otherwise.
Note that using the optional argument of \AtBeginSection
to define a hook for starred sections won't work (the line executing it is commented out in the above code). The reason is that \section*
is also used for the table of contents etc., where such inserts would result in an error message.
Output of your MWE using the above code
In presentation mode (click on the image to see it full-size):
In article mode:
For completeness, the full source that produced the above results can be found on pastebin.com.
Edit: The xparse
package I used to redefine \section
relies on the experimental LaTeX3 kernel. If it is not available, you can use this plain LaTeX2e solution instead:
\mode<article>
\makeatletter
\expandafter\let\expandafter\originalsection\expandafter=\csname @orig\string\section\endcsname
\def\sectionwithhook{\@ifstar\@sectionwithhook\@@sectionwithhook}
\newcommand{\@sectionwithhook}[1]{\originalsection*{#1}}
\newcommand{\@@sectionwithhook}[2][]{\beamer@ifempty{#1}{\originalsection{#2}}{\originalsection[#1]{#2}}\beamer@atbeginsection}
\renewcommand<>{\section}{\alt#1{\sectionwithhook}{\beamer@secgobble}}
\makeatother
\mode<all>
This replaces the whole code given above, achieving the same as the \RenewDocumentCommand
with some helper macros.
I don't know how to extract notes from the original document, but if you accept to work with two files: presentation and notes, the one with notes could be based in sidebyside
tcolorboxes where one side is a slide from a previously compiled beamer presentation while you can write notes on the other side.
Following code defines \mypage
environment with one default and one mandatory parameters. The default is the name of your presentation file (change beamer
with any other name). The mandatory parameter is the number of the slide that you want to comment. The environment's body will the notes corresponding to the slide. It doesn't matter if notes are long or short, they will fit inside a box and every page will contain as many boxes as possible.
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\newenvironment{mypage}[2][beamer]{%
\begin{tcolorbox}[%
fonttitle=\bfseries,
title={Notes to slide #2},
sidebyside,
sidebyside align=top seam,
bicolor,
]
\includegraphics[page=#2, width=\linewidth]{#1}
\tcblower}{\end{tcolorbox}}
\begin{document}
\begin{mypage}{1}
This is a short comment
\end{mypage}
\begin{mypage}{2}
\end{mypage}
\begin{mypage}{3}
\lipsum[2]
\end{mypage}
\end{document}
If you don't want to "waste" paper and ink, use a blankest
tcolorbox:
\newenvironment{mypage}[2][beamer]{%
\begin{tcolorbox}[%
blankest,
sidebyside,
sidebyside align=top seam,
]
\includegraphics[page=#2, width=\linewidth]{#1}
\tcblower}{\end{tcolorbox}}
Best Answer
This creates a command
\handoutgap{}
which will leave a gap in handout mode, typesetting the content normally otherwise.The handout:
The presentation: