21

is there a simple idiom (one not using the calc library) to specify a Tikz coordinate relative to a node?

Something like \coordinate (x) [right=of A]; instead of \node (x) [draw=none, right=of A]{};?

Thanks

  • 1
    Where do you want the coordinate to end up? Nodes come equipped with a whole slew of anchors, would one of them do? (A.east) seems a reasonable one in this case. – Loop Space May 24 '12 at 19:06
  • 4
    \coordinate[right=of A] (x) ; is fine but not \coordinate (x) [right=of A]; – Alain Matthes May 24 '12 at 19:10
  • 1
    @AndrewStacey The advantage of doing [right=of A] instead of (A.east), as you suggest, is that I can change the node distance and have the coordinate repositioned, or I can say directly things like [right=30mm of A]. Also a coordinate has no space, that's why I had to put [draw=none ... above. – Mário May 24 '12 at 21:48
17
\documentclass{article} 
\usepackage {tikz}
\usetikzlibrary{positioning}

\begin{document} 

  \begin{tikzpicture}
    \node (A){A};
    \coordinate  (x) [right=of A]; 
    \coordinate[right=of A]  (y) ;
    \draw (x) -- ++(1,1);
    \draw[red] (y) -- ++(1,1); 
  \end{tikzpicture}

\end{document} 

enter image description here

remark the problem is similar with

  \node  (x) {} [right= of A]; 
  instead of   \node[right= of A]  (x) {} ;
  but \node (x) [right= of A]  {} ; is valable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.