# \coordinate intersection does not work appropriately in TikZ [closed]

I was trying to use TikZ to sketch some graph but something weird happened. I was trying to use "intersection" to get the coordinate of the intersection of two lines, but strangely, there is always one point that cannot get the correct coordinate.

The following is the TikZ code I wrote, and as the output shows, the coordinate for the point (By) is wrong. I changed the order in which I define the four points Bx, By, Dx, Dy, and find that it is always the first of these four gets the coordinate messed up.

I suspect this might be caused by putting labels on the first four points (CC, CD, DC, DD), but I have no idea how to correct this.

I am new to TikZ, so any help is greatly appreciated!

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}%[plain]
\begin{tikzpicture}
\coordinate [label=right:{$(r-1,r-1)$}] (CC) at (2,2);
\coordinate [label=left:{$(-1,r)$}] (CD) at (-1,3);
\coordinate [label=right:{$(r,-1)$}] (DC) at (3,-1);
\coordinate [label=225:{$(0,0)$}] (DD) at (0,0);

\coordinate (By) at (intersection of (0,-1)--(0,4) and CD--CC);
\coordinate (Dx) at (intersection of (-1,0)--(4,0) and CD--DC);
\coordinate (Dy) at (intersection of (0,-1)--(0,4) and CD--DC);
\coordinate (Bx) at (intersection of (-1,0)--(4,0) and DC--CC);

\fill (Bx) circle (2pt);
\fill (By) circle (2pt);
\fill (Dx) circle (2pt);
\fill (Dy) circle (2pt);

\draw [thick] (-1,0) -- (4,0) node [below] {$u_1$};
\draw [thick] (0,-1) -- (0,4) node [left] {$u_2$};
\draw [thick] (DD) -- (CD) -- (CC) -- (DC) -- cycle;
\draw [dashed]  (CD) --  (DC);
\draw [thick]  (CC) --  (DD);
\draw [thick]  (Dx) --  (Dy);
\end{tikzpicture}
\end{frame}
\end{document}


• Welcome to TeX.SE. If you move the lines \coordinate (By) thru \fill (Dy) to be after those lines are actually drawn things seem to work. Of course the \draw [thick] (Dx) -- (Dy); will still need to be after the (Dx) and (Dy) coordinates are computed. Sep 25, 2014 at 16:15
• Thanks for your reply, Peter. That does solve the problem. But I don't understand. The coordinate of the intersection should not matter be the lines drawn or not, right? I mean, even if I don't draw the lines, I should still get the correct coordinates. Am I missing something here? Sep 25, 2014 at 23:18
• I agree that it should not matter, and don't know why there is problem with the way that you did it. That was why I did not post an answer but provided you with a workaround to get you going. Whenever I have done intersections I have always used named paths so have not encountered this before myself. Sep 25, 2014 at 23:50
• Where have you read about this syntax of intersections ? When I search the documentation for (intersection of I can't find it. There is the intersections library, but it doesn't work like this.
– Kpym
Dec 17, 2014 at 7:11
• I'm voting to close this question as off-topic because it is about a very old version of the TikZ package involved. Feb 7, 2015 at 21:33