Thursday, December 3, 2009

How to generate a tart/clock shaped progress meter for latex-beamer

Update: Here is a rewrite of the previously published version. This new version is a bit more elegant and uses the pgfmath package for computations. So, to have a tart diagram inform your listeners about the progress made in your presentation, include the following TeX code into the preamble of your document. It will redefine the current frametitle template so that after the frame title the tart will appear. I've only tested this in the absence of any other templates, so it might not work straight out of the box for your setup. Feel free to modify this, though.

\usepackage{pgfmath}
\usepackage{tikz,ifthen}%


%% frametitle with tart-like progress meter
\setbeamertemplate{frametitle}{%
  \vskip-2pt%
  \begin{beamercolorbox}[rightskip=2cm,leftskip=1em,dp=1ex,wd=12.8cm]{frametitle}%
    \vskip2pt%
    \usebeamercolor{frametitle}%
    \begin{tikzpicture}[scale=1]% 
      \useasboundingbox (0,0) rectangle (0,0); %(-1,-1) rectangle (1,1);%
      \ifthenelse{\insertframenumber<\inserttotalframenumber}{%
        %% uncomplete tart          
        \pgfmathsetmacro{\aimangle}{90-(\insertframenumber*360/\inserttotalframenumber)}
        \fill [fill=frametitle.fg,thin] (11.8,.1) -- (11.8,0.4) arc
        (90:\aimangle:0.3) -- cycle;%
      }{
        %% the full tart
        \fill[fill=frametitle.fg,thin] (11.8,.1) circle (.3);%
      }%
    \end{tikzpicture}
    \insertframetitle%
    \vskip2pt%
  \end{beamercolorbox}% 
}

Documentation on the commands used here can be found in your local pgfuserguide.pdf and ifthen.pdf which should come with any recent TeX distribution.

0 comments:

Post a Comment

Comments are moderated to prevent abuse and may not be made public immediately.


Björn Rüffer, Copyright 20092011
Disclaimer: The author of this page cannot accept any responsibility for content of pages that this page provides hyperlinks to. Also the author cannot accept responsibility or liability for any damage caused by following or not following instructions given on this page. This page, its contents and style, are the responsibility of the author and do not represent the views, policies or opinions of any other party. The author will not be held responsible for comments posted by third parties on this site. Inappropriate comments will be removed. There is no warranty for any program or source code provided here, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the program “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction.