6

I have a beamer presentation with only three sections. Right now they are spaced at equal distances across the slide, but I would like to compress them so that they are spaced evenly in the left hand side of the headline.

Right now it looks like:

Section 1  ---------------------------- Section 2---------------------------Section 3

And I would prefer it to look like

Section 1-------Section 2-------Section 3

Is there a way to customize the horizontal width of the navigation bar at the top? Thank you in advance!

\documentclass[compress]{beamer}
\useoutertheme[footline=authortitle,subsection=false]{miniframes}
\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\frame{}\frame{}\frame{}
\subsection{Subsection 2}
\frame{}\frame{}
\section{Section 2}
\subsection{Subsection 1}
\frame{}\frame{}
\subsection{Subsection 2}
\frame{}\frame{}\frame{}
\section{Section 3}
\subsection{Subsection 1}
\frame{}\frame{}
\subsection{Subsection 2}
\frame{}\frame{}\frame{}
\end{document}
5

Yes, this is possible. Below I'll present two options: the first one is the easier and with sorter code, but depends on you giving the desired total width for the navigation bar; the second one offers you more flexibility and freedom (since you can control the separation between sections at will), but it requires a more involved modification.

  1. In this option you redefine the headline template, as implemented by the miniframes outer theme, so \insertnavigation doesn't take the whole \paperwidth; for example, using 0.5\paperwidth (change this value in the line marked with % Change here to suit your needs):

    \documentclass[compress]{beamer}
    \useoutertheme[footline=authortitle,subsection=false]{miniframes}
    
    \makeatletter
    \defbeamertemplate*{headline}{myminiframes theme}
    {%
      \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
      \end{beamercolorbox}
      \begin{beamercolorbox}{section in head/foot}
        \vskip2pt\insertnavigation{.5\paperwidth}\vskip2pt % Change here
      \end{beamercolorbox}%
      \ifbeamer@theme@subsection%
        \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
        \end{beamercolorbox}
        \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
          leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
          \usebeamerfont{subsection in head/foot}\insertsubsectionhead
        \end{beamercolorbox}%
      \fi%
      \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
      \end{beamercolorbox}
    }
    \makeatother
    
    \begin{document}
    \section{Section 1}
    \subsection{Subsection 1}
    \frame{}\frame{}\frame{}
    \subsection{Subsection 2}
    \frame{}\frame{}
    \section{Section 2}
    \subsection{Subsection 1}
    \frame{}\frame{}
    \subsection{Subsection 2}
    \frame{}\frame{}\frame{}
    \section{Section 3}
    \subsection{Subsection 1}
    \frame{}\frame{}
    \subsection{Subsection 2}
    \frame{}\frame{}\frame{}
    \end{document}
    

    The resulting headline:

    enter image description here

  2. In this option you need a redefinition of some beamer internals: \sectionentry and \insertnavigation (original definitions in beamerbasenavigation.sty). By changing \sectionsep (default of 20pt) you can have the desired separation between sections in the navigation bar:

    \documentclass[compress]{beamer}
    \useoutertheme[footline=authortitle,subsection=false]{miniframes}
    
    \newlength\sectionsep
    \setlength\sectionsep{20pt}% default 1.875ex plus 1fill
    
    \makeatletter
    \def\sectionentry#1#2#3#4#5{% section number, section title, page
      \ifnum#5=\c@part%
      \beamer@section@set@min@width
      \box\beamer@sectionbox\hskip\sectionsep%original: 1.875ex plus 1fill%
      \beamer@xpos=0\relax%
      \beamer@ypos=1\relax%
      \setbox\beamer@sectionbox=
      \hbox{\def\insertsectionhead{#2}%
        \def\insertsectionheadnumber{#1}%
        \def\insertpartheadnumber{#5}%
        {%
          \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
          \ifnum\c@section=#1%
            \hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot}}}%
          \else%
            \hyperlink{Navigation#3}{{\usebeamertemplate{section in head/foot shaded}}}%
          \fi}%
      }%
      \ht\beamer@sectionbox=1.875ex%
      \dp\beamer@sectionbox=0.75ex%
      \fi\ignorespaces}
    \def\insertnavigation#1{%
      \vbox{{%
        \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
        \beamer@xpos=0\relax%
        \beamer@ypos=1\relax%
        \hbox to #1{\hskip.3cm\setbox\beamer@sectionbox=\hbox{\kern1sp}%
          \ht\beamer@sectionbox=1.875ex%
          \dp\beamer@sectionbox=0.75ex%
            \hskip-\sectionsep% original -1.875ex plus 1fill
            \global\beamer@section@min@dim\z@
            \dohead%\hskip\sectionsep%
            \beamer@section@set@min@width
          \box\beamer@sectionbox\hfill\hfill %\hfill%\hskip.3cm
          }%
      }}}  
    \makeatother
    
    \begin{document}
    \section{Section 1}
    \subsection{Subsection 1}
    \frame{}\frame{}\frame{}
    \subsection{Subsection 2}
    \frame{}\frame{}
    \section{Section 2}
    \subsection{Subsection 1}
    \frame{}\frame{}
    \subsection{Subsection 2}
    \frame{}\frame{}\frame{}
    \section{Section 3}
    \subsection{Subsection 1}
    \frame{}\frame{}
    \subsection{Subsection 2}
    \frame{}\frame{}\frame{}
    \end{document}
    

    The resulting headline:

    enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.