2
\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[help lines] grid (4,3);
\coordinate (X) at (3,3);
\draw[red ,thick,xshift=-10] (1,1 -|   X) -- (2,2 -|   X);
\draw[blue,thick,xshift=-10] (1,1 -| 3,3) -- (2,2 -| 3,3);
\end{tikzpicture}
\end{document} 

出力

xshift=-10座標を名前で指定した場合は効果がないようです。何故ですか?

4

1 に答える 1

1

the answer lies in that X is defined outside the scope of the xshift=-10 transformation - see here for details as well as possibly here -, i.e. the node X is defined and has a fixed position before the beginning of the scope of the transformation which then is only applied to nodes newly defined within the scope.

an example may clarify things: extending the scope to include the definition of X shows the expected behavior with only one line:

\documentclass{article}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw[help lines] grid (4,3);
      \begin{scope}[xshift=-10]
        \coordinate (X) at (3,3);
        \draw[red ,thick] (1,1 -|   X) -- (2,2 -|   X);
        \draw[blue,thick] (1,1 -| 3,3) -- (2,2 -| 3,3);
      \end{scope}
  \end{tikzpicture}
\end{document}

produces:

expected output - single line

于 2014-08-05T22:37:28.847 に答える