7

I would like to create a beamer containing a progress bar for a timer looking like this : enter image description here enter image description here enter image description here (these images are from powerpoint)

It's for my student, each slide is a question so I would like to be able to make a progress bar like above with a different timer on each slide.

I've tried to use the tikz and animate package but couldn't make something similar.

The best solution that I found is to use the tdclock package to make a chrono but it is impossible to countdown so we can't realy easily see how much time left.

Here is a compilable code :

\documentclass[french]{beamer}
\usepackage{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usetheme{Warsaw}
\usecolortheme{beaver}

\usepackage{tikz}
\usepackage[font=Times,timeinterval=1, timeduration=2,resetatpages=all]{tdclock}

\begin{document}
\initclock
\begin{frame}
\begin{tikzpicture}[remember picture, overlay,shift={(current page.south west)}] 
\draw (11.8,8) node{\boxed{{\Huge\cronoseconds}}} ;
\draw (12,7.2) node{/45s} ;
\end{tikzpicture}
 \end{frame}
\end{document}

enter image description here

Any help will be very apriciate. Thank you.


Edit for the answer of @samcarter enter image description here

1 Answer 1

10

The easiest way to produce shadings is pgf (or tikz). This can also be used to create a loop over n different iterations of the shading. Beamer can then be used to automatically show each slide for 1 second using \transduration{1} (this assumes your computer is infinitely fast and does not need any time to render the slides. You might have to replace 1 with a slightly smaller time.)

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

\begin{frame}

\transduration{1}

\foreach \x in {0,...,50}{\only<+>{

    \pgfdeclarehorizontalshading{myshade}{1em}{%
        color(0\textwidth)=(rgb:green,50;-green,\x;red,\x);
        color(\x*0.0175\textwidth)=(rgb:green,50;-green,\x;red,\x);     
        color(0.1\textwidth+\x*0.0175\textwidth)=(white);
      color(\textwidth)=(white)
    }
    \begin{pgfpicture}{0pt}{0pt}{\textwidth}{1em}
        \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\textwidth}{1em}}
    \pgfusepath{clip}
    \pgftext[left,base]{\pgfuseshading{myshade}}
    \pgftext[x=.9\textwidth,y=0.5em] {\x s / 50s}
  \end{pgfpicture}

}}

\end{frame}

\end{document}

enter image description here


Quick hack to move it at the top of the page:

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

\begin{frame}[t]

\transduration{1}
\foreach \x in {0,...,50}{\only<+>{

    \pgfdeclarehorizontalshading{myshade}{1em}{%
        color(0\paperwidth)=(rgb:green,50;-green,\x;red,\x);
        color(\x*0.0179\paperwidth)=(rgb:green,50;-green,\x;red,\x);  
        color(0.1\paperwidth+\x*0.0179\paperwidth)=(white);
      color(\paperwidth)=(white)
    }
    \begin{tikzpicture}[remember picture, overlay,xshift=-1cm,yshift=0.3cm]
        \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{1em}}
    \pgfusepath{clip}
    \pgftext[left,base]{\pgfuseshading{myshade}}
    \pgftext[x=.9\paperwidth,y=0.5em] {\x s / 50s}
  \end{tikzpicture}

}}

\end{frame}

\end{document}

enter image description here

6
  • This is amazing! Great work! Thank you very much. Unfortunatly I have an error message at this end of the timer :"This page content an error".
    – Zanzi
    Commented Dec 19, 2018 at 19:40
  • 1
    @Zanzi It compiles fine for me. Can you show your .log file? Commented Dec 19, 2018 at 19:41
  • It is not inside my tex editor that the error comes up but inside Adobe Reader, I make a screenshot but I can't share it inside the comment section so I will add it at the end of my post.
    – Zanzi
    Commented Dec 19, 2018 at 19:51
  • 2
    @Zanzi Ah, I guess I might know what is going on, some rounding error in adobe reader. Try my updated answer. Commented Dec 19, 2018 at 19:57
  • 1
    @Zanzi Please see my update Commented Dec 19, 2018 at 20:22

You must log in to answer this question.

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