3

This question already has an answer here:

Consider the following simple MWE:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \draw(0,0) -- (3,3);
  \pgfmathparse{2+1}
  \draw[red] (0,0) -- (3,\pgfmathresult);
\end{tikzpicture}
\end{document}

I expect to have, as an output, one red line, however this is the result that I get:

enter image description here

So, is it a bug, feature, or simply me doing something wrong?

marked as duplicate by jub0bs, Peter Jansson, Adam Liter, barbara beeton, Svend Tveskæg Mar 25 '14 at 16:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Doesn't the second one (in red) should hide the first one? – Dror Mar 25 '14 at 15:33
  • 3
    I don't know the details, but the value of \pgfmathresult changes at \draw[red]. Try \pgfmathsetmacro\temp{2+1}\draw[red] (0,0) -- (3,\temp); instead. – jub0bs Mar 25 '14 at 15:34
  • Thanks! Is this documented somewhere? I managed to miss it in the manual. – Dror Mar 25 '14 at 15:59
  • No problem. I searched for "pgfmathresult" in the manual, but didn't find a proper explanation. – jub0bs Mar 25 '14 at 16:10
  • @Jubobs: would you call it a bug? It is rather confusing... – Dror Mar 25 '14 at 19:20

Browse other questions tagged or ask your own question.