TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code:

\foreach \i [evaluate=\i as \ii using \i+5] in {1,2,3,4} {
    \node at (\i,0) {\ii};

I like to print 6 7 8 9, but the above code prints 6.0 7.0 8.0 9.0. How can I control the precision in the evaluate statement?

share|improve this question
up vote 7 down vote accepted

You can use the \pgfmathprintnumber{\ii} instead of \ii. See Section 66 in the PGF/TikZ manual for more information about the syntax.

share|improve this answer
You could also say evaluate=\i as \ii using int(\i+5), then \ii will hold just the integer part. – Jake Mar 4 '12 at 9:19
@Jake That's even better! Thanks. – percusse Mar 4 '12 at 23:58

You can use the numprint package, and say:


An alternative is the number printing facility of the siunitx package. You have the \num macro, usable as follows:

\sisetup{round-mode = places}% in preamble    
share|improve this answer

Your Answer


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.