我正在使用 Latex 和 beamer 编写演示文稿。演示文稿中的每一帧都有一个标题,并且可能有或可能没有附加副标题。
令我烦恼的是,当有字幕时,标题会稍微向上移动,而且在幻灯片放映期间这种移动很明显(而且看起来很糟糕)。
\documentclass[14pt]{beamer}
\usetheme{Singapore}
\begin{document}
\begin{frame}
\frametitle{This is a title}
\framesubtitle{This is a subtitle}
This is the text
\end{frame}
\begin{frame}
\frametitle{This is a title}
This is the text
\end{frame}
\end{document}
答案1
如果没有字幕,您可以添加空白行。
\documentclass[14pt]{beamer}
\usetheme{Singapore}
\makeatletter
\setbeamertemplate{frametitle}%
{
\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
\@tempdima=\textwidth%
\advance\@tempdima by\beamer@leftmargin%
\advance\@tempdima by\beamer@rightmargin%
\begin{beamercolorbox}[sep=0.3cm,center,wd=\the\@tempdima]{frametitle}
\usebeamerfont{frametitle}%
\vbox{}\vskip-1ex%
\if@tempswa\else\csname beamer@ftecenter\endcsname\fi%
\strut\insertframetitle\strut\par%
{%
\ifx\insertframesubtitle\@empty%
{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\strut\par}%
\else%
{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
\fi%
}%
\vskip-1ex%
\if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
\end{beamercolorbox}%
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{This is a title}
\framesubtitle{This is a subtitle}
This is the text
\end{frame}
\begin{frame}
\frametitle{This is a title}
This is the text
\end{frame}
\end{document}