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}
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – cfr Jan 2 '15 at 15:33
  • Have you tried a different theme? This doesn't usually happen... – cfr Jan 2 '15 at 15:34
  • 1
    This happens with beamer default theme as well. And I like the Singapore theme more than I dislike this movement :) – p91paul Jan 2 '15 at 15:41
  • 1
    maybe some help here: Keep frame title constant height regardless of content. – barbara beeton Jan 2 '15 at 16:04
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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.