
El siguiente código de proyector
\documentclass{beamer}
\setbeamertemplate{section in toc}[sections numbered]
\begin{document}
\frame{\tableofcontents}
\section{section one}
\frame{\insertsectionnumber\quad\insertsection}
\section*{section two}
\frame{\insertsectionnumber\quad\insertsection}
\section{section three}
\frame{\insertsectionnumber\quad\insertsection}
\end{document}
dar el siguiente resultado:
Sé que eso \tableofcontents
llama \inserttocsectionnumber
al comando. Cuando hay algunos \section*
comandos \inserttocsectionnumber
y \insertsectionnumber
dan resultados diferentes:2 sección tresy3 sección tres. ¿Por qué?
Respuesta1
Este es un código de beamerbasesection.sty
, con algunas anotaciones.
No hay distinción entre \section
y \section*
con respecto al paso del section
mostrador, al contrario de las clases estándar como article
. Como tal, el section
contador aumenta incluso con una \section*
orden.
¿Es esto un error? No, creo que es más fácil hacerlo para la contabilidad con todas las funciones sofisticadas debeamer
\newcommand<>{\section}{\alt#1{\@ifnextchar[\beamer@section\beamer@@section}{\beamer@secgobble}}
\def\beamer@@section{\@ifnextchar*\beamer@@ssection\beamer@@@section}
\long\def\beamer@@ssection*#1{\beamer@section[{#1}]{}} %% starred section
\long\def\beamer@@@section#1{\beamer@section[{#1}]{#1}}
\long\def\beamer@section[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture
\refstepcounter{section}% used in any case of \section or \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}{\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}%
Editar:
Algunos parches para evitar \refstepcounter
que entren en acción si \section*
se usan
\documentclass{beamer}
\usepackage{xpatch}
\makeatletter
\newif\ifisstarred% new if command
\isstarredfalse% % No starred section by default
\xpretocmd{\beamer@@ssection}{\isstarredtrue}{}{} % enable `*` mode
\xpatchcmd{\beamer@@ssection}{\beamer@section[{#1}]{}}{\beamer@section[{#1}]{}\isstarredfalse}{\typeout{Patch success beamer@@ssection}}{\typeout{Patch failure}}
\xpatchcmd{\beamer@section}{%
\refstepcounter{section}%
}{%
\ifisstarred%
% Do nothing in here
\else
\refstepcounter{section}%
\fi
}{\typeout{Patch success beamer@section}}{}
\makeatother
\setbeamertemplate{section in toc}[sections numbered]
\begin{document}
\frame{\tableofcontents}
\section{section one}
\frame{\insertsectionnumber\quad\insertsection}
%\inserttocsectionnumber
\section*{section two}
\typeout{Starred section}
\frame{\insertsectionnumber\quad\insertsection}
\section{section three}
\frame{\insertsectionnumber\quad\insertsection}
\end{document}