Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 Qustions:

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

share|improve this question

4 Answers

up vote 48 down vote accepted

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

share|improve this answer
Wow, this is great! – Werner Jun 13 '12 at 20:13
@Werner thanks! – Gonzalo Medina Jun 13 '12 at 20:39
Looks great! Would be a really great package, if it is highly customizeably! Unfortunately I get an error, I pasted it here: pastebin.com/yb79iMUF – lumbric Jun 13 '12 at 21:00
@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
1  
@antmw1361 almost done! I'll let you know when it's finished. – Gonzalo Medina Feb 11 at 14:03
show 14 more comments

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

Right now, this is still a work in progress, so there is no documentation. 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

share|improve this answer
You are a wizard in context. By reading your answers I am tempted to learn it. – Harish Kumar Jun 14 '12 at 4:52
@HarishKumar: I am no wizard. Most of answers just describe the basic features of ConTeXt. Do give it a try. – Aditya Jun 14 '12 at 6:22

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

share|improve this answer

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:

\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}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.