0

When creating slides with beamer, there are two cases of frame titles I would like to use:

  1. The frame title is centered and displayed in one line, irrespective of \textwidth or \linewidth.
  2. The frame title is centered but displayed in more than one line if it is too long; linebreaks are automatically inserted if needed.

The first command has the advantage that I can get longer titles in one line, e. g. Long Title I have defined it this way and it works nicely:

\setbeamertemplate{frametitle}{%
  \vspace{1ex} \huge\rmfamily\centerline{\scshape{\insertframetitle}}
}

The second command is useful if I the the title cannot be displayed in one single line. Instead of enter image description here which would be produced by the first command, it should intelligently break the line and produce two-line title . The first line should of course have the same height as the line produced by the first function.

The Problem now is that I can't figure out how to create the second command. I'd like to call it \longtitle. Does anyone have an idea?

Here is a MWE:

\documentclass[hyperref={pdfpagemode=FullScreen},aspectratio=169]{beamer}

\setbeamertemplate{frametitle}{%
  \vspace{1ex} \huge\rmfamily\centerline{\scshape{\insertframetitle}}
}

%\newcommand{\longtitle}{}

\begin{document}
\begin{frame}
\frametitle{Warum das cartesische Produkt existiert}
\end{frame}
\begin{frame}
%\longtitle{Warum Mengen von Vereinigungspaaren existieren}
\end{frame}
\end{document}

1 Answer 1

1

You could just define your frame titles to exceed the text margins (although I would not necessarily advocate this). There would then no need to define a second macro:

\documentclass[hyperref={pdfpagemode=FullScreen},aspectratio=169]{beamer}

\makeatletter
\setbeamertemplate{frametitle}{%
  \vspace{1ex}%
  \hspace*{-\beamer@leftmargin}%
  \parbox{\paperwidth}{\centering\huge\rmfamily\scshape{\insertframetitle}}%
  \hspace*{-\beamer@rightmargin}%
}
\makeatother

\begin{document}
\begin{frame}
\frametitle{Warum das cartesische Produkt existiert}
\end{frame}
\begin{frame}
\frametitle{Warum Mengen von \\ Vereinigungspaaren existieren}
\end{frame}
\end{document}

enter image description here

enter image description here

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .