Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use beamer to create a set of slides that are used to present the contents of a document. Both the slides and the printable document contents are contained in a single set of source files; I use the \mode commands to switch between presentation and printout mode. In contrast to some of the beamer examples I have seen so far, the printable version does not contain the complete slides as images. The slides and the printable version share some graphics and other contents, and I use a \marginpar to create a kind of link between the slides and the printable version, just to let the audience keep track. Here is a MWE, consisting of three files:

% === printable.tex =======================================
\documentclass{scrartcl}
\usepackage{beamerarticle}

\begin{document}
\input{contents}
\end{document}
% === end of printable.tex ================================

% === slides.tex ==========================================
\documentclass{beamer}

\begin{document}
\input{contents}
\end{document}
% === end of slides.tex ===================================

% === contents.tex =======================================
\mode*

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Fusce laoreet dui vestibulum tortor luctus porttitor. 
Aliquam dictum ipsum condimentum, auctor augue in, 
consectetur lacus. Morbi auctor posuere scelerisque.
Aenean vel enim sit met orci rutrum fermentum faucibus et 
mauris. Pellentesque tempor felis in imperdiet accumsan.
Mauris auctor pretium nulla et tincidunt.

\mode<presentation>
\begin{frame}
  \frametitle{Foo Bar}
  \begin{itemize}
    \item Foo
    \item Bar
    \item Baz
  \end{itemize}
\end{frame}
\mode*

Mauris\marginpar{Foo Bar} malesuada nisl sit amet nisl 
eleifend tincidunt. Sed sed libero scelerisque, ultrices 
elit a, lacinia mi. Mauris nec semper metus, eget 
pellentesque leo. Donec volutpat aliquam aliquam. Nunc 
vel neque scelerisque, aliquam augue eget, gravida felis. 
Suspendisse vel molestie libero. 

% === end of contents.tex =================================

As you can see, I have to manually repeat the frame title Foo Bar in the \marginpar. I tend to forget to do that, and I especially tend to forget to update the repetition when the title changes. Is there a way to specify the title only once and use it for the \frametitle as well for the \marginpar?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You just need to define different templates for article and presentation modes. If you include

\setbeamertemplate{frametitle}{\marginnote{\insertframetitle}}

in printable.tex preamble then frame title will appear on the margin if you are also processing frames in article version. (\marginnote is defined in marginnote package)

In your example, all frame contents is skipped because it is preceded by \mode<presentation>. Instead you can use something like:

\begin{frame}
  \frametitle{Foo Bar}
  \only<beamer>{%
     \begin{itemize}
       \item Foo
       \item Bar
       \item Baz
  \end{itemize}%
  } %<- \only<beamer> closing
\end{frame}

This way, only frame contents will be skipped while frametitle is processed and printed as a margin note. You don't need to include any \marginpar{Foo Bar} into next paragraph.

Please, look at Changing \mode in beamer makes a new paragraph. Is it possible to avoid it? and How to better adjust placement of frametitle converted to marginpar in beamerarticle? and you will see why I prefer to use \only and \marginnote.

Your complete example adapted with previous solution is

% === printable.tex =======================================
\documentclass{scrartcl}
\usepackage{beamerarticle}
\usepackage{marginnote}

\setbeamertemplate{frametitle}{\marginnote{\insertframetitle}}

\begin{document}
\input{contents}
\end{document}
% === end of printable.tex ================================
% 
% === slides.tex ==========================================
\documentclass{beamer}

\begin{document}
\input{contents}
\end{document}
% === end of slides.tex ===================================
% 
% === contents.tex =======================================

\mode*
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Fusce laoreet dui vestibulum tortor luctus porttitor. 
Aliquam dictum ipsum condimentum, auctor augue in, 
consectetur lacus. Morbi auctor posuere scelerisque.
Aenean vel enim sit met orci rutrum fermentum faucibus et 
mauris. Pellentesque tempor felis in imperdiet accumsan.
Mauris auctor pretium nulla et tincidunt.

