6

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? – Chewtoy 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
11

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.

  • Do you know what the command is to use the short title in the footer of each slide? – Abhimanyu Pallavi Sudhir Jun 14 '20 at 14:53
  • 1
    @AbhimanyuPallaviSudhir: There doesn't seem to be a macro storing that when I looked into beamerbasesection.dtx, so one would have to patch \beamer@section and capture argument #1 for use later. – Werner Jun 14 '20 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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