How to draw a line passing through a point and parallel to another?
\draw (0,0) -- (1,0);
\node (A) at (1,1);
I need \draw (0,1) -- (1,1); parallel to first line.
How to draw a line passing through a point and parallel to another?
\draw (0,0) -- (1,0);
\node (A) at (1,1);
I need \draw (0,1) -- (1,1); parallel to first line.
You can use the calc library to calculate the vector between the first two points. By using the + path operator, you can draw a line from a third point in the direction of this vector:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1},
extended line/.style={shorten >=-#1,shorten <=-#1},
extended line/.default=1cm]
\node [dot=A] at (2,1) {};
\node [dot=B] at (3,2) {};
\node [dot=P] at (2,2) {};
\draw [extended line=0.5cm] (A) -- (B);
\draw [extended line=0.5cm] (P) -- +($(B)-(A)$);
\end{tikzpicture}
\end{document}

++instead of+. Is there any technical difference between both cases? – Diaa Apr 03 '17 at 03:42(1,0) +(1,0) +(0,1)specifies the three coordinates(1,0), then(2,0), and(1,1)." On the other hand, "(1,0) ++(1,0) ++(0,1)specifies the three coordinates(1,0), then(2,0), and(2,1)." (tikz documenation page 119) – jakun Apr 09 '17 at 06:32($(B)-(A)$); what is that for? thks. – mario Jun 10 '17 at 18:03($(B)-(A$)is a calculated coordinate,$..$is calculation mode in tikz, loaded bycalclibrary. In it you can perform basic coordinate calculations such as the one presented and some more daring too.($(B)-(A)$)is literaly(B)coordinate minus(A)coordinate, in geometry that gives the vector pointing fromAtoB, that's why the linePis drawn is parallel to(A)--(B). – Guilherme Zanotelli Nov 27 '18 at 16:52