4

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

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

Edit

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

    \newcommand*{\AddNote}[4]{%
    \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};
    \end{tikzpicture}%
    }
Matthias
  • 1,729
  • 1
    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

1 Answers1

8

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

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\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 %
}
\begin{document}
\addLine{1}\addLine{1}
\end{document}
Scott H.
  • 11,047