[Tex/LaTex] Beamer Navigation bar too long

beamernavigation

My navigation bar in Beamer is too long with the way it is presently formatted.
I have considered going to multiple lines for the circle navigation, but this results in the vertical space of the navigation bar taking up too much space.
I seem to recall at some point seeing a presentation where the circles collapse down to a single circle unless actually inside of the current subsection where they expand back out to have dots for each frame at that point.

I would appreciate suggestions on how to keep the single line navigation bar like I have, but ways to condense the bar so it will fit within the width I have.

enter image description here

I also seem to recall seeing a presentation where there were lines between the circle navigation markers for each subsubsection of the presentation, but haven't been able to find something about how to do that yet. If you could point me to where that might be located, that would be great.

Thanks in advance.

Best Answer

The beamer template mini frames has 3 predefined templates:

  • [default] shows small circles as mini frames
  • [box] shows small rectangles as mini frames
  • [tick] shows small vertical bars as mini frames

So you could for example just switch to the tick template as it doesn't occupy so much space:

\setbeamertemplate{mini frame}[tick]
\setbeamertemplate{mini frame in current subsection}{tick}

But it seems like you want to keep the circles. So why not just scale them down. To do that you have to redefine the mini frame templates. So I just copied the default template, renamed it to scaled circle and introduced a scaling factor.

\defbeamertemplate{mini frame}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}
[action]
{
  \newlength{\myminiframesize}
  \setlength{\myminiframesize}{0.14cm}
  \newlength{\myminiframeoffset}
  \setlength{\myminiframeoffset}{0.03cm}
  \setbeamersize{mini frame size=#1\myminiframesize,mini frame offset=#1\myminiframeoffset}
}

\defbeamertemplate{mini frame in current section}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in current subsection}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

You can then just load it with

\setbeamertemplate{mini frame}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current section}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current subsection}[scaled circle]{0.7}

where 0.7 is the scaling factor.

Complete MWE:

\documentclass[compress]{beamer}
\usepackage{calc}
\useoutertheme{miniframes}

\defbeamertemplate{mini frame}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}
[action]
{
  \newlength{\myminiframesize}
  \setlength{\myminiframesize}{0.14cm}
  \newlength{\myminiframeoffset}
  \setlength{\myminiframeoffset}{0.03cm}
  \setbeamersize{mini frame size=#1\myminiframesize,mini frame offset=#1\myminiframeoffset}
}

\defbeamertemplate{mini frame in current section}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in current subsection}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\setbeamertemplate{mini frame}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current section}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current subsection}[scaled circle]{0.7}

\begin{document}

\section{Section 1}
\subsection{Subsection 1}
\frame{Frame 1}
\frame{Frame 2}
\frame{Frame 3}
\frame{Frame 4}
\frame{Frame 5}
\frame{Frame 6}
\frame{Frame 7}
\frame{Frame 8}
\frame{Frame 9}
\frame{Frame 10}
\subsection{Subsection 2}
\frame{Frame 1}
\frame{Frame 2}
\frame{Frame 3}
\frame{Frame 4}
\frame{Frame 5}
\frame{Frame 6}
\frame{Frame 7}
\frame{Frame 8}
\frame{Frame 9}
\frame{Frame 10}

\end{document}

Scaling Factor = 0.7

scaling0.7

Scaling Factor = 1

scaling1

Scaling Factor = 2

scaling2

EDIT – Connect Circles

