在我为beamer
班级撰写的演示文稿中,我有以下一段代码:
\documentclass[dvips, 9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}
\setbeamertemplate{footline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
\usebeamerfont{author in head/foot}\hspace*{1em}good footline
\end{beamercolorbox}}%
\vskip0pt}
\begin{document}
\begin{frame}
Frame one (with footline)
\end{frame}
\begin{frame}
Frame two (with footline)
\end{frame}
\end{document}
给出了正确的脚注。但是,下面的代码
\documentclass[dvips, 9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}
\newcommand\Switttch{0}
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}{}{\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
\usebeamerfont{author in head/foot}\hspace*{1em}bad footline
\end{beamercolorbox}}%
\vskip0pt}}
\begin{document}
\begin{frame}
Frame one (without footline)
\end{frame}
\renewcommand\Switttch{1}
\begin{frame}
Frame two (with footline)
\end{frame}
\end{document}
在第二个框架上给出与页面底线重叠的页脚线。第二段代码有什么问题?(我想为不同的框架打开和关闭页脚线。)
答案1
(将我的答案从评论移到这里,现在放在给出的 MWE 的上下文中。)
beamer
仅计算一次headline
s 和s的大小(高度) (我认为是在 处)。如果您希望在不同的幻灯片上使用不同高度的 s,并且不想采用 egreg 的方法(使用 struts 使所有s 都显示相同的高度),则可以在高度与前一帧发生变化的每个帧之前调用 来要求重新计算高度。footline
\begin{document}
footline
footline
beamer
\beamer@calculateheadfoot
footline
我已经修改了你的语法,以便\Switttch
于进行更改。
\documentclass[dvips, 9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}
\newcommand\Switttch{0}
\makeatletter
\newcommand*\setSwitttch[1]{\renewcommand\Switttch{#1}\beamer@calculateheadfoot}
\makeatother
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}{}{\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
\usebeamerfont{author in head/foot}\hspace*{1em}bad footline
\end{beamercolorbox}}%
\vskip0pt}}
\begin{document}
\begin{frame}
Frame one (without footline)
\end{frame}
\setSwitttch{1}
\begin{frame}
Frame two (with footline)
\end{frame}
\end{document}
现在footline
,在两张幻灯片上都出现在正确的位置,并且导航按钮/主幻灯片内容现在位于的正上方footline
。
答案2
我认为更简单的定义
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}
{\vrule height 2.25ex depth 1ex width 0pt}
{\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
\usebeamerfont{author in head/foot}\hspace*{1em}Good footline
\end{beamercolorbox}}}
将会做你想做的事。
答案3
随着当前 beamer 开发版本(应包含在 beamer v3.70 或更新版本中),beamer 现在会在每帧开始时重新计算头部和脚部的高度,因此您的示例开箱即可正常工作
\documentclass[9pt, unicode, t]{beamer}
\usepackage{ifthen}
\usetheme{CambridgeUS}
\newcommand\Switttch{0}
\setbeamertemplate{footline}{%
\ifthenelse{\equal{\Switttch}{0}}{}{\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{author in head/foot}%
\usebeamerfont{author in head/foot}\hspace*{1em}bad footline
\end{beamercolorbox}}%
\vskip0pt}}
\begin{document}
\begin{frame}
Frame one (without footline)
\end{frame}
\renewcommand\Switttch{1}
\begin{frame}
Frame two (with footline)
\end{frame}
\end{document}