我想使用 texlive 2018 版本對 Beamer 書籤中的每個部分、小節和子小節進行編號。根據提供的解決方案,這個問題似乎很多年前就已經解決了網路奇點有問題調整 Beamer 中的書籤編號。
我跟著它並且在 texlive 2017 中解決了這個問題然而,去年我無法編譯程式碼2018年紡織生活展在 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}