4

I have a section navigation bar in my headline, and I want it to show the sections center aligned. Although, the section navigation bar is right aligned, I tried to position it in the center by setting the position manually using the following code:

\setbeamertemplate{headline}{%
\leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=\paperwidth,ht=12.5ex]{section in head/foot}%
      \insertsectionnavigation{0.5\paperwidth}
    \end{beamercolorbox}%
  }
}

With the above definition of the headline, here is the snap of one of the frames: sample frame

How can I get the text (the sections) in the section navigation bar center aligned?

3

1 Answer 1

3

I added two \hfill around \usebeamertemplate{section in head/foot} to make them centred.

\documentclass{beamer}

\usetheme{Berlin}

\setbeamertemplate{headline}{%
    \leavevmode%
    \hbox{%
        \begin{beamercolorbox}[wd=\paperwidth,ht=12.5ex]{section in head/foot}%
            \insertsectionnavigation{\paperwidth}
        \end{beamercolorbox}%
    }
}

\makeatletter
\def\insertsectionnavigation#1{%
    \hbox to #1{%
        \vbox{{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
                \vskip0.5625ex%
                \def\slideentry##1##2##3##4##5##6{}%
                \def\sectionentry##1##2##3##4##5{%
                    \ifnum##5=\c@part%
                    \def\insertsectionhead{##2}%
                    \def\insertsectionheadnumber{##1}%
                    \def\insertpartheadnumber{##5}%
                    \setbox\beamer@tempbox=\hbox{%
                        \hyperlink{Navigation##3}{\hbox to #1{%
                                \hskip0.3cm%
                                \ifnum\c@section=##1%
                                {\hfill\usebeamertemplate{section in head/foot}\hfill}%
                                \else%
                                {\hfill\usebeamertemplate{section in head/foot shaded}\hfill}%
                                \fi\hskip0.3cm}}}%
                    \ht\beamer@tempbox=1.6875ex\dp\beamer@tempbox=0.75ex%
                    \box\beamer@tempbox\fi}%
                \dohead\vskip0.5625ex}}\hfil}}
\makeatother


\begin{document}

\section{loooooooooooooong}
\frame{as}

\section{er}
\frame{sd}

\end{document}

enter image description here

0

You must log in to answer this question.

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