7

How to display a short section name in the tabel of contents?

\documentclass{beamer}

\begin{document}

    \begin{frame}
        \tableofcontents
    \end{frame}

    \section[short title]{long title}
    \frame{}

\end{document}

enter image description here

According to https://tex.stackexchange.com/a/200141/36296 this should theoretically work, or am I reading the answer wrong?

  • 1
    Could you add some more information about what you are trying to do? From this I assume that you want one name for the actual section, but another to show up in the TOC, is this correct? – qwelyt Sep 25 '14 at 16:16
  • 1
    yes, I'd like to have the long title when using \insertsection but the short form in the TOC – samcarter_is_at_topanswers.xyz Sep 25 '14 at 16:30

1 Answers1

12

Currently, beamer inserts the ToC and Navigation entries to match the mandatory sectioning command. You'll have to patch each sectional unit separately to "fix" this:

enter image description here

\documentclass{beamer}
\usepackage{etoolbox}
\makeatletter
% Insert [short title] for \section in ToC
\patchcmd{\beamer@section}{{#2}{\the\c@page}}{{#1}{\the\c@page}}{}{}
% Insert [short title] for \section in Navigation
\patchcmd{\beamer@section}{{\the\c@section}{\secname}}{{\the\c@section}{#1}}{}{}
% Insert [short title] for \subsection in ToC
\patchcmd{\beamer@subsection}{{#2}{\the\c@page}}{{#1}{\the\c@page}}{}{}
% Insert [short title] for \subsection  in Navigation
\patchcmd{\beamer@subsection}{{\the\c@subsection}{#2}}{{\the\c@subsection}{#1}}{}{}
\makeatother
\begin{document}

\begin{frame}
  \tableofcontents
\end{frame}

\section[short section]{long section}
\subsection[short subsection]{long subsection}
\frame{}

\end{document}

\beamer@section[#1]{#2} and \beamer@subsection[#1]{#2} act very much like the regular \section[#1]{#2} and \subsection[#1]{#2}, writing #2 to the .toc and .nav auxiliary files. The above \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>} switches the mandatory one for the optional one when writing to the auxiliaries.

Werner
  • 603,163