以下 MCE 指出,对于某些beamer
主题,框架标题是垂直的:
- 在有(可能不可见的)框架字幕的情况下顶部对齐,
- 居中显示,无框架字幕。
我怎样才能使框架标题在所有情况下都顶部对齐?
\documentclass[9pt]{beamer}
\usetheme{PaloAlto}
\begin{document}
\begin{frame}
\frametitle{Top aligned frame title if subtitle}
\framesubtitle{Frame subtitle}
\end{frame}
\begin{frame}
\frametitle{Top aligned frame title if (possibly invisible) subtitle}
\framesubtitle{\mbox{}}
\end{frame}
\begin{frame}
\frametitle{Vertically centered frame title if no frame subtitle}
\end{frame}
\end{document}
答案1
\strut
您可以在frametitle
模板中插入类似内容
\documentclass[9pt]{beamer}
\usetheme{PaloAlto}
\makeatletter
\setbeamertemplate{frametitle}{%
\nointerlineskip%
\vskip-\beamer@headheight%
\vbox to \beamer@headheight{%
\vfil
\leftskip=-\beamer@leftmargin%
\advance\leftskip by0.3cm%
\rightskip=-\beamer@rightmargin%
\advance\rightskip by0.3cm plus1fil%
{\usebeamercolor[fg]{frametitle}\usebeamerfont{frametitle}\insertframetitle\par}%
{\usebeamercolor[fg]{framesubtitle}\usebeamerfont{framesubtitle}%
\strut% NEW
\insertframesubtitle\par}%
\vbox{}%
\vskip-1em%
\vfil
}%
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{Top aligned frame title if subtitle}
\framesubtitle{Frame subtitle}
\end{frame}
\begin{frame}
\frametitle{Top aligned frame title if (possibly invisible) subtitle}
\framesubtitle{\mbox{}}
\end{frame}
\begin{frame}
\frametitle{Vertically centered frame title if no frame subtitle}
\end{frame}
\end{document}