When scaling tikzpicture using option scale, some points that had equal coordinates appear to be shifted a little bit. So the precise comparision \ifdim \y1 = \y2 will not do anymore.

I'm aware of \pgfmathapproxequalto, but the problem is that dimensions are not plain numbers.

  • I was not aware of \pgfmathapproxequalto, but know that using dimensions instead of plain numbers is not a problem with the \pgfmath... macros. You can simply use it with dimensions: \pgfmathapproxequalto{1pt}{1pt} or even mixed: \pgfmathapproxequalto{1pt}{1}. Did you tried that and got an error? It works OK in my little tests. Apr 18, 2011 at 6:55
  • @Martin: Yes, you are right, it seems to work. I messed up with \the macro (\the\y1), which led me to errors. This problem is the consequence of this topic (tex.stackexchange.com/questions/15107/…). When scaling, I get the same artifacts, even when I check the points to be on horizontal or vertical line. Apr 18, 2011 at 7:29
  • @Dmitry: You should put your edit into an answer instead and then accept it so that this question won't appear unanswered.
    – TH.
    Apr 18, 2011 at 9:42
  • @TH: Yeah, you are right, and I will do that shortly. There's restriction for me (being quite a new user) to self-answer only after 24 hours. Thanks, anyway. Apr 18, 2011 at 15:37
  • The 24 hours accept-your-own-answer is active for all users, not just the new ones. And with 120rep you should be free of all new-user restrictions relevant for posting. Apr 18, 2011 at 15:44

1 Answer 1


The problem was that \pgfmathapproxequalto uses fixed precision of 0.0001, but in my case scaling was so distorting that finally I had to set precision to 0.01. So, the solution was to use \pgfmathparse{abs(\y1 - \y2) <= 0.01}.

By the way, I have to call this macro from inside of pgfextra, because this condition is used to alter path construction on the fly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .