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.)

lumbric
  • 4,269
  • 1
    There is a beamer theme called metropolis (https://www.ctan.org/pkg/beamertheme-metropolis) which has progressbar in the section page overviews. Maybe this is helpful for you. – math Apr 12 '16 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 Jun 26 '17 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 Jun 26 '17 at 15:39

7 Answers7

113

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

Gonzalo Medina
  • 505,128
  • Looks great! Would be a really great package, if it is highly customizeably! Unfortunately I get an error, I pasted it here: http://pastebin.com/yb79iMUF – lumbric Jun 13 '12 at 21:00
  • 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. – Gonzalo Medina Jun 13 '12 at 21:06
  • Nice work @GonzaloMedina: When it will be available as a package? Please notify to us also here in this site. –  Jun 14 '12 at 04:52
  • @GonzaloMedina: Is it correct that your code is missing \makeatother? If this is the case, where should it be added? Otherwise, this looks great!!!1 Thanks! – Dror Jun 14 '12 at 07:33
  • @GonzaloMedina Perhaps you could put this into the appropriate format for inclusion in beamer as a theme file? – Joseph Wright Jun 14 '12 at 07:36
  • @GonzaloMedina Wow great, thanks! etex solved the problem. I managed to adopt your code to my needs, it works great! Thanks! – lumbric Jun 14 '12 at 07:44
  • @GonzaloMedina: My last frame uses allowframebreaks and goes over two "pages". This confuses your code: The first of this page shows the 100% and a filled bar, the second shows 105% and the bar got an extension. – Ulrike Fischer Jun 14 '12 at 07:55
  • @HarishKumar I still have lots of work to do, but as soon as it's ready I'll let you know. – Gonzalo Medina Jun 14 '12 at 19:47
  • @Dror you're right; I initially forgot \makeatother; I've added it. Thanks for your kind words. – Gonzalo Medina Jun 14 '12 at 19:47
  • @JosephWright the prject bar is part of a bigger project, but I like your idea :-) I'll let you know when the theme is ready. – Gonzalo Medina Jun 14 '12 at 19:49
  • @lumbric You're welcome! I am glad you liked the progress bar. – Gonzalo Medina Jun 14 '12 at 19:49
  • @UlrikeFischer could you please give me a little example of code showing the problem? After reading your comment, I did some tests with allowframebreaks, but I wasn't able to reproduce the odd behaviour you mentioned. – Gonzalo Medina Jun 14 '12 at 19:51
  • @GonzaloMedina Looks as if allowframebreaks alone is not the problem. My last frame actually uses [allowframebreaks,t]. You can test the behaviour with your example if you use this options and \lipsum[1-4] in one frame. (And naturally load lipsum) – Ulrike Fischer Jun 15 '12 at 07:49
  • @UlrikeFischer Now I am really intrigued; I can't reproduce the problem using [allowframebreaks,t] either... Should we perhaps continue this discussion in a chat room? – Gonzalo Medina Jun 15 '12 at 16:50
  • @GonzaloMedina: If I have one frame consisting of 50 slides and another consisting of only one, then the progress bar will always be the same for 50 slides. Wouldnt it be better to use \insertpagenumber and \insertdocumentendpage for your tmpcounta and tmpcountb ? – Tom Bombadil Jun 23 '12 at 12:53
  • @GonzaloMedina: I was wondering if you are finished with your progress bar package or not? – antmw1361 Feb 08 '13 at 13:35
  • 1
    @antmw1361 almost done! I'll let you know when it's finished. – Gonzalo Medina Feb 11 '13 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 Jul 29 '13 at 09:35
  • @Ignasi I'll do some tests to see if I can reproduce the problem, and I'll let you know the results. – Gonzalo Medina Aug 12 '13 at 13:30
  • 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 Nov 07 '14 at 21:51
  • @Alain Hard to tell without some actual code. Please compose a MWE illustrating the problem and open a follow-up question. – Gonzalo Medina Nov 08 '14 at 16:02
  • @GonzaloMedina indeed, I will do this. I did not provide a MWE in the comments as I thought it may be a known issue. – Alain Nov 09 '14 at 14:32
  • 1
    @GonzaloMedina I created a post regarding this issue: http://tex.stackexchange.com/questions/211301/slide-number-limit-when-using-a-progress-bar – Alain Nov 09 '14 at 14:56
  • @GonzaloMedina: This is awesome, thank you! Would it be possible to add the section headings into the bar? So the section heading will be highlighted when arriving there during presentation? – Dave Aug 10 '19 at 17:37
  • @GonzaloMedina: Excuse me, I have sent you the wrong URL. This is the right one: https://tex.stackexchange.com/questions/503702/beamer-how-to-add-progress-bar-with-section-titles – Dave Aug 11 '19 at 09:02
  • Works well and looks nice. I'd like to use this in a beamer presentation in which I externalize the TikZ figures with \usetikzlibrary{external}. Unfortuantely, the progress bar marker doesn't work anymore when figures are externalized, do you have any pointers on that? – Habi Dec 05 '19 at 13:10
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

Aditya
  • 62,301
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

Ignasi
  • 136,588
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

Tom Bombadil
  • 40,123
  • What is the use of the \ifthenelse conditional at the beginning of the TikZ picture? – Herr K. Oct 26 '13 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}? – Tom Bombadil Oct 26 '13 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. Oct 26 '13 at 23:59
  • 2
    @KevinC: Please see my update, now it should work ;D – Tom Bombadil Oct 27 '13 at 03: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. Oct 27 '13 at 05: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}
L.J.R.
  • 10,932
  • I notice one problem. The document must have at least one subsection to compile properly. – hola Jul 16 '17 at 15:40
  • 1
    @pushpen.paul Fixed. Please try it again. – L.J.R. Jul 24 '17 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 May 20 '19 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 – John Paul Qiang Chen Mar 10 '20 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 May 19 '20 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

Friedrich
  • 221
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.

thymaro
  • 1,507