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

In the following example I want to use \ifnum to compare two numbers computed by pgfmath, for simplicity I use simply 1 and 2 in the example below. Compiling this code gives me the error:

    ERROR: Missing = inserted for \ifnum.

--- TeX said ---
<to be read again> 
l.11    \ifnum \one
--- HELP ---
From the .log file...

I was expecting to see `<', `=', or `>'. Didn't.

The example is:



   \ifnum \one<\two
   \draw (0,0) -- (0,1);

Any idea how to solve this?

share|improve this question
up vote 19 down vote accepted

\ifnum compares integers. The results stored by \pgfmathsetmacro always contain a decimal part, even for integer numbers, so you'll have to use \pgfmathtruncatemacro in this case:


   \draw (0,0) -- (0,1);
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.