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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From How to draw a line passing through a point and perpendicular to another? I learned to use shorten to extend lines. But the extended part doesn't seem to "really exist". For example, I would like to connect two predefined dots and extend the line segment by 1cm and then define the new end as "C" for later use. But \draw[shorten >=-1cm] (A) -- (B) coordinate (C) will only give me a C which is actually still B.

What I really need to do is to find the intersection of two extended lines, but I think the tough part is to make the extended lines "real".

share|improve this question
up vote 15 down vote accepted

You're right, the shorten > syntax doesn't "actually" extend the line, but works on a lower level. In your case, I would use \usetikzlibrary{calc}, which gives you access to a lot of nifty coordinate calculations.

Your desired result could be achieved with the syntax

\draw (A) -- ($(B)!-1cm!(A)$) coordinate (C);

where the ($...$) encloses the calc syntax, and the (<first node>)!<distance>!(<second node>) specifies the coordinate that lies at <distance> along the line from <first node> to <second node>.

\fill (0,0) circle [radius=2pt] node (A) [label=A] {};
\fill (2,1) circle [radius=2pt] node (B) [label=B] {};
\fill (3.2,1) circle [radius=2pt] node (C) [label=C] {};
\fill (4,0.5) circle [radius=2pt] node (D) [label=D] {};
\draw [name path=AB] (A) -- ($(B)!-1cm!(A)$);
\draw [name path=CD] (D) -- ($(C)!-1cm!(D)$);

\fill [red,name intersections={of={AB and CD}}] (intersection-1) circle [radius=2pt];
share|improve this answer
thanks a lot. that's "actually" helpful! :) – Ting Sep 25 '11 at 3:16

If you use tkz-euclide (documentation only in French, though), this is much easier:




\tkzDefPoint(0,0){A} \tkzDefPoint(2,1){B}
\tkzDefPoint(3.2,1){C} \tkzDefPoint(4,0.5){D}

\tkzInterLL(A,B)(C,D) \tkzGetPoint{I}
\tkzDrawLines(A,I D,I)
\tkzDrawPoints[color=blue](A,B,C,D) \tkzDrawPoint[color=red](I)


You could also write a piece of code to check the coordinates and automate the choice points for the \tkzDrawLines command and then use arbitrary coordinates, if you need, but I was too lazy to do it. :)

share|improve this answer

Consider this a side-answer to the original question, since the solution is provided using pstricks.

pstricks-add provides this point of intersection by means of the macro \psIntersectionPoint(<P0>)(<P1>)(<P2>)(<P3>){<node name>} where P0 and P1 define one straight line (say 0-1) and P2 and P3 define another straight line (say 2-3). <node name> is the name of the saved node at the intersection of 0-1 and 2-3. The following example is taken directly from the pstricks-add package documentation:

\usepackage{pstricks-add}% http://ctan.org/pkg/pstricks-add}

Intersection between two lines in 2D using PStricks

share|improve this answer

Your Answer


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.