目錄中的短節名稱

目錄中的短節名稱

如何在目錄中顯示簡短的章節名稱?

\documentclass{beamer}

\begin{document}

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

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

\end{document}

在此輸入影像描述

根據https://tex.stackexchange.com/a/200141/36296理論上這應該有效,還是我讀錯了答案?

答案1

現在,beamer插入目錄和導航條目以符合強制分段命令。您必須分別修補每個部分單元才能「修復」此問題:

在此輸入影像描述

\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}\beamer@subsection[#1]{#2}的行為非常類似於常規的\section[#1]{#2}\subsection[#1]{#2},寫入#2.toc輔助.nav文件。上面\patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}在寫入輔助設備時將強制項切換為可選項。

相關內容