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.

I'm having trouble passing an argument to \pgfmathparse inside a macro I defined. Here is the code:




    \draw (0,0) -- (\endpt,0);


I must confess, I'm quite clueless why I get the error:

Incomplete \iffalse; all text was ignored after line 14
share|improve this question
This is all to do with expansion. As well as Peter's answer, you might want to look for example at tex.stackexchange.com/questions/7811/… –  Joseph Wright Nov 17 '11 at 21:40
I guess I really need to sit down and study a bit this expandability thing... It keep s popping up, but I don't really get it - yet! :) –  Count Zero Nov 18 '11 at 14:44
add comment

2 Answers

up vote 13 down vote accepted

In the \draw command in your version \endpt is expanded to \pgfmathparse{#1+#2}\pgfmathresult. So you get

\draw (0,0) -- (\pgfmathparse{#1+#2}\pgfmathresult,0);

which greatly confuses TikZ.

Instead you should set \endpt to the result of the calculation, either via


as Peter suggested or equivalently via


Alternatively for this MWE you can of course simply do

    \draw (0,0) -- ({#1+#2},0);
share|improve this answer
I like this answer because it took me one year of using TikZ before I figured out how to use arbitrary math in coordinates. The manual never says! –  Ryan Reich Nov 17 '11 at 23:02
add comment

Simply use pgfmathsetmacro as in:

share|improve this answer
@CountZero: Or \pgfmathparse{#1+#2}\let\endpt\pgfmathresult, which however is basically the same. The \enpt must be expandable, and \pgfmathparse isn't, so it can't be part of the macro. –  Martin Scharrer Nov 17 '11 at 21:47
add comment

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.