I'm using a set of beautiful beamer templates developed by Christian Gogolin and I'm struggling to get the desired effect using the \hfill command in \frametitle{} in order to have a beamer button aligned completely to the right in the frame title.

Here is a MWE, using Gogolin's own wuerzburg beamer outer theme:


%\setbeamertemplate{frametitle}[default][none] % uncommenting this gives proper placement but overrides the frametitle definition of the outer theme. 

\frametitle{This is the frame title \hfill \beamergotobutton{right}}
Some text

This is the result:

<code>Example frame with unaligned button</code>

The "right" beamer button is not aligned right as expected; its absolute position also changes based on the lenght of the title text.

I tried to implement the advice given on google groups: using \frametitle{Title \hspace{1 filll} Logo} (1 filll or 1 fill both do not work).

Using \setbeamertemplate{frametitle}[default][none] gives proper placement but overrides the frametitle definition of the outer theme.

I imagine that the fix would involve the definition of frametitle template in the wuerzburg theme:

\defbeamertemplate*{frametitle}{wuerzburg theme}[1][left]
    \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@frametitletopmshade}\hskip-\Gm@rmargin}
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
    \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
    \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@frametitlebottomshade}\hskip-\Gm@rmargin}%

But I can't figure out what goes wrong here: the text width seems to be correct and I don't understand the role of \strut\par around \insertframetitle.

Any help is appreciated.

1 Answer 1


You can use \hspace{0pt plus 1 filll} instead of \hfill:

\frametitle{This is the frame title \hspace{0pt plus 1 filll}  \beamergotobutton{right}}

The environment beamercolorboxhas predefined left and right margins which are defined with the skip 0pt plus 1fill. If you are using \hfill the word is centered for the right part. To show the behaviour you can use the following mwe:


\null Word \hfill word \par

\null Word \hfill word \hfill\null\par

\null\hspace{0pt plus 1fill} Word \hfill word \hspace{0pt plus 1fill}\null\par

\null\hspace{0pt plus 1fill} Word \hspace{0pt plus 1filll} word \hspace{0pt plus 1fill}\null\par

enter image description here

egreg wrote an answer to this special registers: What is the difference between 'fil' and 'fill'?

  • Well, that was fast! Thank you. I'll accept your answer as soon as I'm allowed to.
    – MatteoS
    Jun 8, 2013 at 12:01
  • 1
    Just for curiosity, would you mind explaining the difference between the two?
    – MatteoS
    Jun 8, 2013 at 12:03
  • @MatteoS: Does the edit help? Jun 8, 2013 at 12:14

You must log in to answer this question.

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