TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

Every time I'm using this macro it shifts to the right. Why?

    \begin{tikzpicture}[overlay, remember picture]
        \coordinate (x) at (#1,0);
        \draw [open triangle 45-] (0,0) -- (x);


Well, I adapted my real macro (I just provided a smaller example for the sake of demonstration), but I still have a little gap:

    \begin{tikzpicture}[overlay, remember picture]%
                \coordinate (x) at (#2,0);
                \coordinate (a) at ($(x)!(#1.north)!($(x)+(0,1)$)$);
                \coordinate (b) at ($(a)+(0.5,0)$);
                \coordinate (c) at ($(b)+(0,#3)$);
                \draw [open triangle 45-] (a) -- (b) -- (c);
                \node[right] at (c) {\bf\sffamily\smaller#4};
share|improve this question
Try \newcommand*{addLine}[1]{% and \end{tikzpicture}%. I'm not sure what packages are required to get your example to compile, so I can't test. Possibly also a % after remember picture]% – Scott H. Dec 10 '12 at 19:31
up vote 8 down vote accepted

Your macro is introducing spurious spaces. See Why the end-of-line % in macro definitions

With comment chars:

enter image description here

Without comment chars:

enter image description here

\newcommand*{\addLine}[1]{% <--- a space is introduced without this %
    \begin{tikzpicture}[overlay, remember picture]
        \coordinate (x) at (#1,0);
        \draw [open triangle 45-] (0,0) -- (x);
    \end{tikzpicture}% <--- a space is introduced without this %
share|improve this answer
I always wondered what's the matter of this :D – Matthias Dec 10 '12 at 19:55
Now you know! They're easy enough to miss, see for example, tex.stackexchange.com/a/86265/14100 – Scott H. Dec 10 '12 at 19:59
Hi Scott: I think there's another problem. Please have a look on my edits. – Matthias Dec 10 '12 at 20:04
I'm super-flashed: I put a % to the end of the macro usage. Now the gap is gone... Is this the correct approach? – Matthias Dec 10 '12 at 20:11
Yes, I believe you are having the same issue in document. – Scott H. Dec 10 '12 at 20:14

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.