Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
\newcommand{\navradius}{0.25ex}
\setbeamertemplate{footline}{
    \tikz\draw[text height=2*\navradius,inner sep=0ex,rounded corners=\navradius]
        node[fill=navbg,minimum width=\textwidth-\navradius](back){} (back.west)
        node[fill=navfg,minimum width=(\insertframenumber-1)/(\inserttotalframenumber-1)*(\textwidth-\navradius),right]{}
        (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.
<to be read again> 
                   \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?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

If TikZ doesn't want to evaluate some expression correctly, you can often help it by surrounding the expression with braces. In your case,

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

works correctly.

share|improve this answer
    
While that does make the errors disappear, it unfortunately also makes the navigation bar disappear. –  Daniel Wagner Jul 20 '12 at 1:06
    
It works for me. Maybe you could add a complete MWE. –  Caramdir Jul 20 '12 at 1:07
    
Whoops, you're right, this works perfectly. My PDF viewer was just cutting off the bottom of each page during the test. –  Daniel Wagner Jul 20 '12 at 1:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.