4

I am writing a presentation using Latex and beamer. Each frame in my presentation has a title, and may or may not have an additional subtitle.

What bothers me is that when there is the subtitle, the title moves a little up, and that movement is evident (and looks bad) during the slideshow.

\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}
p91paul
  • 143

1 Answers1

2

You can add blank line if no subtitle is provided.

\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}
Marco Daniel
  • 95,681
  • I see it's the very same code from http://tex.stackexchange.com/a/171414/579, except for the \ifx\insertframesubtitle@empty. Can you explain me the reason for that? – p91paul Jan 03 '15 at 14:16
  • @p91paul It tests whether there is a frametitle or not. For more details see: http://tex.stackexchange.com/questions/127502/difference-between-if-and-ifx – Marco Daniel Jan 03 '15 at 14:37