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}{%
\hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@frametitletopmshade}\hskip-\Gm@rmargin}
\nointerlineskip%
}%
\@tempdima=\textwidth%
\advance\@tempdima by\beamer@leftmargin%
\advance\@tempdima by\beamer@rightmargin%
\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}{}{%
\hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@frametitlebottomshade}\hskip-\Gm@rmargin}%
\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.
Best Answer
You can use
\hspace{0pt plus 1 filll}
instead of\hfill
:The environment
beamercolorbox
has predefined left and right margins which are defined with the skip0pt 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:egreg wrote an answer to this special registers: What is the difference between 'fil' and 'fill'?