我正在用 Beamer 做我的第一个演示。我使用的是 CambridgeUS 主题,我想重新定义信息行,以便展示
- 标题上的演示文稿的标题
- 脚注上的作者、机构、日期和计数器
我写了下面的代码
\makeatletter
\setbeamertemplate{headline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{section in head/foot}\insertshorttitle\hspace*{2ex}
\end{beamercolorbox}%
}
\makeatother
\makeatletter
\setbeamertemplate{footline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{title in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshortinstitute
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} / \inserttotalframenumber\hspace*{2ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother
但我收到以下错误
扫描使用 \beamer@sbtexec 时文件结束
我认为错误在于headline的定义。事实上,如果我写了下面的代码
\makeatletter
\setbeamertemplate{headline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{section in head/foot}\insertshorttitle\hspace*{2ex}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshortinstitute
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} / \inserttotalframenumber\hspace*{2ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother
一切正常,但我不得不定义两个无用的 beamercolorbox。错误在哪里?
另外,我想隐藏演示文稿第一帧的标题。
我能怎么做?
答案1
您在定义中缺少最后的右括号headline
:
\documentclass{beamer}
\usetheme{CambridgeUS}
\makeatletter
\setbeamertemplate{headline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.75ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{section in head/foot}\insertshorttitle\hspace*{2ex}
\end{beamercolorbox}}% <- this closing brace was missing
}
\setbeamertemplate{footline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{title in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshortinstitute
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} / \inserttotalframenumber\hspace*{2ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother
\author{The Author}
\title{The Title}
\institute{The Institute}
\begin{document}
\begin{frame}
test
\end{frame}
\end{document}
我擅自稍微增加了标题框的高度(当然,这只是一个建议,您可以恢复到原来的设置)。
为了抑制headline
和 footline
,使用;plain
选项frame
仅抑制一个模板,在本地将其重新定义为空:
\documentclass{beamer}
\usetheme{CambridgeUS}
\makeatletter
\setbeamertemplate{headline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=2.75ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{section in head/foot}\insertshorttitle\hspace*{2ex}
\end{beamercolorbox}}%
}
\setbeamertemplate{footline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{title in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshortinstitute
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} / \inserttotalframenumber\hspace*{2ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother
\author{The Author}
\title{The Title}
\institute{The Institute}
\begin{document}
\begin{frame}[plain]
test
\end{frame}
\begingroup
\setbeamertemplate{headline}{}
\begin{frame}
test
\end{frame}
\endgroup
\begingroup
\setbeamertemplate{footline}{}
\begin{frame}
test
\end{frame}
\endgroup
\begin{frame}
test
\end{frame}
\end{document}