5

I like the Darmstadt theme in Beamer, but my presentation has to many sections for the headline. I tried to find an elegant solution, without success so far.

Do you know if it is possible to show only a part of the headline? My idea is to have a headline that shows as many sections as possible around (ie before and/or after) the current section.

Thank you for your help.

Cheers

Here is a MWE:

\documentclass{beamer}

\usetheme{Darmstadt}

\begin{document}

\section{Section 1}
\subsection{Subsection 1.1}
\begin{frame}{Frame 1.11}
...
\end{frame}
\begin{frame}{Frame 1.12}
...
\end{frame}
\begin{frame}{Frame 1.13}
...
\end{frame}
\subsection{Subsection 1.2}
\begin{frame}{Frame 1.21}
...
\end{frame}
\begin{frame}{Frame 1.22}
...
\end{frame}
\begin{frame}{Frame 1.23}
...
\end{frame}

\section{Section 2}
\begin{frame}{Frame 2}
...
\end{frame}

\section{Section 3}
\begin{frame}{Frame 3}
...
\end{frame}

\section{Section 4}
\begin{frame}{Frame 4}
...
\end{frame}

\section{Section 5}
\begin{frame}{Frame 5}
...
\end{frame}

\section{Section 6}
\begin{frame}{Frame 6}
...
\end{frame}

\section{Section 7}
\begin{frame}{Frame 7}
...
\end{frame}

\section{Section 8}
\begin{frame}{Frame 8}
...
\end{frame}

\section{Section 9}
\subsection{Subsection 9.1}
\begin{frame}{Frame 9.11}
...
\end{frame}
\begin{frame}{Frame 9.12}
...
\end{frame}
\begin{frame}{Frame 9.13}
...
\end{frame}
\subsection{Subsection 9.2}
\begin{frame}{Frame 9.21}
...
\end{frame}
\begin{frame}{Frame 9.22}
...
\end{frame}
\begin{frame}{Frame 9.23}
...
\end{frame}


\section{Section 10}
\begin{frame}{Frame 10}
...
\end{frame}

\section{Section 11}
\begin{frame}{Frame 11}
...
\end{frame}

\section{Section 12}
\begin{frame}{Frame 12}
...
\end{frame}

\section{Section 13}
\begin{frame}{Frame 13}
...
\end{frame}

\section{Section 14}
\begin{frame}{Frame 14}
...
\end{frame}

\section{Section 15}
\begin{frame}{Frame 15}
...
\end{frame}

\section{Section 16}
\subsection{Subsection 16.1}
\begin{frame}{Frame 16.11}
...
\end{frame}
\begin{frame}{Frame 16.12}
...
\end{frame}
\begin{frame}{Frame 16.13}
...
\end{frame}
\subsection{Subsection 16.2}
\begin{frame}{Frame 16.21}
...
\end{frame}
\begin{frame}{Frame 16.22}
...
\end{frame}
\begin{frame}{Frame 16.23}
...
\end{frame}

\section{Section 17}
\begin{frame}{Frame 17}
...
\end{frame}

\section{Section 18}
\begin{frame}{Frame 18}
...
\end{frame}

\section{Section 19}
\subsection{Subsection 19.1}
\begin{frame}{Frame 19.11}
...
\end{frame}
\begin{frame}{Frame 19.12}
...
\end{frame}
\begin{frame}{Frame 19.13}
...
\end{frame}
\subsection{Subsection 19.2}
\begin{frame}{Frame 19.21}
...
\end{frame}
\begin{frame}{Frame 19.22}
...
\end{frame}
\begin{frame}{Frame 19.23}
...
\end{frame}

\section{Section 20}
\begin{frame}{Frame 20}
...
\end{frame}

\end{document}
4
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Sep 4, 2016 at 18:07
  • It would be something similar to [tex.stackexchange.com/questions/205143/… but for Darmstadt theme. Any idea?
    – user113391
    Sep 5, 2016 at 12:18
  • The main difficulty is, that related answers such as tex.stackexchange.com/a/54956/36296 all deal with a fixed number. If you would say, you want to show current section +- 2 sections it would certainly be much easier. Sep 5, 2016 at 12:23
  • Thank you for your comment samcarter. I understand the problem. Current version +-2 sections means that 5 sections are always shown in the headline: it is a good option. If it were possible to do so with the Darmstadt theme, then it would solve my problem.
    – user113391
    Sep 5, 2016 at 14:14

1 Answer 1

2

The following will show the current section +-2 sections. If you want more or less sections to be displayed, change the value of \mymin=3 and \mymax=3 [and add corresponding exception for first, second, second to last and last section].

\documentclass{beamer}

\usetheme{Darmstadt}

% based on the original definitions in beamerbasenavigation.sty
\makeatletter
\def\sectionentry#1#2#3#4#5{% section number, section title, page
%
\newcount\mymin%
\mymin=3
\ifnum\c@section=1%
    \mymin=5
\fi%
\ifnum\c@section=2%
    \mymin=4
\fi%
%
\newcount\mymax%
\mymax=3
\ifnum\c@section=\beamer@sectionmax%
    \mymax=5
\fi%
\ifnum\c@section=\numexpr\beamer@sectionmax-1%
    \mymax=4
\fi%
%
    \ifnum\numexpr\c@section-#1<\mymax%
        \ifnum\numexpr#1-\c@section<\mymin%
            \ifnum#5=\c@part%
                \beamer@section@set@min@width
                \box\beamer@sectionbox\hskip1.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%
        \fi%
    \fi%
    \ignorespaces%
}

\def\slideentry#1#2#3#4#5#6{%
    %section number, subsection number, slide number, first/last frame, page number, part number
    %
    \newcount\mymin%
    \mymin=3
    \ifnum\c@section=1%
        \mymin=5
    \fi%
    \ifnum\c@section=2%
        \mymin=4
    \fi%
        %
    \newcount\mymax%
    \mymax=3
    \ifnum\c@section=\beamer@sectionmax%
        \mymax=5
    \fi%
    \ifnum\c@section=\numexpr\beamer@sectionmax-1%
        \mymax=4
    \fi%
    %
    \ifnum\numexpr\c@section-#1<\mymax%
        \ifnum\numexpr#1-\c@section<\mymin%
          \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%
                        \usebeamertemplate{mini frame}%\beamer@minislidehilight%
                      \else%
                        \usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
                      \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%
        \fi%
    \fi%
    \ignorespaces%
}
\makeatother


\begin{document}

\section{Section 1}
\subsection{Subsection 1.1}
\begin{frame}{Frame 1.11}
...
\end{frame}
\begin{frame}{Frame 1.12}
...
\end{frame}
\begin{frame}{Frame 1.13}
...
\end{frame}
\subsection{Subsection 1.2}
\begin{frame}{Frame 1.21}
...
\end{frame}
\begin{frame}{Frame 1.22}
...
\end{frame}
\begin{frame}{Frame 1.23}
...
\end{frame}

\section{Section 2}
\begin{frame}{Frame 2}
...
\end{frame}

\section{Section 3}
\begin{frame}{Frame 3}
...
\end{frame}

\section{Section 4}
\begin{frame}{Frame 4}
...
\end{frame}

\section{Section 5}
\begin{frame}{Frame 5}
...
\end{frame}

\section{Section 6}
\begin{frame}{Frame 6}
...
\end{frame}

\section{Section 7}
\begin{frame}{Frame 7}
...
\end{frame}

\section{Section 8}
\begin{frame}{Frame 8}
...
\end{frame}

\section{Section 9}
\subsection{Subsection 9.1}
\begin{frame}{Frame 9.11}
...
\end{frame}
\begin{frame}{Frame 9.12}
...
\end{frame}
\begin{frame}{Frame 9.13}
...
\end{frame}
\subsection{Subsection 9.2}
\begin{frame}{Frame 9.21}
...
\end{frame}
\begin{frame}{Frame 9.22}
...
\end{frame}
\begin{frame}{Frame 9.23}
...
\end{frame}


\section{Section 10}
\begin{frame}{Frame 10}
...
\end{frame}

\section{Section 11}
\begin{frame}{Frame 11}
...
\end{frame}

\section{Section 12}
\begin{frame}{Frame 12}
...
\end{frame}

\section{Section 13}
\begin{frame}{Frame 13}
...
\end{frame}

\section{Section 14}
\begin{frame}{Frame 14}
...
\end{frame}

\section{Section 15}
\begin{frame}{Frame 15}
...
\end{frame}

\section{Section 16}
\subsection{Subsection 16.1}
\begin{frame}{Frame 16.11}
...
\end{frame}
\begin{frame}{Frame 16.12}
...
\end{frame}
\begin{frame}{Frame 16.13}
...
\end{frame}
\subsection{Subsection 16.2}
\begin{frame}{Frame 16.21}
...
\end{frame}
\begin{frame}{Frame 16.22}
...
\end{frame}
\begin{frame}{Frame 16.23}
...
\end{frame}

\section{Section 17}
\begin{frame}{Frame 17}
...
\end{frame}

\section{Section 18}
\begin{frame}{Frame 18}
...
\end{frame}

\section{Section 19}
\subsection{Subsection 19.1}
\begin{frame}{Frame 19.11}
...
\end{frame}
\begin{frame}{Frame 19.12}
...
\end{frame}
\begin{frame}{Frame 19.13}
...
\end{frame}
\subsection{Subsection 19.2}
\begin{frame}{Frame 19.21}
...
\end{frame}
\begin{frame}{Frame 19.22}
...
\end{frame}
\begin{frame}{Frame 19.23}
...
\end{frame}

\section{Section 20}
\begin{frame}{Frame 20}
...
\end{frame}

\end{document}

enter image description here

5
  • Thank you, it looks very nice now! But the bullets for subsections do not appear correctly. It seems that all the bullets from the sections above the n+2 section are shown underneath the section n+2. Any idea why?
    – user113391
    Sep 6, 2016 at 7:42
  • @user113391 Can you update your example to show this problem? Sep 6, 2016 at 8:13
  • Ok, done. The problem can now be seen on almost every frame.
    – user113391
    Sep 6, 2016 at 8:55
  • @user113391 Thanks! Can you try my updated code? Sep 6, 2016 at 9:09
  • Perfect! I changed 1pt by 2.5pt in your code line 95 to have the first bullet and the S of Section aligned, but it was already nice as it was. Thank you very much!
    – user113391
    Sep 6, 2016 at 9:31

You must log in to answer this question.

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