7

Can I force the latex beamer frametitle template to be called even if the frametitle is empty?

So in my case I want the black box with "Frametitle: " to appear not only for frames with frametitle, but on every slide.

MWE:

\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}
5

Here's a version that patches beamer to always invoke the template even if the title is empty:

\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}
8

You can cheat by adding a \null or \mbox{} or \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}

enter image description here

  • 3
    \begin{frame}{{}} will do it. – Loop Space Sep 17 '13 at 8:36
  • Thank you. The \begin{frame}{{}} is the most elegant solution at the moment. Nevertheless, I want to add it to a new beamer theme an it should be done hidden somehow. Maybe I can redefine the frame-environment? – matheburg Sep 17 '13 at 10:20
  • Another way which keeps other related formatting (for me it is important): \begin{frame}{\strut} – matheburg Sep 17 '13 at 10:25

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.