[Tex/LaTex] Navigation bar is too long on progressbar theme, can it wrap

beamer

My navigation bar at the top of each slide (that links to each section) has too many sections. I would like to keep the bar and keep each section but I would like to wrap it i.e. have it on two lines.

Is that possible?

I am using compress and I am using progressbar as a theme.

Best Answer

You could redefine the \insertsectionnavigationhorizontal command and wrap the sections with a parbox.

Here is a quick & dirty example of it could be done in general:

\makeatletter
\def\insertsectionnavigationhorizontal#1#2#3{%
 \hbox to #1{{%
   \def\slideentry##1##2##3##4##5##6{}%
   #2\hskip.3cm%
   \newdimen\tmp@parbox%
   \setlength\tmp@parbox{#1}%
   \addtolength\tmp@parbox{-.6cm}%
   \parbox{\tmp@parbox}{\raggedleft%
     \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
     \setbox\beamer@sectionbox=\hbox{}%
     \ht\beamer@sectionbox=1.875ex%
     \dp\beamer@sectionbox=0.75ex%
     \hskip-1.875ex plus-1fill\dohead%
     \box\beamer@sectionbox}\hfil\hskip.3cm%
     #3}}}
\makeatother

Here is a complete example for the progressbar theme, with increased headline height.

\documentclass[compress]{beamer}

\usetheme{progressbar}
\progressbaroptions{headline=sections}

\makeatletter
\def\insertsectionnavigationhorizontal#1#2#3{%
  \hbox to #1{{%
    \def\slideentry##1##2##3##4##5##6{}%
    #2\hskip.3cm%
    \newdimen\tmp@parbox%
    \setlength\tmp@parbox{#1}%
    \addtolength\tmp@parbox{-.6cm}%
    \parbox{\tmp@parbox}{\raggedleft%
      \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
      \setbox\beamer@sectionbox=\hbox{}%
      \ht\beamer@sectionbox=1.875ex%
      \dp\beamer@sectionbox=0.75ex%
      \hskip-1.875ex plus-1fill\dohead%
      \box\beamer@sectionbox}\hfil\hskip.3cm%
      #3}}}

\setbeamertemplate{headline}
{%
  \edef\tempa{sections}
  \ifx\progressbar@headline\tempa
  \leavevmode%
  \begin{beamercolorbox}[ignorestructure.bg=true,wd=\paperwidth,ht=8ex,dp=1.125ex]{structure.fg}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{}%\hskip0pt plus1filll}{}%
    \vspace*{0mm}
  \end{beamercolorbox}%
  \else
  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,dp=1.125ex]{structure.fg}%
  \end{beamercolorbox}%
  \fi
}

\makeatother

\begin{document}

\section{First very long section name}
\section{Second very long section name}
\section{Third very long section name}
\section{Fourth very long section name}
\section{Fifth very long section name}

\begin{frame}{Title}
Content
\end{frame}

\end{document}

enter image description here