7

I want the title of my frames to be a little more to the right than it is the case by default. I thought I had the ideal solution with

 \addtobeamertemplate{frametitle}{\hspace*{1em}}{}

(1em just as example). But the "pre-text" and "post-text" arguments don't work as expected (and described in the beamer doc). :-(

MWE:

\documentclass{beamer}
\addtobeamertemplate{frametitle}{X}{Z}
\begin{document}
\begin{frame}{Foo}
\begin{itemize}
\item Bar
\end{itemize}
\end{frame}
\end{document}

So does anyone know how to accomplish what I want?

3
  • 1
    Welcome to TeX.SX! Your suggested solution (\addtobeamertemplate{frametitle}{\hspace*{1em}}{}) works perfectly fine here, what does it do in your system? Oct 17, 2015 at 16:26
  • @TorbjørnT. it does not work perfectly. The default template is a box of width \textwidth and the \hspace moves it in the right margin and you get an overfull \hbox. Oct 17, 2015 at 17:29
  • @UlrikeFischer Ah, I see, didn't notice the warning. Thanks. Oct 17, 2015 at 17:41

2 Answers 2

7

\addtobeamertemplate allows "you a limited form of modification of existing templates." If (and how) it works depends a lot on the code of the template you want to change. In the case of the frametitle the default template (defined in beamerouterthemedefault.sty) is more or less a box of width \textwidth and so if you add something before you push the box in the right margin or to the next line.

So you will either have to redefine the template completly (or define a new one) or you can try to patch the template definition. Such a patch naturally depends a lot on the actual code too:

\documentclass{beamer}
\makeatletter
\usepackage{xpatch}
\patchcmd\beamer@@tmpl@frametitle{sep=0.3cm}{sep=1cm}{}{}
\makeatother
\begin{document}
\begin{frame}{Foo blbla blabl ablalb blablalb XXXXX XXXX blablabla blablabl blalab blablablala}
akbkbkb
\begin{itemize}
\item Bar
\end{itemize}
\end{frame}
\end{document}

Unpatched

enter image description here

With patch

enter image description here

2
  • 1
    Okay, that works reasonably well but could you please also state what the two non-empty arguments of that call do exactly? As far as I can tell from the docs, they are called "X" and "Y" but when experimenting with them, I found that anything other than "sep=0.3cm" for the first one leads to no change at all. And the second one seems to affect the distance of the frametitle from the upper left corner along the diagonal??
    – Chris K
    Oct 18, 2015 at 16:18
  • \patchcmd replaces the original sep=0.3cm in the frametitle code by sep=1cm. sep is described in the beamer documentation (look for \beamercolorbox). \patchcmd in etoolbox and/or xpatch. Oct 18, 2015 at 16:42
9

The default outer theme defines the frametitle colorbox with options [sep=0.3cm,#1,wd=\the\@tempdima]. Therefore, an easy way to push the title to the right is to define the frametitle template as

\setbeamertemplate{frametitle}[default][left,leftskip=1cm] % <-- choose here the leftskip you wish

To automatically align the frametitle with the rest of the text, you can write

\makeatletter
\setbeamertemplate{frametitle}[default][left,leftskip=\the\dimexpr\[email protected]\relax]
\makeatother

(0.3cm is subtracted because the default value for sep is 0.3cm)

You must log in to answer this question.

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