5

In the following example, I have drawn a couple of arrows in TikZ that are overlapping at one end.

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \foreach \x in {1,...,10}
    \draw[->] (0,0) -- (\x,0);
\end{tikzpicture}

\end{document}

enter image description here

Since the arrows are drawn separately, TikZ lays them on top of each other making them look thicker than normal. Is there any way to tell TikZ to not thicken lines/borders that are superimposed? Of course, I am looking for a general solution to this problem, not a quick fix for the simple example above.

Ali
  • 1,824
  • 3
    Did you try zooming in and out? It's a PDF viewer related anti-aliasing problem. See also http://tex.stackexchange.com/questions/49614/tikz-borders-showing-through-when-they-shouldnt-overlapping-circles – percusse Jun 23 '12 at 01:15
  • So, it wouldn't look like this if I print the document? – Ali Jun 23 '12 at 01:21
  • Drawing a line on top of itself will only make the line appear thicker if there is a slight offset. In this case, I don't see any offset and since the arrows are not redrawn on top not sure why you would think that the lines could get thicker? – Peter Grill Jun 23 '12 at 01:21
  • @peter: The leftmost arrow clearly looks thicker to me than the rightmost one. Is that an illusion?! – Ali Jun 23 '12 at 01:25
  • @Ali: Opening it in Acrobat and zooming in to 1600%, the last arrow look the same as the one before. – Peter Grill Jun 23 '12 at 02:00
  • @PeterGrill: Interesting. I usually use Okular in Ubuntu. It appears that in Acrobat Reader all arrows are looking the same, but if I use [rotate{45}] option inside tikzpicture and recompile, even in Acrobat, again the lower arrows look thicker than the upper ones. Does that look so to you as well? – Ali Jun 23 '12 at 02:27
  • Even with the rotate=45, the arrows look the same in Acrobat Reader 10.1.3 on Mac once you zoom in. – Peter Grill Jun 23 '12 at 03:20
  • Thanks @PeterGrill. It probably has something to do with linux, then. Weird... – Ali Jun 23 '12 at 03:27
  • @Ali: In defense of "Linux" (whose problem this really is not), I have found that if you zoom in 400% (the max) in Okular, all questionable graphical artifacts are resolved. This kind of thing happens a lot with precise graphics. – Ryan Reich Jun 23 '12 at 04:41
  • @RyanReich: True. I did not mean to bash Linux in any ways in my previous comment. In fact, I am a big fan of it and that is exactly why I am using it. However, for some reason (may be related to my graphics driver?!), I do not get the correct picture even with 400% zoom. – Ali Jun 23 '12 at 05:42

1 Answers1

4

This is the same effect as in Branching lines in TikZ without antialiasing/subpixel artifact? (and some others, I think). If you are concerned how it looks like on screen, you could try to sidestep the issue. For example (plain-format):

\input tikz
\tikz \foreach \x in {1,...,10} \draw[->] (\x,0) -- ++(1,0);
\bye

enter image description here

morbusg
  • 25,490
  • 4
  • 81
  • 162
  • Thanks, @morbusg. This works, indeed. However, it is not always this easy to avoid overlapping lines. In more complicated structures, it is a real headache to segment lines in series, e.g. having lots of shapes with common borders, etc. Anyways, I would not be much concerned about this as long as the printout looks pretty. – Ali Jun 23 '12 at 20:12
  • @Ali: Oh, man, I'm sorry; I missed your questions last sentence. I think I remember once seeing a mailing list conversation regarding this effect, but can't for the life of me find it or remember what was the outcome. Maybe there is some program which could “optimize” the resulting PDF by removing the overlapping lines somehow. – morbusg Jun 24 '12 at 07:16
  • Sure. As far as I realized from comments, this is apparently a problem related to how the document is rendered and the results vary from system to system. Therefore, I do not believe if there exists any general remedy for it. Again, thanks for your kind input. – Ali Jun 24 '12 at 08:47