我使用了如何在 Beamer 导航栏中插入页码?在 beamer 导航栏中插入页码。但我试图从附录中排除页码。附录没有按预期计算,但它应该只是一页,上面写着“提问时间”之类的内容,没有任何附加内容(如页码)。更糟糕的是,在当前版本中,我必须在页码不正确或页码大于实际页数之间进行选择(如果您删除[noframenumbering]
)
我的最小“工作”示例:
\documentclass[ignorenonframetext, ngerman]{beamer}
\usepackage{etoolbox} % for \newtoggle and \iftoggle
\usetheme{Frankfurt}
% see https://tex.stackexchange.com/questions/686/how-to-get-rid-of-navigation-symbols-in-beamer
\beamertemplatenavigationsymbolsempty
\newtoggle{inAppendix}
\newcommand{\myAppendix}{\appendix\toggletrue{inAppendix}}
% see https://tex.stackexchange.com/questions/137022/how-to-insert-page-number-in-beamer-navigation-bars (I modified this)
\addtobeamertemplate{navigation symbols}{}{
\iftoggle{inAppendix}{}% do nothing in appendix
{% add number of frame
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
\insertframenumber/\inserttotalframenumber
}
}
\setbeamercolor{footline}{fg=black}
\title{Awesome project}
\author{Nomen nescio}
\begin{document}
\frame{\titlepage}
\frame{\tableofcontents[pausesections]}
\section{Test}
\begin{frame}
Stuff!
\end{frame}
\myAppendix
\begin{frame}[noframenumbering]
\Huge
Time for questions.
\end{frame}
\end{document}}
我的想法是使用一个切换开关来检查是否必须添加页码。我尝试用 替换切换开关,\newif\ifAppendix
但没有任何效果。我想我检查条件太晚了,更改切换开关的值时页码已经排版了。
后台发生了什么导致切换无效?如何获得附录中没有页码的输出?
答案1
\documentclass[ignorenonframetext, ngerman]{beamer}
\usetheme{Frankfurt}
\usepackage{appendixnumberbeamer}
\beamertemplatenavigationsymbolsempty
\addtobeamertemplate{navigation symbols}{}{
\ifnum\insertframenumber>\inserttotalframenumber%
\relax
\else%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
\insertframenumber/\inserttotalframenumber
\fi%
}
\setbeamercolor{footline}{fg=black}
\title{Awesome project}
\author{Nomen nescio}
\begin{document}
\frame{\titlepage}
\frame{\tableofcontents[pausesections]}
\section{Test}
\begin{frame}
Stuff!
\end{frame}
\appendix
\begin{frame}
\Huge
Time for questions.
\end{frame}
\end{document}
从 Beamer 3.49 版开始,解决方案可以简化为
\documentclass{beamer}
\usetheme{Frankfurt}
\makeatletter
\setbeamertemplate{navigation symbols}{
\ifbeamer@inappendix%
\else%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\insertframenumber\,/\,\insertmainframenumber%
\fi%
}
\makeatother
\begin{document}
\section{Test}
\begin{frame}
Stuff!
\end{frame}
\appendix
\begin{frame}
\Huge
Time for questions.
\end{frame}
\end{document}