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.

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.

share|improve this question

1 Answer 1

up vote 18 down vote accepted

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}

parallel lines with TikZ

share|improve this answer
    
thanks Jake.... –  Regis da Silva May 29 '11 at 21:17

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.