我需要在 beamer 类中手动设置子子部分编号,因此使用以下代码:
\newcommand{\setnextsubsubsection}[1]{%
\setcounter{subsubsection}{\numexpr#1-1\relax}%
\beamer@tocsubsubsectionnumber=\numexpr#1\relax\space}
相同的代码对于部分工作正常,但当我使用\setnextsubsubsection
它时说
!undefined control sequence. \setnextsubsubsection
...
是因为\beamer@tocsubsubsectionnumber =
不起作用吗?
这是一个(希望是)最小的例子:
\documentclass[mathserif, handout]{beamer}
\usepackage[polish,german]{babel}
\usepackage[utf8]{inputenc}
\setbeamerfont{frametitle}{size=\linespread{1.1}\Large}
\newcommand{\sectiontitle}{\huge \bf \color{blau} \thesection . \insertsection}
\newcommand{\subsectiontitle}{\thesubsection . \subsecname}
\newcommand{\subsubsectiontitle}{\thesubsubsection . \subsubsecname }
\defbeamertemplate{subsubsection in toc}{subsubsections numbered}
{\leavevmode\tiny\leftskip=3em%
\rlap{\hskip-3em\inserttocsectionnumber.\inserttocsubsectionnumber.\inserttocsubsubsectionnumber}%
\inserttocsubsubsection\par}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\setbeamertemplate{subsubsection in toc}[subsubsections numbered]
\makeatletter
\newcommand{\setnextsection}[1]{%
\setcounter{section}{\numexpr#1-1\relax}%
\beamer@tocsectionnumber=\numexpr#1-1\relax\space}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setnextsubsubsection}[1]{%
\setcounter{subsubsection}{\numexpr#1-1\relax}%
\beamer@tocsubsubsectionnumber=\numexpr#1\relax\space}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatother
\makeatletter
\long\def\beamer@section[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture
\refstepcounter{section}%
\beamer@ifempty{#2}%
{\long\def\secname{#1}\long\def\lastsection{#1}}%
{\global\advance\beamer@tocsectionnumber by 1\relax%
\long\def\secname{#2}%
\long\def\lastsection{#1}%
\addtocontents{toc}{\protect\beamer@sectionintoc{\the\c@section}{#2\hfill\the\c@page}{\the\c@page}{\the\c@part}%
{\the\beamer@tocsectionnumber}}}%
{\let\\=\relax\xdef\sectionlink{{Navigation\the\c@page}{\noexpand\secname}}}%
\beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
\beamer@ifempty{#1}{}{%
\addtocontents{nav}{\protect\headcommand{\protect\sectionentry{\the\c@section}{#1}{\the\c@page}{\secname}{\the\c@part}}}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\the\beamer@tempcount}}}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}}%
}%
\beamer@sectionstartpage=\c@page%
\beamer@subsectionstartpage=\c@page%
\def\insertsection{\expandafter\hyperlink\sectionlink}%
\def\insertsubsection{}%
\def\insertsubsubsection{}%
\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
\def\insertsubsectionhead{}%
\def\insertsubsubsectionhead{}%
\def\lastsubsection{}%
\Hy@writebookmark{\the\c@section}{\secname}{Outline\the\c@part.\the\c@section}{2}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsections}{\beamer@atbeginsection}%
\fi%
\beamer@resumemode}%
\def\beamer@subsection[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture%
\refstepcounter{subsection}%
\beamer@ifempty{#2}{\long\def\subsecname{#1}\long\def\lastsubsection{#1}}
{%
\long\def\subsecname{#2}%
\long\def\lastsubsection{#1}%
\addtocontents{toc}{\protect\beamer@subsectionintoc{\the\c@section}{\the\c@subsection}{#2\hfill\the\c@page}{\the\c@page}{\the\c@part}{\the\beamer@tocsectionnumber}}%
}%
\beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
\addtocontents{nav}{%
\protect\headcommand{\protect\beamer@subsectionentry{\the\c@part}{\the\c@section}{\the\c@subsection}{\the\c@page}{\lastsubsection}}%
\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}%
}%
\beamer@subsectionstartpage=\c@page%
\edef\subsectionlink{{Navigation\the\c@page}{\noexpand\subsecname}}%
\def\insertsubsection{\expandafter\hyperlink\subsectionlink}%
\def\insertsubsubsection{}%
\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
\def\insertsubsubsectionhead{}%
\Hy@writebookmark{\the\c@subsection}{#2}{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@page}{3}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@page}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsubsections}{\beamer@atbeginsubsection}%
\fi%
\beamer@resumemode}
\def\beamer@subsubsection[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture%
\refstepcounter{subsubsection}%
\beamer@ifempty{#2}{\long\def\subsubsecname{#1}\long\def\lastsubsubsection{#1}}
{%
\long\def\subsubsecname{#2}%
\long\def\lastsubsubsection{#1}%
\addtocontents{toc}{\protect\beamer@subsubsectionintoc%
{\the\c@section}{\the\c@subsection}{\the\c@subsubsection}{#2\hfill\the\c@page}{\the\c@page}{\the\c@part}{\the\beamer@tocsectionnumber}}%
}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@subsubsectionentry%
{\the\c@part}{\the\c@section}{\the\c@subsection}{\the\c@subsubsection}{\the\c@page}{\lastsubsubsection}}}%
\edef\subsubsectionlink{{Navigation\the\c@page}{\noexpand\subsubsecname}}%
\def\insertsubsubsection{\expandafter\hyperlink\subsubsectionlink}%
\def\insertsubsubsectionhead{#1}%
\Hy@writebookmark{\the\c@subsubsection}{#2}{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@subsubsection.\the\c@page}{4}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@subsubsection.\the\c@page}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsubsubsections}{\beamer@atbeginsubsubsection}%
\fi%
\beamer@resumemode}
\makeatother
\renewcommand*{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand*{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\begin{document}
%\setnextsubsubsection{7}
\subsubsection{test}
\begin{frame}
\frametitle{\subsubsectiontitle}
\end{frame}
\end{document}
答案1
好的,我想我已经解决掉了。
beamer
只使用subsubsection
计数器而不\beamer@tocsubsubsectionnumber
计数。使用以下定义似乎就足够了:
\newcommand{\setnextsubsubsection}[1]{%
\setcounter{subsubsection}{\numexpr#1-1\relax}}
在您的完整代码中:
\documentclass[mathserif, handout]{beamer}
\usepackage[polish,german]{babel}
\usepackage[utf8]{inputenc}
\setbeamerfont{frametitle}{size=\linespread{1.1}\Large}
\newcommand{\sectiontitle}{\huge \bf \color{blau} \thesection . \insertsection}
\newcommand{\subsectiontitle}{\thesubsection . \subsecname}
\newcommand{\subsubsectiontitle}{\thesubsubsection . \subsubsecname }
\defbeamertemplate{subsubsection in toc}{subsubsections numbered}
{\leavevmode\tiny\leftskip=3em%
\rlap{\hskip-3em\inserttocsectionnumber.\inserttocsubsectionnumber.\inserttocsubsubsectionnumber}%
\inserttocsubsubsection\par}
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\setbeamertemplate{subsubsection in toc}[subsubsections numbered]
\makeatletter
\newcommand{\setnextsection}[1]{%
\setcounter{section}{\numexpr#1-1\relax}%
\beamer@tocsectionnumber=\numexpr#1-1\relax\space}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setnextsubsubsection}[1]{%
\setcounter{subsubsection}{\numexpr#1-1\relax}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatother
\makeatletter
\long\def\beamer@section[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture
\refstepcounter{section}%
\beamer@ifempty{#2}%
{\long\def\secname{#1}\long\def\lastsection{#1}}%
{\global\advance\beamer@tocsectionnumber by 1\relax%
\long\def\secname{#2}%
\long\def\lastsection{#1}%
\addtocontents{toc}{\protect\beamer@sectionintoc{\the\c@section}{#2\hfill\the\c@page}{\the\c@page}{\the\c@part}%
{\the\beamer@tocsectionnumber}}}%
{\let\\=\relax\xdef\sectionlink{{Navigation\the\c@page}{\noexpand\secname}}}%
\beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
\beamer@ifempty{#1}{}{%
\addtocontents{nav}{\protect\headcommand{\protect\sectionentry{\the\c@section}{#1}{\the\c@page}{\secname}{\the\c@part}}}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\the\beamer@tempcount}}}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}}%
}%
\beamer@sectionstartpage=\c@page%
\beamer@subsectionstartpage=\c@page%
\def\insertsection{\expandafter\hyperlink\sectionlink}%
\def\insertsubsection{}%
\def\insertsubsubsection{}%
\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
\def\insertsubsectionhead{}%
\def\insertsubsubsectionhead{}%
\def\lastsubsection{}%
\Hy@writebookmark{\the\c@section}{\secname}{Outline\the\c@part.\the\c@section}{2}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsections}{\beamer@atbeginsection}%
\fi%
\beamer@resumemode}%
\def\beamer@subsection[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture%
\refstepcounter{subsection}%
\beamer@ifempty{#2}{\long\def\subsecname{#1}\long\def\lastsubsection{#1}}
{%
\long\def\subsecname{#2}%
\long\def\lastsubsection{#1}%
\addtocontents{toc}{\protect\beamer@subsectionintoc{\the\c@section}{\the\c@subsection}{#2\hfill\the\c@page}{\the\c@page}{\the\c@part}{\the\beamer@tocsectionnumber}}%
}%
\beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
\addtocontents{nav}{%
\protect\headcommand{\protect\beamer@subsectionentry{\the\c@part}{\the\c@section}{\the\c@subsection}{\the\c@page}{\lastsubsection}}%
\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}%
}%
\beamer@subsectionstartpage=\c@page%
\edef\subsectionlink{{Navigation\the\c@page}{\noexpand\subsecname}}%
\def\insertsubsection{\expandafter\hyperlink\subsectionlink}%
\def\insertsubsubsection{}%
\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
\def\insertsubsubsectionhead{}%
\Hy@writebookmark{\the\c@subsection}{#2}{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@page}{3}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@page}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsubsections}{\beamer@atbeginsubsection}%
\fi%
\beamer@resumemode}
\def\beamer@subsubsection[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture%
\refstepcounter{subsubsection}%
\beamer@ifempty{#2}{\long\def\subsubsecname{#1}\long\def\lastsubsubsection{#1}}
{%
\long\def\subsubsecname{#2}%
\long\def\lastsubsubsection{#1}%
\addtocontents{toc}{\protect\beamer@subsubsectionintoc%
{\the\c@section}{\the\c@subsection}{\the\c@subsubsection}{#2\hfill\the\c@page}{\the\c@page}{\the\c@part}{\the\beamer@tocsectionnumber}}%
}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@subsubsectionentry%
{\the\c@part}{\the\c@section}{\the\c@subsection}{\the\c@subsubsection}{\the\c@page}{\lastsubsubsection}}}%
\edef\subsubsectionlink{{Navigation\the\c@page}{\noexpand\subsubsecname}}%
\def\insertsubsubsection{\expandafter\hyperlink\subsubsectionlink}%
\def\insertsubsubsectionhead{#1}%
\Hy@writebookmark{\the\c@subsubsection}{#2}{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@subsubsection.\the\c@page}{4}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@subsubsection.\the\c@page}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsubsubsections}{\beamer@atbeginsubsubsection}%
\fi%
\beamer@resumemode}
\makeatother
\renewcommand*{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand*{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\begin{document}
\begin{frame}{Table of Contents}{}%>>>
\tableofcontents
\end{frame}%<<<
\setnextsubsubsection{7}
\subsubsection{test}
\begin{frame}
\frametitle{\subsubsectiontitle}
\end{frame}
\end{document}
手册仍然beamer
建议根本不要使用\subsubsection
s(并声称如果您按照所说的去做,您将会做出更好的演示)。