# Show full section titles in beamerarticle ToC when short section titles are present

I am creating lecture notes and slides simultaneously using beamerarticle. In beamer, I'm using a theme called Berlin which puts all section titles in the slide header. Because some section titles are long and don't fit, I have specified short titles such as:

\section[short title 1]{First Section's Full Title}


The short titles now appear in the slide header. However, this has an undesirable effect on the article: by default the short section titles now show up in the article's table of contents.

\section{First Section's Full Title}
\sectionmark{short title 1}


However, beamer does not recognize sectionmark and now reverts to putting the full section titles in the slide header.

It seems to me that I need to somehow edit the default options of either the table of contents in the documentclass article, or the Berlin theme in beamer. Unfortunately I am quite new to LaTeX and have no idea how to do either. Help appreciated.

Among the packages I am using are titlesec and tocloft, but my problem occurs regardless of whether the packages are in use, thus I have commented them out in the minimal working example below. The code for the m.w.e. needs to be saved as three separate tex files in the same folder, as specified below. Compile example.article.tex and example.beamer.tex, not example.tex

%NOTE: The following should be saved as example.article.tex:
\documentclass{article}
\usepackage{beamerarticle}
\input{example.tex}

%NOTE: The following should be saved as example.beamer.tex:
\documentclass[ignorenonframetext]{beamer}
\input{example.tex}

%NOTE: The following should be saved as example.tex:
%\mode<article>{
% \usepackage{tocloft}
% \usepackage[compact]{titlesec}
%}
\mode<presentation>{\usetheme{Berlin}}
% everyone:
\usepackage[english]{babel}

\begin{document}
\begin{frame}
\title{Title}
\maketitle
\end{frame}
\begin{frame}{\only<presentation>{Outline}}
\setcounter{tocdepth}{1}
\tableofcontents
\end{frame}
\section[short title 1]{First Section's Full Title}
%\sectionmark{short title 1}
\begin{frame}{First Frame}
Blah blah text
\end{frame}
\begin{frame}{Second Frame}
Blah blah text 2
\end{frame}
\section[short title 2]{Second Section's Full Title}
%\sectionmark{short title 2}
\begin{frame}{Third Frame}
Blah blah text 3
\end{frame}
\end{document}

-
Welcome to TeX.sx! –  lockstep Nov 21 '12 at 10:58

One possible solution is to use modes and to define a command \Section with tow arguments: one (the first one) optional argument will hold the short title for the navigation bar in presentation mode and the second, mandatory argument, will hold the title for the section both in presentation and in article modes. A complete example follows.

Processing the following test document:

    %\documentclass{article}
\documentclass{beamer}
%\usepackage{beamerarticle}

\newcommand\Section[2][]{%
\section<presentation>[#1]{#2}
\section<article>{#2}
}
\usetheme{Berlin}

\begin{document}

\begin{frame}
\tableofcontents
\end{frame}
\Section[Short title 1]{First Section's Full Title}
\begin{frame}
test
\end{frame}

\end{document}


produces the following frame (short tile in the navigation bar, full title in the ToC):

Now, using the article version:

\documentclass{article}
%\documentclass{beamer}
\usepackage{beamerarticle}

\newcommand\Section[2][]{%
\section<presentation>[#1]{#2}
\section<article>{#2}
}
\usetheme{Berlin}

\begin{document}

\begin{frame}
\tableofcontents
\end{frame}
\Section[Short title 1]{First Section's Full Title}
\begin{frame}
test
\end{frame}

\end{document}


we receive the following ToC (full title in the ToC):

-
Dear Gonzalo, this worked for me - thanks a lot. –  Thomas Farrar Nov 22 '12 at 11:18
This solution worked for me. However just a note for future users who may use it: We have to remove the optional [ignorenonframetext] argument in \documentclass[ignorenonframetext]{beamer} for beamer to recognize \Section calls (which come outside of frame) - otherwise no headers or ToC will appear in beamer. So now any text between frames will appear on slides. But this is easily solved - text can be allocated to the article only by placing it within \only<article>{} –  Thomas Farrar Nov 26 '12 at 7:02
@ThomasFarrar I am glad to hear my solution worked for you. Please consider accepting the answer (up-voting and accepting are two different actions); in case of doubt please see How do you accept an answer?. –  Gonzalo Medina Nov 26 '12 at 14:28