\makeatletter
\def\slideentry#1#2#3#4#5#6{%
  %section number, subsection number, slide number, first/last frame, page number, part number
  \ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
    \ifbeamer@compress%
      \advance\beamer@xpos by1\relax%
    \else%
      \beamer@xpos=#3\relax%
      \beamer@ypos=#2\relax%
    \fi%
  \hbox to 0pt{%
    \beamer@tempdim=-\beamer@vboxoffset%
    \advance\beamer@tempdim by-\beamer@boxsize%
    \multiply\beamer@tempdim by\beamer@ypos%
    \advance\beamer@tempdim by -.05cm%
    \raise\beamer@tempdim\hbox{%
      \beamer@tempdim=\beamer@boxsize%
      \multiply\beamer@tempdim by\beamer@xpos%
      \advance\beamer@tempdim by -\beamer@boxsize%
      \advance\beamer@tempdim by 1pt%
      \kern\beamer@tempdim
      \global\beamer@section@min@dim\beamer@tempdim
      \hbox{\beamer@link(#4){%
          \usebeamerfont{mini frame}%
          \ifnum\c@section=#1%
            \ifnum\c@subsection=#2%
              \usebeamercolor[fg]{mini frame}%
              \ifnum\c@subsectionslide=#3%
                \ifnum#3=1%
                  \usebeamertemplate{mini frame first}%\beamer@minislidehilight%
                \else%
                  \usebeamertemplate{mini frame}%\beamer@minislidehilight%
                \fi
              \else%
                \ifnum#3=1%
                  \usebeamertemplate{mini frame in current subsection first}%
                \else%
                  \usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
                \fi
              \fi%
            \else%
              \usebeamercolor{mini frame}%
              %\color{fg!50!bg}%
              \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
            \fi%
          \else%
            \usebeamercolor{mini frame}%
            %\color{fg!50!bg}%
            \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
          \fi%
        }}}\hskip-10cm plus 1fil%
  }\fi\fi%
  \else%
  \fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
  \fi\ignorespaces
  }
\makeatother

