texlive 2018 版 Beamer 中的书签编号

texlive 2018 版 Beamer 中的书签编号

我想使用 texlive 2018 版本对 beamer 书签中的每个部分、子部分和子子部分进行编号。根据提供的解决方案,这个问题似乎很多年前就解决了网络奇点有问题在 Beamer 中调整书签编号

我关注了它,在 texlive 2017 中解决了这个问题然而,去年我无法编译代码2018 年 TEXLIVE在 Windows 操作系统上:

在此处输入图片描述

书签是:

在此处输入图片描述

代码如下:

\documentclass{beamer}
\documentclass{beamer}
\hypersetup{
  bookmarksnumbered=true
}

\setcounter{tocdepth}{4}

% get numbering in section bookmarks
\usepackage{etoolbox}
\usepackage{bookmark}
\makeatletter

\newcounter{realsection}
\newif\ifrealsection
\long\def\beamer@@ssection*#1{\realsectionfalse\beamer@section[{#1}]{}}
\long\def\beamer@@@section#1{\realsectiontrue\beamer@section[{#1}]{#1}}

\patchcmd{\beamer@section}%
    {\refstepcounter{section}}%
    {\ifrealsection\refstepcounter{realsection}\fi\refstepcounter{section}}%
    {}{\errmessage{failed to patch}}

\patchcmd{\beamer@section}%
    {\Hy@writebookmark{\the\c@section}{\secname}}%
    {\Hy@writebookmark{\the\c@section}{\numberline{\therealsection}\secname}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsection}%
   {\Hy@writebookmark{\the\c@subsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsection}{\numberline{\therealsection.\thesubsection}#2}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsubsection}%
    {\Hy@writebookmark{\the\c@subsubsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\therealsection.\thesubsection.\thesubsubsection}#2}}%
    {}{\errmessage{failed to patch}}
\makeatother


\begin{document}

\section*{Intro}

\section{section}

\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\section{section}
\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}
\end{document}

所以,我如何修改上面的代码并编号子节和子节

非常感谢您的帮助。

答案1

beamer 现在还使用 subsection 和 subsubsection 命令 \subsecname 和 \subsubsecname:

\documentclass{beamer}
\hypersetup{
  bookmarksnumbered=true
}

\setcounter{tocdepth}{4}

% get numbering in section bookmarks
\usepackage{etoolbox}
\usepackage{bookmark}
\makeatletter

\newcounter{realsection}
\newif\ifrealsection
\long\def\beamer@@ssection*#1{\realsectionfalse\beamer@section[{#1}]{}}
\long\def\beamer@@@section#1{\realsectiontrue\beamer@section[{#1}]{#1}}

\patchcmd{\beamer@section}%
    {\refstepcounter{section}}%
    {\ifrealsection\refstepcounter{realsection}\fi\refstepcounter{section}}%
    {}{\errmessage{failed to patch}}

\patchcmd{\beamer@section}%
    {\Hy@writebookmark{\the\c@section}{\secname}}%
    {\Hy@writebookmark{\the\c@section}{\numberline{\therealsection}\secname}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsection}%
   {\Hy@writebookmark{\the\c@subsection}{\subsecname}}%
    {\Hy@writebookmark{\the\c@subsection}{\numberline{\therealsection.\thesubsection}\subsecname}}%
    {}{\errmessage{failed to patch}}


\patchcmd{\beamer@subsubsection}%
    {\Hy@writebookmark{\the\c@subsubsection}{\subsubsecname}}%
    {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\therealsection.\thesubsection.\thesubsubsection}\subsubsecname}}%
    {}{\errmessage{failed to patch}}
\makeatother


\begin{document}

\section*{Intro}

\section{section}

\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\section{section}
\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}
\end{document}

相关内容