I try to use the results of pgfmath
calculations with cnttest
from xifthen
, but it fails:
\documentclass{article}
\usepackage{pgf,xifthen}
\begin{document}
\pgfmathparse{42+77}%
\def\val{\pgfmathprintnumber{\pgfmathresult}}
\ifthenelse{\cnttest{\val}{>=}{50}}{%
Large
}{%
Small
}%
\end{document}
pdflatex
(TexLive 2012) produces in the log:
./test.tex:7: Missing number, treated as zero.
<to be read again>
\protect
l.7 \ifthenelse{\cnttest{\val}{>=}{50}}
{%
And in the document (yes, the message leaves the page):
I suspect it's an expansion problem -- something I seem to be unable to wrap my head around. I know that using \pgfmathprintnumber{\pgfmathresult}
directly (instead of val
does not help. Can I fix this somehow?
\pgfmathtruncatemacro\val{42+77}%
to directly save the integer part of the operation result into your\val
macro. Then everything works as expected.\pgfmathparse
necessary? If you're dealing with integers,\numexpr
is way handier.