\defbeamertemplate{mini frame}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathmoveto{\pgfpoint{0cm}{#1 * 0.05cm}} 
    \pgfpathlineto{\pgfpoint{#1 * -0.04cm}{#1 * 0.05cm}} 
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}
[action]
{
  \newlength{\myminiframesize}
  \setlength{\myminiframesize}{0.14cm}
  \newlength{\myminiframeoffset}
  \setlength{\myminiframeoffset}{0.03cm}
  \setbeamersize{mini frame size=#1\myminiframesize,mini frame offset=#1\myminiframeoffset}
}

\defbeamertemplate{mini frame first}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}


\defbeamertemplate{mini frame in current section}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathmoveto{\pgfpoint{0cm}{#1 * 0.05cm}} 
    \pgfpathlineto{\pgfpoint{#1 * -0.04cm}{#1 * 0.05cm}} 
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in other section}{scaled circle}[1]
{%
  \color{fg!50!bg}
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in current subsection}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathmoveto{\pgfpoint{0cm}{#1 * 0.05cm}} 
    \pgfpathlineto{\pgfpoint{#1 * -0.04cm}{#1 * 0.05cm}} 
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in current subsection first}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in other subsection}{scaled circle}[1]
{%
  \color{fg!50!bg}
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\setbeamertemplate{mini frame}[scaled circle]{0.7}
\setbeamertemplate{mini frame first}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current section}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current subsection}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current subsection first}[scaled circle]{0.7}
\setbeamertemplate{mini frame in other section}[scaled circle]{0.7}
\setbeamertemplate{mini frame in other subsection}[scaled circle]{0.7}

Output:

connected

EDIT 2 – Collapse Other Subsections

\makeatletter
\def\slideentry#1#2#3#4#5#6{%
  %section number, subsection number, slide number, first/last frame, page number, part number
  \ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
    \ifbeamer@compress%
      \ifnum\c@section=#1
        \ifnum\c@subsection=#2
          \advance\beamer@xpos by1\relax%
        \else%
          \ifnum#3=1%
            \advance\beamer@xpos by1\relax%
          \fi
        \fi
      \else%
        \ifnum#3=1%
          \advance\beamer@xpos by1\relax%
        \fi
      \fi
    \else%
      \beamer@xpos=#3\relax%
      \beamer@ypos=#2\relax%
    \fi%
  \hbox to 0pt{%
    \beamer@tempdim=-\beamer@vboxoffset%
    \advance\beamer@tempdim by-\beamer@boxsize%
    \multiply\beamer@tempdim by\beamer@ypos%
    \advance\beamer@tempdim by -.05cm%
    \raise\beamer@tempdim\hbox{%
      \beamer@tempdim=\beamer@boxsize%
      \multiply\beamer@tempdim by\beamer@xpos%
      \advance\beamer@tempdim by -\beamer@boxsize%
      \advance\beamer@tempdim by 1pt%
      \kern\beamer@tempdim
      \global\beamer@section@min@dim\beamer@tempdim
      \hbox{\beamer@link(#4){%
          \usebeamerfont{mini frame}%
          \ifnum\c@section=#1%
            \ifnum\c@subsection=#2%
              \usebeamercolor[fg]{mini frame}%
              \ifnum\c@subsectionslide=#3%
                \ifnum#3=1%
                  \usebeamertemplate{mini frame first}%\beamer@minislidehilight%
                \else%
                  \usebeamertemplate{mini frame}%\beamer@minislidehilight%
                \fi
              \else%
                \ifnum#3=1%
                  \usebeamertemplate{mini frame in current subsection first}%
                \else%
                  \usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
                \fi
              \fi%
            \else%
              \ifnum#3=1%
                \usebeamercolor{mini frame}%
                %\color{fg!50!bg}%
                \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
              \fi
            \fi%
          \else%
            \ifnum#3=1%
              \usebeamercolor{mini frame}%
              %\color{fg!50!bg}%
              \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
            \fi
          \fi%
        }}}\hskip-10cm plus 1fil%
  }\fi\fi%
  \else%
  \fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
  \fi\ignorespaces
  }
\makeatother

\defbeamertemplate{mini frame}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathmoveto{\pgfpoint{0cm}{#1 * 0.05cm}} 
    \pgfpathlineto{\pgfpoint{#1 * -0.04cm}{#1 * 0.05cm}} 
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}
[action]
{
  \newlength{\myminiframesize}
  \setlength{\myminiframesize}{0.14cm}
  \newlength{\myminiframeoffset}
  \setlength{\myminiframeoffset}{0.03cm}
  \setbeamersize{mini frame size=#1\myminiframesize,mini frame offset=#1\myminiframeoffset}
}

\defbeamertemplate{mini frame first}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}


\defbeamertemplate{mini frame in current section}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathmoveto{\pgfpoint{0cm}{#1 * 0.05cm}} 
    \pgfpathlineto{\pgfpoint{#1 * -0.04cm}{#1 * 0.05cm}} 
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in other section}{scaled circle}[1]
{%
  \color{fg!50!bg}
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in current subsection}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathmoveto{\pgfpoint{0cm}{#1 * 0.05cm}} 
    \pgfpathlineto{\pgfpoint{#1 * -0.04cm}{#1 * 0.05cm}} 
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in current subsection first}{scaled circle}[1]
{%
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\defbeamertemplate{mini frame in other subsection}{scaled circle}[1]
{%
  \color{fg!50!bg}
  \begin{pgfpicture}{0pt}{0pt}{#1 * 0.1cm}{#1 * 0.1cm}
    \pgfsetlinewidth{#1 * 0.4pt}
    \pgfpathcircle{\pgfpoint{#1 * 0.05cm}{#1 * 0.05cm}}{#1 * 0.05cm}
    \pgfusepath{stroke}
  \end{pgfpicture}%
}

\setbeamertemplate{mini frame}[scaled circle]{0.7}
\setbeamertemplate{mini frame first}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current section}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current subsection}[scaled circle]{0.7}
\setbeamertemplate{mini frame in current subsection first}[scaled circle]{0.7}
\setbeamertemplate{mini frame in other section}[scaled circle]{0.7}
\setbeamertemplate{mini frame in other subsection}[scaled circle]{0.7}