Maybe the question is not minimal enough - if so, please tell me.
I do not know what is the correct title since I do not understand the connection of the different packages.
Related
This question is somehow a follow up of
and also includes
Introduction
The basic idea is, that I calculate the progress (in percent) of a beamer presentation using
100*\insertframenumber/\inserttotalframenumber
I added a min(progress in percent,100) around that all because in the first run the \inserttotalframenumber is 1 and I do not want the progress to exceed 100.
At the moment I do not know which LaTeX package is responsible that I can use the
minfunction here.
So it actually looks like
min((100*\insertframenumber/\inserttotalframenumber),100)
This fails if there is an appendix because I do not want that the appendix slides to be taken into account.
If there is an appendix then this approach
min((100*\insertframenumber/(\beamer@startpageofappendix-1))
works. The key is \beamer@startpageofappendix. But it fails if there is no appendix because then \beamer@startpageofappendix-1 is -1 (minus one).
Main Question
I thought that it would help if there was a check if
\beamer@startpageofappendixis zero in the code. Depending on the result, approach a) (\inserttotalframenumber) or b) (\beamer@startpageofappendix-1) will be used.
Code
\documentclass[t]{beamer}
\usepackage{tikz}
\usepackage{calc}
\usepackage{xparse}
\ExplSyntaxOn
\int_new:N \l_beamer_percentage_int
\prop_new:N \g_beamer_percentage_prop
\makeatletter
\NewDocumentCommand{\myProgressPercent}{}{%
\int_set:Nn \l_beamer_percentage_int {
\fp_to_int:n {
\fp_eval:n {min((100*\insertframenumber/(\beamer@startpageofappendix-1)),100)}
%\fp_eval:n {min((100*\insertframenumber/\inserttotalframenumber),100)}
}
}
\prop_gput:NnV \g_beamer_percentage_prop {percentage} { \l_beamer_percentage_int }
\prop_item:Nn \g_beamer_percentage_prop {percentage}
}
\makeatother
\ExplSyntaxOff
\begin{document}
\foreach \n in {1,...,10}{
%------------------
\begin{frame}
\frametitle{Slide \n}
Progress is \myProgressPercent\,\%
\end{frame}
%------------------
}
% comment \appendix in and out to see the effect
\appendix
\foreach \n in {1,...,3}{
%------------------
\begin{frame}
\frametitle{Appendix Slide \n}
Progress is \myProgressPercent\,\% (Should always be 100\,\%)
\end{frame}
%------------------
}
\end{document}
It wokred!
Thanks all - here's illustration of what I am trying to achieve.


\fp_compare. – Henri Menke Jan 07 '17 at 15:36