即使为空,我也可以强制调用 latex beamer frametitle 模板吗frametitle
?
因此,就我而言,我希望带有“Frametitle:”的黑框不仅出现在带有frametitle的框架上,而且出现在每张幻灯片上。
梅威瑟:
\documentclass{beamer}
%% redefine frametitle template
\setbeamercolor{frametitle}{fg = white, bg = black}
\setbeamertemplate{frametitle}{%
\vskip-3pt
\begin{beamercolorbox}[sep=0.6em,wd=\paperwidth,leftskip=0cm,rightskip=0cm]{frametitle}%
\vspace{-2pt}\par
\hspace{.4cm}Frametitle: \insertframetitle\strut
\end{beamercolorbox}%
}
%% mwe document:
\begin{document}
\begin{frame}{Heading}
beamer template ``frametitle'' is called
\end{frame}
\begin{frame}
beamer template ``frametitle'' is not called
\end{frame}
\end{document}
答案1
这是一个修补版本,beamer
即使标题为空,也总是调用模板:
\documentclass{beamer}
%% redefine frametitle template
\setbeamercolor{frametitle}{fg = white, bg = black}
\setbeamertemplate{frametitle}{%
\vskip-3pt
\begin{beamercolorbox}[sep=0.6em,wd=\paperwidth,leftskip=0cm,rightskip=0cm]{frametitle}%
\vspace{-2pt}\par
\hspace{.4cm}Frametitle: \insertframetitle\strut
\end{beamercolorbox}%
}
% make beamer always use the frametitle template, even if frametitle is empty
\usepackage{etoolbox}
\makeatletter
\patchcmd{\endbeamer@frameslide}{\ifx\beamer@frametitle\@empty}{\iffalse}{}{\errmessage{failed to patch}}
\makeatother
%% mwe document:
\begin{document}
\begin{frame}{Heading}
beamer template ``frametitle'' is called
\end{frame}
\begin{frame}{}
beamer template ``frametitle'' is not called
\end{frame}
\end{document}
答案2
您可以通过添加\null
或\mbox{}
或 来作弊\phantom{some text}
:
\documentclass{beamer}
%% redefine frametitle template
\setbeamercolor{frametitle}{fg = white, bg = black}
\setbeamertemplate{frametitle}{%
\vskip-3pt
\begin{beamercolorbox}[sep=0.6em,wd=\paperwidth,leftskip=0cm,rightskip=0cm]{frametitle}%
\vspace{-2pt}\par
\hspace{.4cm}Frametitle: \insertframetitle\strut
\end{beamercolorbox}%
}
%% mwe document:
\begin{document}
\begin{frame}{Heading}
beamer template ``frametitle'' is called
\end{frame}
\begin{frame}{\null}
beamer template ``frametitle'' is not called
\end{frame}
\end{document}