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.

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

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.

share|improve this question
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. – Martin Scharrer Apr 18 '11 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. – Dmitry Volosnykh Apr 18 '11 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 '11 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. – Dmitry Volosnykh Apr 18 '11 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. – Martin Scharrer Apr 18 '11 at 15:44
up vote 1 down vote accepted

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.

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.