Search code examples
latexbeamer

Beamer Slide header is not including subsubsection


I am using beamer to make my slides. I managed to have the subsections show in the header. For example subsection of Security is (1) Background (2) PerSpectron (3) Commercial ....

How can I add subsubsections in the header too? For example, I want to have several subsections to the background appear in an extra column in the header, similar to subsections. Is there any way to do this? Thank you.

enter image description here


Solution

  • First I'd like to quote the beamer users guide:

    "Do not use subsubsections, they are evil."

    If you want to torture your audience, you can use this quick hack. Make sure that:

    • you have more sections/subsections than subsubsections, otherwise the height might be wrong

    • you set the counter for the number of subsubsection in each subsection


    \documentclass{beamer}
    
    \usetheme{Warsaw}
    
    \usepackage{pgffor}
    
    \newcounter{totalsubsub}
    
    \AtBeginSubsubsection[]{\label{subsubsec:\thesection:\thesubsection:\thesubsubsection}}
    
    
    \makeatletter
    
    \setbeamertemplate{headline}{%
      \leavevmode%
      \@tempdimb=2.4375ex%
      \ifnum\beamer@subsectionmax<\beamer@sectionmax%
        \multiply\@tempdimb by\beamer@sectionmax%
      \else%
        \multiply\@tempdimb by\beamer@subsectionmax%
      \fi%
      \ifdim\@tempdimb>0pt%
        \advance\@tempdimb by 1.825ex%
        \begin{beamercolorbox}[wd=.33\paperwidth,ht=\@tempdimb]{section in head/foot}%
          \vbox to\@tempdimb{\vfil\insertsectionnavigation{.33\paperwidth}\vfil}%
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.34\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
          \vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.33\paperwidth}\vfil}%
        \end{beamercolorbox}%
        \begin{beamercolorbox}[leftskip=3.3ex,wd=.33\paperwidth,ht=\@tempdimb]{section in head/foot}%
        \begin{minipage}[b][\@tempdimb][c]{.9\linewidth}%
          \ifnum\thetotalsubsub>0
              \foreach \i in {1,...,\thetotalsubsub}{% 
                      \ifnum\i=\thesubsubsection
                          \usebeamercolor[fg]{subsubsection in sidebar}
                      \else
                          \usebeamercolor[fg]{subsubsection in sidebar shaded}
                      \fi
                      \hyperlink{subsubsec:\thesection:\thesubsection:\i}{\nameref{subsubsec:\thesection:\thesubsection:\i}}\par
                  }
          \fi
            \end{minipage}%
        \end{beamercolorbox}%    
      \fi%
    }
    
    \makeatother
    
    
    \begin{document}
    
    \section{section}
    \subsection{sub 1}
    \setcounter{totalsubsub}{3}
    
    \subsubsection{subsub 1}
    \begin{frame}
        subsub 1
    \end{frame} 
    
    \subsubsection{subsub 2}
    \begin{frame}
        subsub 2
    \end{frame} 
    
    \subsubsection{subsub 3}
    \begin{frame}
        subsub 3
    \end{frame} 
    
    \subsection{sub 2}
    \setcounter{totalsubsub}{0}
    
    \begin{frame}
        abc
    \end{frame} 
    
    \subsection{sub 3}
    \setcounter{totalsubsub}{2}
    
    \begin{frame}
    content...
    \end{frame}
    
    \subsubsection{subsub 1}
    \begin{frame}
        subsub 1
    \end{frame} 
    
    \subsubsection{subsub 2}
    \begin{frame}
        subsub 2
    \end{frame} 
    
    \end{document}
    

    enter image description here