質問: ? \progressbar@tmpcountb=\inserttotalframenumber \progressbar@tmpdim=\progressbar@pbwd \multiply\progressbar@tmpdim by \progressbar@tmpcounta \divide\progressbar@tmpdim by \progressbar@tmpcountb \begin{tikzpicture}[rounded corners=1.5pt,very thin] \shade[top color=blue!20,bottom color=blue!20,middle color=blue!50] (0pt, 0pt) rectangle ++ (\progressbar@pbwd, \progressbar@pbht); \shade[draw=red,top color=red!50,bottom color=red!50,middle color=red] % (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{% }% }; \end{tikzpicture}% } \addtobeamertemplate{headline}{} {% \begin{beamercolorbox}[wd=\paperwidth,ht=1.5ex,center,dp=0ex]{white}% \progressbar@progressbar% \end{beamercolorbox}% } \makeatother % \begin{document} \frame[t]{ \frametitle{slide} \small{ } } \frame[t]{ \frametitle{slide} \small{ } } \end{document} ``` I only left here two slides for the sake of clarity but when more than 44 slides are used, the arithmetic overflow error kicks in... and I don't know why. A few things I have been thinking about: could it be related with the definition of the graphic increment from a slide to another ? Would 1/45 be some kind of lower bound here... ? But I don't know why... Because the total number of frame seems to be the cause of the problem, I tried to add the following lines in the definition of the progress bar: ``` \multiply\progressbar@tmpcounta by 44 \divide\progressbar@tmpcounta by \progressbar@tmpcountb ``` in order to somehow normalize all values with respect to the maximum number of slides I found acceptable but it did not work.
回答: You can scale the arithmetic to keep within bounds, halving then doubling, I tested this with 67 pages. ``` \documentclass[10pt,fleqn]{beamer} \mode \usepackage{tikz} % PROGRESS BAR \usetikzlibrary{calc} \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=\paperwidth \progressbar@pbht=0.5ex % the progress bar \def\progressbar@progressbar{% \progressbar@tmpcounta= \insertframenumber % max = ? \progressbar@tmpcountb=\inserttotalframenumber \progressbar@tmpdim=.5\progressbar@pbwd \multiply\progressbar@tmpdim by \progressbar@tmpcounta \divide\progressbar@tmpdim by \progressbar@tmpcountb \progressbar@tmpdim=2\progressbar@tmpdim \begin{tikzpicture}[rounded corners=1.5pt,very thin] \shade[top color=blue!20,bottom color=blue!20,middle color=blue!50] (0pt, 0pt) rectangle ++ (\progressbar@pbwd, \progressbar@pbht); \shade[draw=red,top color=red!50,bottom color=red!50,middle color=red] % (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{% }% }; \end{tikzpicture}% } \addtobeamertemplate{headline}{} {% \begin{beamercolorbox}[wd=\paperwidth,ht=1.5ex,center,dp=0ex]{white}% \progressbar@progressbar% \end{beamercolorbox}% } \makeatother % \begin{document} \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \frame[t]{ \frametitle{slide} \small } \end{document} ```