I want to indicate the progress of a beamer
presentation using external pictures.
Let's say we are at slide 24 out of 200 slides then I want to display a picture called
12.png
(24/200 = 12 %) on the current slide.
I am already able to manage to calculate the percentage of the progress but I can't use \pgfmathresult (\pgfmathprintnumber[precision=0]{\pgfmathresult}
, which in my MWE gives the progress percentage of the current slide) as part of a file name (error ! Missing \endcsname inserted.
).
I use the calc
library of tikz/pgf
to do the calculations.
In the MWE I input an external tex
file in order to emulate inserting a picture.
\documentclass{beamer}
\usepackage{filecontents}
\begin{filecontents}{33.tex}
File with name \texttt{33.tex}.
\end{filecontents}
\begin{filecontents}{67.tex}
File with name \texttt{67.tex}.
\end{filecontents}
\begin{filecontents}{100.tex}
File with name \texttt{100.tex}.
\end{filecontents}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
%% Start of Frame
\begin{frame}
\frametitle{Frame Title}
%
\begin{description}
\item[Current Frame Number] \insertframenumber
\item[Total Frame Number] \inserttotalframenumber
\item[Progress in Percent]
\pgfmathparse{min((100*\insertframenumber/\inserttotalframenumber),100)}
\pgfmathprintnumber[precision=0]{\pgfmathresult}\,\%
\end{description}
%
\input{33.tex}
\end{frame}
%% Start of Frame
\begin{frame}
\frametitle{Frame Title}
%
\begin{description}
\item[Current Frame Number] \insertframenumber
\item[Total Frame Number] \inserttotalframenumber
\item[Progress in Percent]
\pgfmathparse{min((100*\insertframenumber/\inserttotalframenumber),100)}
\pgfmathprintnumber[precision=0]{\pgfmathresult}\,\%
\end{description}
%
\input{67.tex}
\end{frame}
%% Start of Frame
\begin{frame}
\frametitle{Frame Title}
%
\begin{description}
\item[Current Frame Number] \insertframenumber
\item[Total Frame Number] \inserttotalframenumber
\item[Progress in Percent]
\pgfmathparse{min((100*\insertframenumber/\inserttotalframenumber),100)}
\pgfmathprintnumber[precision=0]{\pgfmathresult}\,\%
\end{description}
%
\input{100.tex}
\end{frame}
\end{document}
When you first compile the document then
\inserttotalframenumber
is 1 (One). So if you are on slide 3 (Three) then the current progress percentage is 300 (slide 3 out of 1). Therefore I use themin
function to restrict the result of the calculation to be 100 at maximum.
Related
pgfmath...
calculations? – user31729 Jan 4 '17 at 19:59\pgfmathresult
does not survive the group, that's the point – user31729 Jan 4 '17 at 20:09