Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have already defined 2 nodes crect and celli, and I would like to draw a line from crect to the point on the right of celli, it seems that the following does not work:

\draw[->] (crect) -- [right=1cm of celli];

So do I have to declare explicitly that point by \node? Does anyone have a solution to make it work in one line?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

You could use the calc library and its syntax for coordinate calculations.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
  \node (A) at (1,1) {A};
  \node (B) at (3,1) {B};
  \draw (A) -- ($(B) + (1cm,0)$);
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

You can also [x|y]shift your desired coordinates. No need of calc library in this case.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \node (A) at (1,1) {A};
  \node (B) at (3,1) {B};
  \draw[red] (A) -- ([xshift=1cm]B.center);
  \draw[green] (A) -- ([yshift=1cm]B.center);
  \draw[blue] (A) -- ([shift={(1cm,1cm)}]B.center);
\end{tikzpicture}
\end{document}

You need to use B.center (or any other node's coordinate) and not just its name. Note also the brackets envolving parenthesis in shift.

share|improve this answer
add comment

Your Answer

 
discard

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.