# Why can't I use max() here?

When I make presentations (with beamer), I like to have a bar along the bottom showing progress through the presentation visually. The interesting bit of the code below is the division on the node[fill=navfg,...] line:

\usebeamercolor{palette primary}
\colorlet{navfg}{fg!80!white}
\colorlet{navbg}{fg!40!white}
\setbeamertemplate{footline}{
(back.south) node[below]{}
;
}


This works great, except during the first attempt to build a presentation using this snippet. During the first build, \inserttotalframenumber has the value 1, so this makes a division by zero. The obvious fix is to use max:

node[fill=navfg,minimum width=(\insertframenumber-1)/max(1,\inserttotalframenumber-1)*(\textwidth-\navradius),right]{}


But this results in an error:

! Missing \endcsname inserted.
\textwidth
l.10 \begin{document}

!  ==> Fatal error occurred, no output PDF file produced!


Why do I get this error? What can I do to solve this problem correctly?

-

node[fill=navfg,minimum width={(\insertframenumber-1)/max(1,inserttotalframenumber-1)*(\textwidth-\navradius)},right]{}