119

Instead of slide numbers, I find it very nice to have something like a unobtrusive progressbar at the bottom which grows each slide about (width of screen)/(slide numbers).

I've found here (page in German) the following code snippet:

%%-----------------------------------------------------------------------
%% progress bar in footline
%% http://www.mrunix.de/forums/showpost.php?p=316577&postcount=3
%% -----------------------------------------------------------------------
\definecolor{lightgr}{rgb}{0.7 0.7 0.7}
\makeatletter
\addtobeamertemplate{footline}{%
  \color{lightgr}% to color the progressbar
  \hspace*{-\beamer@leftmargin}%
  \rule{\beamer@leftmargin}{2pt}%
  \rlap{\rule{\dimexpr
      \beamer@startpageofframe\dimexpr
      \beamer@rightmargin+\textwidth\relax/\beamer@endpageofdocument}{1pt}}
  % next 'empty' line is mandatory!

  \vspace{0\baselineskip}
  {}
}

It work fine in the beginning, but after I added a certain number of frames, suddenly it caused the following error message:

! Dimension too large.
<argument> ...amer@rightmargin +\textwidth \relax 
                                                  /\beamer@endpageofdocument 
l.517 \lyxframeend

It took me several hours to figure out that the progress bar caused the error message, because it is thrown only when I add certain images. But I couldn't figure out any system, when there is an error and when not. Sometimes it is possible to add new frames without problems, sometimes not. Sometimes when I use pdfpages to add a page the error occurs.

I use LyX (as you can see) and the Pittsburgh theme, but I suppose such a (running) progress bar snippet would be interesting for many users (also those with other themes and without LyX).

A screenshot of a frame to illustrate the result:

Screenshot

My Questions:

  • Is there a way to get this code more stable and compatible with any theme?
  • Would it be easy to turn this into an package?
  • How can I change the \beamer@startpageofframe to the real PDF page number? (Otherwise there are quite big and sudden jumps of the progressbar.)

(Please comment if I should provide more information, e.g. my whole LyX file.)

3
  • 1
    There is a beamer theme called metropolis (ctan.org/pkg/beamertheme-metropolis) which has progressbar in the section page overviews. Maybe this is helpful for you.
    – math
    Commented Apr 12, 2016 at 13:11
  • @math It can, ostensibly, be configured to go in the footer et al. too, via the progressbar=foot|head|frametitle|none package option. It doesn't seem to work for me, though.
    – OJFord
    Commented Jun 26, 2017 at 15:31
  • Ah, actually, it works fine - it's just quite narrow (when not projected) and I couldn't see it! (I missed the edit window.)
    – OJFord
    Commented Jun 26, 2017 at 15:39

7 Answers 7

114

Here you have some customizable progress bars (part of a project I am working on):

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\definecolor{pbblue}{HTML}{0A75A8}% filling color for the progress bar
\definecolor{pbgray}{HTML}{575757}% background color for the progress bar

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1.5ex

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}[rounded corners=2pt,very thin]

    \shade[top color=pbgray!20,bottom color=pbgray!20,middle color=pbgray!50]
      (0pt, 0pt) rectangle ++ (\progressbar@pbwd, \progressbar@pbht);

      \shade[draw=pbblue,top color=pbblue!50,bottom color=pbblue!50,middle color=pbblue] %
        (0pt, 0pt) rectangle ++ (\progressbar@tmpdim, \progressbar@pbht);

    \draw[color=normal text.fg!50]  
      (0pt, 0pt) rectangle (\progressbar@pbwd, \progressbar@pbht) 
        node[pos=0.5,color=normal text.fg] {\textnormal{%
             \pgfmathparse{\insertframenumber*100/\inserttotalframenumber}%
             \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,\%%
        }%
    };
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\end{document}

enter image description here

And a close-up image of the bar:

enter image description here

Two little variations; first using a circle as progress indicator:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\definecolor{pbblue}{HTML}{0A75A8}% color for the progress bar and the circle

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@rcircle % radius for the circle
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt
\progressbar@rcircle=2.5pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}
    \draw[pbblue!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);

    \filldraw[pbblue!30] %
      (\the\dimexpr\progressbar@tmpdim-\progressbar@rcircle\relax, .5\progressbar@pbht) circle (\progressbar@rcircle);

    \node[draw=pbblue!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbblue!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\end{document}

enter image description here

And the close-up:

enter image description here

And now using a triangle as progress-indicator (inspired by the theme Ignasi mentioned in his answer):

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\definecolor{pbgray}{HTML}{575757}% background color for the progress bar

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}[very thin]
    \draw[pbgray!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);
    \draw[draw=none]  (\progressbar@pbwd,0pt) -- ++ (2pt,0pt);

    \draw[fill=pbgray!30,draw=pbgray] %
       ( $ (\progressbar@tmpdim, \progressbar@pbht) + (0,1.5pt) $ ) -- ++(60:3pt) -- ++(180:3pt) ;

    \node[draw=pbgray!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbgray!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=5ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\begin{frame}
test
\end{frame}

\end{document}

enter image description here

And the close-up:

enter image description here

26
  • 1
    @lumbric yes, the project I mentioned in my answer includes a package containing the progress bar. The error message is not caused by my code, but by the framed package; apparently you ran out of lengths; you can try loading the etex package (\usepackage{etex}) right after \begin{document}. If the problem persists, then a follow-up question with a minimal version of the offending code would be the way to go. Commented Jun 13, 2012 at 21:06
  • 1
    @antmw1361 almost done! I'll let you know when it's finished. Commented Feb 11, 2013 at 14:03
  • 1
    @GonzaloMedina: Your theme with ball fails for me with more than 53 slides. It finishes with ! Arithmetic overflow. \progressbar@progressbar ...progressbar@tmpcounta \divide \progressbar@tmpdi...
    – Ignasi
    Commented Jul 29, 2013 at 9:35
  • 1
    @GonzaloMedina I personally tried the first progress bar, it seems to have an issue when the value of tmpcounta exceeds 44 slides. For tmpcounta=45 it does not compile anymore with the error: Arithmetic overflow. I am not sure why though...
    – Alain
    Commented Nov 7, 2014 at 21:51
  • 1
    @GonzaloMedina I created a post regarding this issue: tex.stackexchange.com/questions/211301/…
    – Alain
    Commented Nov 9, 2014 at 14:56
35

For ConTeXt, I have written a module visualcounter that allows one to visualize any ConTeXt counter. It provides a few predefined visualizers.

See the documentation for details. The basic usage is

\usemodule[visualcounter]


\definevisualcounter
  [pagevisualized] % visualizer
  [progressbar] % inherit from
  [counter=userpage]


\usevisualcounter{pagevisualizer}

where the first argument is the name of the visualizer that you want to define, the 2nd (optional) argument is the predefined visualizer from which you can inherit settings, and counter is the name of counter that the visualizer should display. See the tests/ subdirectory on github for detailed examples.

The image below shows four visualizers for page numbers and itemizations.

enter image description here

4
  • You are a wizard in context. By reading your answers I am tempted to learn it.
    – user11232
    Commented Jun 14, 2012 at 4:52
  • @HarishKumar: I am no wizard. Most of answers just describe the basic features of ConTeXt. Do give it a try.
    – Aditya
    Commented Jun 14, 2012 at 6:22
  • Can anyone help me with how to install this package?
    – ATOzTOA
    Commented Feb 14, 2018 at 18:14
  • This is for ConTeXt, not LaTeX.
    – Aditya
    Commented Feb 14, 2018 at 20:59
33

Sylvain Bouveret already developed a progressbar theme for beamer. You can find it in his web page. It's a 'complete' (inner, outer, color, font) theme but here you have a little example with just using \useoutertheme{progressbar}. Bootom triangle moves under the line according actual slide.

enter image description here

24

Some time ago I did a progress bar, so I changed it to be used in beamer via the \logo command. The bar overlaps with the navigation symbols, you might want to change it if it is an issue for you:

Code

\documentclass{beamer}
\usetheme{Darmstadt}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xifthen}

\makeatletter
    \newcommand{\Progressbar@LabelColor}{black}
    \newcommand{\Progressbar@LabelText}{Label}
    \newcommand{\Progressbar@LabelWidth}{5}
%   Farbe, Text, Breite des Labels

    \newcommand{\Progressbar@BarWidth}{10}
    \newcommand{\Progressbar@BarHeight}{1}
    \newcommand{\Progressbar@BarColor}{yellow}
    \newcommand{\Progressbar@BarBorder}{black}
%   Breite, Höhe, Schriftfarbe des Prozentsatzes, Rahmenfarbe des Fortschrittbalkens

    \newcommand{\Progressbar@TodoA}{gray}
    \newcommand{\Progressbar@TodoB}{black}
%   Farbe 1 und 2 für den unerledigten Teil 

    \newcommand{\Progressbar@DoneA}{red}
    \newcommand{\Progressbar@DoneB}{blue}
%   Farbe 1 und 2 für den erledigten Teil   

    \newcommand{\Progressbar@Direction}{LTR}
%   Modus links nach rechts oder umgekehrt; umgekehrt ist buggy (no support yet)    

    \newcommand{\Progressbar@Completion}{50}
%   Fertigstellung in Prozent   

    \define@key{Progressbar}{LabelColor}[\Progressbar@LabelColor]{\renewcommand{\Progressbar@LabelColor}{#1}}
    \define@key{Progressbar}{LabelText}[\Progressbar@LabelText]{\renewcommand{\Progressbar@LabelText}{#1}}
    \define@key{Progressbar}{LabelWidth}[\Progressbar@LabelWidth]{\renewcommand{\Progressbar@LabelWidth}{#1}}

    \define@key{Progressbar}{BarWidth}[\Progressbar@BarWidth]{\renewcommand{\Progressbar@BarWidth}{#1}}
    \define@key{Progressbar}{BarHeight}[\Progressbar@BarHeight]{\renewcommand{\Progressbar@BarHeight}{#1}}
    \define@key{Progressbar}{BarColor}[\Progressbar@BarColor]{\renewcommand{\Progressbar@BarColor}{#1}}

    \define@key{Progressbar}{BarBorder}[\Progressbar@BarBorder]{\renewcommand{\Progressbar@BarBorder}{#1}}
    \define@key{Progressbar}{TodoA}[\Progressbar@TodoA]{\renewcommand{\Progressbar@TodoA}{#1}}
    \define@key{Progressbar}{TodoB}[\Progressbar@TodoB]{\renewcommand{\Progressbar@TodoB}{#1}}

    \define@key{Progressbar}{DoneA}[\Progressbar@DoneA]{\renewcommand{\Progressbar@DoneA}{#1}}
    \define@key{Progressbar}{DoneB}[\Progressbar@DoneB]{\renewcommand{\Progressbar@DoneB}{#1}}
    \define@key{Progressbar}{Direction}[\Progressbar@Direction]{\renewcommand{\Progressbar@Direction}{#1}}

    \define@key{Progressbar}{Completion}[\Progressbar@Completion]{\renewcommand{\Progressbar@Completion}{#1}}

    \newcommand{\Progressbar}[1]%
    {   \setkeys{Progressbar}{#1}
        % Progress Bars --------------------------------------------------
        \begin{tikzpicture}[overlay, remember picture,shift={($(current page.south west)+(0.1,0.1)$)}]

            \ifthenelse{ \( \Progressbar@Completion = 0 \) \or \( \Progressbar@Completion = 100 \) }
                {   \newcommand{\TCA}{\Progressbar@TodoA}
                    \newcommand{\TCB}{\Progressbar@TodoB}
                    \newcommand{\DCA}{\Progressbar@DoneA}
                    \newcommand{\DCB}{\Progressbar@DoneB}
                }
                {   \newcommand{\TCA}{\Progressbar@TodoB !\Progressbar@Completion !\Progressbar@TodoA}
                    \newcommand{\TCB}{\Progressbar@TodoB}
                    \newcommand{\DCA}{\Progressbar@DoneA}
                    \newcommand{\DCB}{\Progressbar@DoneB !\Progressbar@Completion !\Progressbar@DoneA}
                }
            \ifthenelse{\equal{\Progressbar@Direction}{LTR}}
                {   \shade[left color=\DCA,right color=\DCB]%
                        (0,0) rectangle (\Progressbar@Completion * \Progressbar@BarWidth / 100,\Progressbar@BarHeight);
                    \shade[left color=\TCA,right color=\TCB]%
                        (\Progressbar@Completion * \Progressbar@BarWidth / 100,0)%
                        rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);
                }
                {   \shade[left color=\TCB,right color=\TCA]%
                        (0,0) rectangle (\Progressbar@Completion * \Progressbar@BarWidth / 100,\Progressbar@BarHeight);
                    \shade[left color=\DCB,right color=\DCA]%
                        (\Progressbar@Completion * \Progressbar@BarWidth / 100,0)%
                        rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);               
                }
            \draw (0,0) rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);
            \node[color=\Progressbar@BarColor] at%
                (\Progressbar@BarWidth / 10,\Progressbar@BarHeight / 2) {\Progressbar@Completion \%};
            \draw[color=white] (- \Progressbar@LabelWidth,0) -- %
                node[anchor=west,color=\Progressbar@LabelColor,text width=\Progressbar@LabelWidth]%
                {\Progressbar@LabelText} (- \Progressbar@LabelWidth,\Progressbar@BarHeight) ;
%               \typeout{todo c1 = \TCA}
%               \typeout{todo c2 = \TCB}
%               \typeout{done c1 = \DCA}
%               \typeout{done c2 = \DCB}
        \end{tikzpicture}
    }
\makeatother

\logo   {   \pgfmathsetmacro{\wid}{\the\paperwidth/28.45276-0.2}
                \pgfmathtruncatemacro{\prog}{100*\insertpagenumber/\insertdocumentendpage}
                \Progressbar{   LabelColor=yellow,%
                                            LabelText=,%
                                            LabelWidth=0,%
                                            BarWidth=\wid,%
                                            BarHeight=0.3,%
                                            BarColor=green,%
                                            BarBorder=black,%
                                            TodoA=orange!20!gray,%
                                            TodoB=orange!80!gray,%
                                            DoneA=blue!80!cyan,%
                                            DoneB=blue!20!cyan,%
                                            Completion=\prog%
                                        }
            }

\begin{document}

\begin{frame}
    \only<1>{Sha la la.}
    \only<2>{Shu bi du.}
    \only<3>{Tri Tra.}
    \only<4>{Trullala.}

    page - frame - totalpages : \insertpagenumber\ - \insertframenumber\ -  \insertdocumentendpage
\end{frame}

\begin{frame}
    \only<1>{One.}
    \only<2>{Zwei.}
    \only<3>{Tri.}
    \only<4>{Quattro.}
    \only<5>{Cinq.}
    \only<6>{Seis.}
    \only<7>{Siedem.}
    \only<8>{Kahdeksan.}

    page - frame - totalpages : \insertpagenumber\ - \insertframenumber\ -  \insertdocumentendpage
\end{frame}

\end{document}

Output

enter image description here


Edit 1

On popular demand by a single person, I reworked this as it was only "some kind of working". Instead of doing complicated computations with colors now I just use clipping. RTL progression of the bar now works, furthermore you can influence the position of the percentage label.

Code

\documentclass{beamer}
\usetheme{Darmstadt}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xifthen}

\makeatletter
    \newcommand{\Progressbar@BarWidth}{10}
    \newcommand{\Progressbar@BarHeight}{1}
    \newcommand{\Progressbar@BarColor}{yellow}
    \newcommand{\Progressbar@BarBorder}{black}
    \newcommand{\Progressbar@BarPosition}{10}
%   Breite, Höhe, Schriftfarbe des Prozentsatzes, Rahmenfarbe, Bechriftungsposition des Fortschrittbalkens

    \newcommand{\Progressbar@TodoA}{gray}
    \newcommand{\Progressbar@TodoB}{black}
%   Farbe 1 und 2 für den unerledigten Teil 

    \newcommand{\Progressbar@DoneA}{red}
    \newcommand{\Progressbar@DoneB}{blue}
%   Farbe 1 und 2 für den erledigten Teil   

    \newcommand{\Progressbar@Direction}{LTR}
%   Modus links nach rechts oder umgekehrt; umgekehrt ist buggy (no support yet)

    \newcommand{\Progressbar@Completion}{50}
%   Fertigstellung in Prozent   

    \define@key{Progressbar}{BarWidth}[\Progressbar@BarWidth]{\renewcommand{\Progressbar@BarWidth}{#1}}
    \define@key{Progressbar}{BarHeight}[\Progressbar@BarHeight]{\renewcommand{\Progressbar@BarHeight}{#1}}
    \define@key{Progressbar}{BarColor}[\Progressbar@BarColor]{\renewcommand{\Progressbar@BarColor}{#1}}

    \define@key{Progressbar}{BarBorder}[\Progressbar@BarBorder]{\renewcommand{\Progressbar@BarBorder}{#1}}
    \define@key{Progressbar}{BarPosition}[\Progressbar@BarPosition]{\renewcommand{\Progressbar@BarPosition}{#1}}    
    \define@key{Progressbar}{TodoA}[\Progressbar@TodoA]{\renewcommand{\Progressbar@TodoA}{#1}}

    \define@key{Progressbar}{TodoB}[\Progressbar@TodoB]{\renewcommand{\Progressbar@TodoB}{#1}}
    \define@key{Progressbar}{DoneA}[\Progressbar@DoneA]{\renewcommand{\Progressbar@DoneA}{#1}}
    \define@key{Progressbar}{DoneB}[\Progressbar@DoneB]{\renewcommand{\Progressbar@DoneB}{#1}}

    \define@key{Progressbar}{Direction}[\Progressbar@Direction]{\renewcommand{\Progressbar@Direction}{#1}}
    \define@key{Progressbar}{Completion}[\Progressbar@Completion]{\renewcommand{\Progressbar@Completion}{#1}}

    \newcommand{\Progressbar}[1]%
    {   \setkeys{Progressbar}{#1}
        % Progress Bars --------------------------------------------------
        \begin{tikzpicture}[overlay, remember picture,shift={($(current page.south west)+(0.1,0.1)$)}]
            \draw[draw=\Progressbar@BarBorder,ultra thick] (0,0) rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);          
            \ifthenelse{\equal{\Progressbar@Direction}{LTR}}
                {   \shade[left color=\Progressbar@TodoA,right color=\Progressbar@TodoB]%
                        (0,0)   rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);
                    \begin{scope}
                        \clip   (0,0) rectangle (\Progressbar@Completion * \Progressbar@BarWidth / 100,\Progressbar@BarHeight);
                        \shade[left color=\Progressbar@DoneA,right color=\Progressbar@DoneB]%
                            (0,0) rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);
                    \end{scope}
                }
                {   \shade[left color=\Progressbar@TodoB,right color=\Progressbar@TodoA]%
                        (0,0) rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);
                    \begin{scope}
                        \clip   ({(100-\Progressbar@Completion) * \Progressbar@BarWidth / 100},0)%
                            rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);
                        \shade[left color=\Progressbar@DoneB,right color=\Progressbar@DoneA]%
                            (0,0)   rectangle (\Progressbar@BarWidth,\Progressbar@BarHeight);               
                    \end{scope}
                }
            \node[color=\Progressbar@BarColor] at%
                (\Progressbar@BarWidth / 100 * \Progressbar@BarPosition,\Progressbar@BarHeight / 2) {\Progressbar@Completion \%};
        \end{tikzpicture}
    }
\makeatother

\logo   {   \pgfmathsetmacro{\wid}{\the\paperwidth/28.45276-0.2}
                \pgfmathtruncatemacro{\prog}{100*\insertpagenumber/\insertdocumentendpage}
                \pgfmathtruncatemacro{\mybarpos}{104-\prog}
                \Progressbar{   BarWidth=\wid,%
                                            BarHeight=0.3,%
                                            BarColor=green,%
                                            BarBorder=none,%
                                            BarPosition=\mybarpos,%
                                            TodoA=orange!20!gray,%
                                            TodoB=orange!80!gray,%
                                            DoneA=blue!80!cyan,%
                                            DoneB=blue!20!cyan,%
                                            Completion=\prog,%
                                            Direction=RTL,%
                                        }
            }

\begin{document}

\begin{frame}
    \only<1>{Sha la la.}
    \only<2>{Shu bi du.}
    \only<3>{Tri Tra.}
    \only<4>{Trullala.}

    page - frame - totalpages : \insertpagenumber\ - \insertframenumber\ -  \insertdocumentendpage
\end{frame}

\begin{frame}
    \only<1>{One.}
    \only<2>{Zwei.}
    \only<3>{Tri.}
    \only<4>{Quattro.}
    \only<5>{Cinq.}
    \only<6>{Seis.}
    \only<7>{Siedem.}
    \only<8>{Kahdeksan.}

    page - frame - totalpages : \insertpagenumber\ - \insertframenumber\ -  \insertdocumentendpage
\end{frame}

\end{document}

Output

enter image description here

5
  • What is the use of the \ifthenelse conditional at the beginning of the TikZ picture?
    – Herr K.
    Commented Oct 26, 2013 at 23:40
  • It's been a while since I wrote this, and I'm not so sure this is needed. Did you try replacing the conditional with just the false statement, e.g. \newcommand{\TCA}{\Progressbar@TodoB !\Progressbar@Completion !\Progressbar@TodoA} \newcommand{\TCB}{\Progressbar@TodoB} \newcommand{\DCA}{\Progressbar@DoneA} \newcommand{\DCB}{\Progressbar@DoneB !\Progressbar@Completion !\Progressbar@DoneA}? Commented Oct 26, 2013 at 23:51
  • It would seem that only the false part of the conditional matters. But I'm getting some erratic behavior when I change the Todo and Done colors; the transition of colors is not working, and I don't know why...
    – Herr K.
    Commented Oct 26, 2013 at 23:59
  • 2
    @KevinC: Please see my update, now it should work ;D Commented Oct 27, 2013 at 3:10
  • Thanks! Clipping is a very clever way indeed! And \colorlet is also more robust in dealing with the colors than \newcommand. With regard to the old method, I also managed to get a "smooth" color transition by setting TCA and DCR equal to DoneB!\Progressbar@Completion!TodoA. Anyway, this is an excellent implementation of progress bar :)
    – Herr K.
    Commented Oct 27, 2013 at 5:18
15

My implementation gives you a both navigation and progress bar: you could jump to any frame by clicking some navigation box.

Beamer Theme Mathz

First save the following codes as beamerouterthemeprogress.sty file:

\makeatletter

\AtBeginSection[]{\frame{\sectionpage}}
\AtBeginSubsection[]{\frame{\subsectionpage}}

\newcommand{\my@bigsize}{9}
\newcommand{\my@medsize}{7}
\newcommand{\my@smallsize}{5}

\newlength{\my@tempsize}

\newcounter{my@sectnum}

\newcommand{\my@lastdigit}[1]{%
  \loop\ifnum\value{#1}>9\addtocounter{#1}{-10}\repeat
  \arabic{#1}%
}

\newcommand\my@fixedbox[2]{%
  \makebox[#1]{\rule[-1ex]{0pt}{3.25ex}#2}%
}

\newcommand\my@colorbox[3]{%
  {\setlength{\fboxsep}{0pt}\colorbox{#1}{\my@fixedbox{#2}{#3}}}%
}

\def\my@temptext{}

\newcommand{\my@navbox}[1][]{%
  \if\relax\detokenize{#1}\relax
    \def\my@tempbox{\my@fixedbox}%
  \else
    \def\my@tempbox{\my@colorbox{#1}}%
  \fi
  \ifx\my@box\my@bigbox
    \def\my@temptext{\my@lastdigit{my@sectnum}}%
  \fi
  \ifx\my@box\my@medbox
    \def\my@temptext{$\diamond$}%
  \fi
  \ifx\my@box\my@smallbox
    \def\my@temptext{$-$}%
  \fi
  \my@tempbox{\my@tempsize}{\my@temptext}%
}

\defbeamertemplate{navigation box}{home}{%
  \setlength{\my@tempsize}{\my@box@size pt}%
  \my@colorbox{teal!60}{\my@tempsize}{$\equiv$}%
}

\defbeamertemplate{navigation box}{done}{%
  \setlength{\my@tempsize}{\my@box@size pt}%
  \my@navbox[teal!60]%
}

\defbeamertemplate{navigation box}{todo}{%
  \setlength{\my@tempsize}{\my@box@size pt}%
  \my@navbox
}

\newcommand{\my@bigbox}{\global\let\my@box@size=\my@bigsize\usebeamertemplate{navigation box}}
\newcommand{\my@medbox}{\global\let\my@box@size=\my@medsize\usebeamertemplate{navigation box}}
\newcommand{\my@smallbox}{\global\let\my@box@size=\my@smallsize\usebeamertemplate{navigation box}}

\renewcommand{\sectionentry}[5]{\global\let\my@box=\my@bigbox\setcounter{my@sectnum}{#1}}
\renewcommand{\beamer@subsectionentry}[5]{\global\let\my@box=\my@medbox}

\renewcommand{\slideentry}[6]{%
  \def\my@temp@i{1/1}%
  \def\my@temp@ii{#4}%
  \ifx\my@temp@i\my@temp@ii % title page
    \setbeamertemplate{navigation box}[home]%
  \else
    \setbeamertemplate{navigation box}[done]%
  \fi
  \ifnum\c@section<#1%
    \setbeamertemplate{navigation box}[todo]%
  \else
    \ifnum\c@section=#1\ifnum\c@subsection<#2%
      \setbeamertemplate{navigation box}[todo]%
    \else
      \ifnum\c@subsection=#2\ifnum\c@subsectionslide<#3%
        \setbeamertemplate{navigation box}[todo]%
      \fi\fi
    \fi\fi
  \fi
  \ifx\my@temp@i\my@temp@ii % title page
    \beamer@link(#4){\my@bigbox}%
  \else
    \beamer@link(#4){\my@box}%
  \fi
  \global\let\my@box=\my@smallbox
}

\defbeamertemplate{footline}{progress}
{%
  {\color{teal}\hrule}\hbox{%
  \begin{beamercolorbox}[wd=.8\paperwidth,ht=2.25ex,dp=1ex,left]{footline}%
    \kern2em\dohead
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,right]{footline}%
    \insertframenumber{}/\inserttotalframenumber\kern2em
  \end{beamercolorbox}%
  }%
}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[progress]

\makeatother

Then you could create a beamer file for testing this outer theme (put it in the same folder as beamerouterthemeprogress.sty file):

\documentclass{beamer}

\useoutertheme{progress}
\setbeamercolor{background canvas}{bg=lightgray}

\begin{document}

\title{Beamer Theme Math}
\author{Author Name}

\begin{frame}
\titlepage
\end{frame}

\section{Name One}

\subsection{Subname One}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\subsection{Subname Two}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\subsection{Subname Three}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\section{Name Two}

\subsection{Subname One}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\subsection{Subname Two}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\subsection{Subname Three}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\section{Name Three}

\subsection{Subname One}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\subsection{Subname Two}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\subsection{Subname Three}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\begin{frame}{Frame Title}
Frame \insertframenumber
\end{frame}

\end{document}
5
  • I notice one problem. The document must have at least one subsection to compile properly.
    – hola
    Commented Jul 16, 2017 at 15:40
  • 1
    @pushpen.paul Fixed. Please try it again.
    – L.J.R.
    Commented Jul 24, 2017 at 12:49
  • one mild inconvenience (matter of taste) I observed is that the progress bar includes the appendix. background: I normally use appendixnumberbeamer to only the main body count for the total number of frames. otherwise one might scare off listeners at the start when they see a page count that's inflated by backup material.
    – pseyfert
    Commented May 20, 2019 at 11:53
  • 1
    report one problem: when presenting too many pages the bar will be truncated, better to set the total length propotional to paperwidth Commented Mar 10, 2020 at 21:18
  • Hi @L.J.R., this is quite an old post, but I really liked your solution to this problem. Do you know of a way to make your progress bar work with other themes? Which part of the code would I need for that? I already like my current theme and don't want to change it except for adding your progress bar. Thank you!
    – lazulikid
    Commented May 19, 2020 at 22:04
12

Here a simple footline template

\setbeamercolor{progress bar progress}{use=progress bar,bg=progress bar.fg}
\defbeamertemplate{footline}{progress bar}{
  \dimen0=\paperwidth
  \multiply\dimen0 by \insertframenumber
  \divide\dimen0 by \inserttotalframenumber
  \edef\progressbarwidth{\the\dimen0}

  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.75ex,dp=1ex]{progress bar}
    \begin{beamercolorbox}[wd=\progressbarwidth,ht=1.75ex,dp=1ex]{progress bar progress}
    \end{beamercolorbox}%
  \end{beamercolorbox}%
}

which can then be used as follows

\setbeamertemplate{footline}[progress bar]
\setbeamercolor{progress bar}{fg=blue!50!black,bg=white!50!black}

Result

5
  • 1
    You might want to get the \newdimen out of the definition as it would define everytime it is executed.
    – percusse
    Commented May 18, 2015 at 22:43
  • Thanks for the suggestion! After reading about what \newdimen does I decided to remove it and use a scratch register instead.
    – Friedrich
    Commented May 19, 2015 at 0:19
  • +1 For simplicity. Thank you.
    – 01es
    Commented Oct 2, 2019 at 22:29
  • @Friedrich Can we add Page numbers in this bar too simultaneously?
    – ShJ
    Commented Jul 10, 2020 at 7:11
  • Sure, I have used this before: gist.github.com/friedrich/538ed40acb9a1c7582470e01387fc867
    – Friedrich
    Commented Jul 12, 2020 at 16:16
6

This is a very short "answer", but it fits the purpose:

There is a very "unobtrusive progressbar" included in the metropolis beamer theme. The progressbar is a liiiittle bit too unobtrusive for my taste, but I haven't found out how to make it thicker, yet.

Usage example:

\documentclass{beamer}

%The used theme. Options: No page number, progress bar at the bottom
\usetheme[numbering=none,progressbar=foot]{metropolis}

Addendum: To adapt the thickness ("width", for the initiated), I use

\makeatletter
    \setlength{\metropolis@progressinheadfoot@linewidth}{1pt}
\makeatother

from an answer by samcarter, in which samcarter also explains how to work with the other progressbars (section pages and such) in the metropolis theme.

You must log in to answer this question.

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