# Using \hfill in a beamer \frametitle in the wuerzburg theme

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:

\documentclass[xcolor={x11names,svgnames,dvipsnames}]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\useoutertheme[nofootline]{wuerzburg}
\usecolortheme{shark}
%\setbeamertemplate{frametitle}[default][none] % uncommenting this gives proper placement but overrides the frametitle definition of the outer theme.
\begin{document}

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


This is the result:

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]
{
\nointerlineskip
\ifbeamercolorempty[bg]{frametitle}{\vskip0.5ex}{%
\nointerlineskip%
}%
\@tempdima=\textwidth%
\begin{beamercolorbox}[sep=0.3cm,#1,wd=\the\@tempdima]{frametitle}
\usebeamerfont{frametitle}%
\vbox{}\vskip-1.7ex%
\if@tempswa\else\csname beamer@fte#1\endcsname\fi%
\strut\insertframetitle\strut\par%
{%
\ifx\insertframesubtitle\@empty%
\else%
{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
\fi
}%
\vskip-1.3ex%
\if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
\end{beamercolorbox}%
\nointerlineskip
\ifbeamercolorempty[bg]{frametitle}{}{%
\vskip-1.5pt%
}%
}


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.

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:

\documentclass[]{article}
\parindent0pt
\usepackage{showframe}
\begin{document}

\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
\end{document}


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 '13 at 12:01
• Just for curiosity, would you mind explaining the difference between the two? – MatteoS Jun 8 '13 at 12:03
• @MatteoS: Does the edit help? – Marco Daniel Jun 8 '13 at 12:14