\begin{frame}
  \frametitle{Foo Bar}
\only<beamer>{\begin{itemize}
    \item Foo
    \item Bar
    \item Baz
  \end{itemize}}
\end{frame}

\mode*
Mauris malesuada nisl sit amet nisl 
eleifend tincidunt. Sed sed libero scelerisque, ultrices 
elit a, lacinia mi. Mauris nec semper metus, eget 
pellentesque leo. Donec volutpat aliquam aliquam. Nunc 
vel neque scelerisque, aliquam augue eget, gravida felis. 
Suspendisse vel molestie libero. 

% === end of contents.tex =================================

Note: A very nice example to understand how to work with beamerarticle to produce presentations and printed version from same sources is a-lecture. It's written by Till Tantau and is part of beamer distribution, so probably it's in your computer. Take a look at it!

Addition by vwegert:

With the help of the package environ, I managed to define an environment that -- in contrast to the open \only<beamer>{ command -- does not wreak havoc with the syntax highlighting, pretty printer and other tools:

% === printable.tex =======================================
\documentclass{scrartcl}
\usepackage{beamerarticle}
\input{preamble}
\setbeamertemplate{frametitle}{\marginpar{\insertframetitle}}

\begin{document}
\input{contents}
\end{document}
% === end of printable.tex ================================

% === slides.tex ==========================================
\documentclass{beamer}
\input{preamble}

\begin{document}
\input{contents}
\end{document}
% === end of slides.tex ===================================

% === preamble.tex =======================================
\usepackage{environ}
\NewEnviron{onlybeamer}{\only<beamer>{\BODY}}
% === end of preamble.tex =================================

% === contents.tex =======================================
\mode*

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Fusce laoreet dui vestibulum tortor luctus porttitor. 
Aliquam dictum ipsum condimentum, auctor augue in, 
consectetur lacus. Morbi auctor posuere scelerisque.
Aenean vel enim sit met orci rutrum fermentum faucibus et 
mauris. Pellentesque tempor felis in imperdiet accumsan.
Mauris auctor pretium nulla et tincidunt.

\begin{frame}
  \frametitle{Foo Bar}
  \begin{onlybeamer}
    \begin{itemize}
      \item Foo
      \item Bar
      \item Baz
    \end{itemize}
  \end{onlybeamer}
\end{frame}
\mode*

Mauris malesuada nisl sit amet nisl 
eleifend tincidunt. Sed sed libero scelerisque, ultrices 
elit a, lacinia mi. Mauris nec semper metus, eget 
pellentesque leo. Donec volutpat aliquam aliquam. Nunc 
vel neque scelerisque, aliquam augue eget, gravida felis. 
Suspendisse vel molestie libero. 

\mode<all>
% === end of contents.tex =================================
share|improve this answer
    
This does not work for me - the frame title does not appear. –  vwegert Jan 21 at 16:14
1  
@vweger and @Ignasi The problem is, that the framecontent should not be included in the article. Hence the frametitle command is not seen in the article mode. Removing \mode<presentation> it should work. But this is not what is anticipated. Unfortunately I do not have a solution yet. –  crixstox Jan 21 at 16:21
    
@vwegert Ups, my fault. If frametitle is inside a presentation environment it won't be processed in article mode, then it won't appear. –  Ignasi Jan 21 at 16:34
    
@vwegert I've changed my answer. Not it includes frame title as margin note and avoid frame contents. –  Ignasi Jan 22 at 9:39
    
Is this really the only way? While this works, the open \only<beamer>{ command causes all kinds of trouble with many editors - syntax highlighting stops working, so does the auto-indentation of the environment contents, and sometimes the pretty printers will even mash together the contents of the \only<beamer>{ command. Would it be possible to wrap this in a kind of \begin{onlybeamer}...\end{onlybeamer} environment? –  vwegert Jan 29 at 9:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.