In Dimensioning of a technical drawing in TikZ a very nice solution to mark lengths on a drawing has been given that uses pgfmath's capability. How do I omit having the decimal part of the number printed, eg: 25 instead of 25.0?
Asked
Active
Viewed 4,402 times
1 Answers
20
You can use the optional arguments of \pgfmathprintnumber to either cut off the decimal part or to round the number to an integer. Alternatively, you can use the \num macro from the siunitx package to round the number:
\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx}
\begin{document}
\pgfmathsetmacro\testnumber{25.7}
\pgfmathprintnumber{\testnumber}
\pgfmathprintnumber[int trunc]{\testnumber}
\pgfmathprintnumber[fixed,precision=0]{\testnumber}
\num{\testnumber}
\num[round-mode=figures]{\testnumber}
\end{document}

Jake
- 232,450
\pgfversionin your document; it should be at least v2.1. – Jake Jun 01 '11 at 10:59