I am using beamer for a presentation, and I would like to include a progress bar, in the top part of the slide. I would like it to be something similar to the one which apperas here: (Beamer: How to add progress bar with section titles?). However, I need that not only the section title, but also the current subsection title appers on it. It would be perfect, if the subsection title can appear below its section name.

Someone can help me? Thanks in advance,

1 Answer 1


Here is a first attempt to add the current subsection. The only problem are jumps when the subsection contains letters like p, q and y (e.g. change from slide 2 to 3). Maybe an anchor problem, but I do not know how to fix it.

Code: I have added a comment for each addition or change. I hope I have not forgotten anything.

% To provide total amount of sections throughout the document
% Registers de total amount of sections (see https://tex.stackexchange.com/a/192506/141947)
% To be able to refer to sections when needed
% Redefinition of the \section command so that each one is labeled \label{sec:n} where n is its index 


% Definition of custom colors based on the initial figure of the bar by the OP

% Definition of custom tikz styles in order to ease readability
    % Bar style (Argument : color)
        % Filling with one color as a preaction, in order to avoid reset by the pattern color
        % Application of the line pattern on to of the fill
        pattern={Lines[angle=45,distance={6pt},line width=3pt]},pattern color=#1
    % Node style (Arguments : color, section number)
    sectionnode/.style 2 args={
        % Display of the section name below the cicle
        label={[text=#1,align=center]below:\nameref{sec:#2}\\~},% CHANGED
    % ADDED: Node style (Arguments : color, section number, subsection number)
    sectionnodeWithSubsection/.style n args={3}{
        % Display of the section name and the subsection name below the cicle
        label={[text=#1,align=center]below:\nameref{sec:#2}\\-- \nameref{subsec:#2-#3} --},

% Actual definition of the colorbar based on Gonzalo Medina's initial proposal
    \def\pbar@progressbar{} % the progress bar
    \newcount\pbar@tmpcnta% auxiliary counter
    \newcount\pbar@tmpcntb% auxiliary counter
    \newdimen\pbar@pbht %progressbar height
    \newdimen\pbar@pbwd %progressbar width
    \newdimen\pbar@tmpdim % auxiliary dimension

% The progress bar
    \pbar@tmpcnta=\value{section} % tmpcnta stores the section number
    \pbar@tmpcntb=\totvalue{section} % tmbcountb sotres the total amount of sections
    \advance\pbar@tmpcntb by 1 % tmbcountb is advanced by 1 in order to have the last bar segment after the last node

    \begin{tikzpicture}[very thin]
        % Clipping scope to avoid tests for the bar dimensions
        % Clipping path
        \path[rounded corners=2pt,clip] (0pt,{-\pbar@pbht/2}) rectangle (\pbar@pbwd,{\pbar@pbht/2});
        % Gray bar (from 0 to last section)
        \path[sectionbar=mygray] (0pt,{-\pbar@pbht/2}) rectangle (\linewidth,{\pbar@pbht/2});
        % Blue bar (from 0 to the current section)
        \path[sectionbar=myblue] (0pt,{-\pbar@pbht/2}) rectangle ({(\[email protected])*\linewidth/\pbar@tmpcntb},{\pbar@pbht/2});
        % Green bar (from current to next section)
        \path[sectionbar=mygreen] ({(\[email protected])*\linewidth/\pbar@tmpcntb},{-\pbar@pbht/2}) rectangle ({(\pbar@tmpcnta+0.5)*\linewidth/\pbar@tmpcntb},{\pbar@pbht/2});
        % Drawing of the nodes on top of the bars, based on the number of the current section
        \foreach \secnumber in {1,...,\totvalue{section}}{
            % Number is lower, section is past, blue color
                \node[sectionnode={myblue}{\secnumber}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};
            % Number is equal, section is current, green color
                % CHANGED:
                % if we have a current subsection, show current subsection
                    \node[sectionnodeWithSubsection={mygreen}{\secnumber}{\thesubsection}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};
                    \node[sectionnode={mygreen}{\secnumber}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};
            % Number is larger, to be done section, gray color
            \node[sectionnode={mygray}{\secnumber}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};

  \begin{beamercolorbox}[wd=\paperwidth,ht=13ex,center,dp=1ex]{white}% CHANGED: value of ht










\subsection{Results 1}
    \frametitle{Results 1}

\subsection{Results 2}
    \frametitle{Results 2}




Beamer: Progress bar with sections and subsections.

  • 1
    OMG! You are my new hero! Thanks so much for your help, that is exactly what I was looking for! :)
    – Michael
    Commented Jun 5, 2022 at 8:50

You must log in to answer this question.

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