# Code for drawing two intersecting lines and the acute angle between them

Here is the code for two intersecting lines. I know the code that I use to draw lines $\ell$ and $k$ is bad. I am sure that is the reason that the labels $\ell$ and $k$ are not in the right places. I want $\ell$ to be to the above and left of upper arrowhead and $k$ to be to the right and below the right arrowhead. (Line $\ell$ is the more upright line.)

Point $P$ should be at the intersection of the two lines. It is not. Point $A$ should be on $\ell$ and point $B$ should be on $k$. They are not. $\angle APB$ should be marked with an arc. The arc is not centered at $P$. The line segments $\overline{AP}$, $\overline{BP}$, and $\overline{AQ}$ should be labeled with $r$, $x$, and $y$, respectively, in the middle of arrows. The arrows are all there but shifted.

The diagram is a mess. I think that with an appropriate code for the two lines, the new code would give the diagram that I want. (It is a diagram for defining the sine and cosine functions for acute angles.) Please add "$\theta$" to the angle in the diagram.

\begin{tikzpicture}[
dot/.style={
fill,
circle,
inner sep=1.5pt
}
]
\path (80:3) coordinate (a) (20:3.5) coordinate (b) (0:0) coordinate (P);
\path (-70:1) coordinate (e) (-160:1) coordinate (f) (0:0) coordinate (P);
\path (80:2) coordinate (A) (20:2.5) coordinate (B) (0:0) coordinate (P);
\draw[<->] node [at start, left]{$\ell$} (a) -- (e);
\draw[<->] node [at start, right]{$k$} (b) -- (f);

\node[dot,label={left:$P$}] at (A) {};
\node[dot,label={below:$B$}] at (B) {};
\node[dot,label={left:$P$}] at (P) {};
\node[dot,label={right:$P$}] at (B) {};

\draw (A)
-- (P) node [at start, below left]{$A$}
-- (B) node [at start, right]{$B$};
\coordinate (Q) at ($(P)!(A)!(B)$);
(P) node [at start, left below]{$P$};
(Q) node [at start, right]{$Q$};
\draw[purple!70!black,dashed] (A) -- (Q);
\tkzMarkRightAngle(A,Q,P);

\draw[|<->|] ($(P)!7mm!90:(A)$)--node[fill=white,sloped] {$r$} ($(A)!7mm!-90:(P)$);
\draw[|<->|] ($(P)!7mm!90:(B)$)--node[fill=white,sloped] {$x$} ($(B)!7mm!-90:(P)$);
\draw[|<->|] ($(Q)!7mm!90:(A)$)--node[fill=white,sloped] {$y$} ($(A)!7mm!-90:(Q)$);
\draw pic[draw, angle radius=2mm,"$\theta$",angle eccentricity=2] {angle = B--P--A};
\end{tikzpicture}

• Can you please at least clean up the code a bit? You definitely know that there is no such thing as left below and remove the parts that you already know how to do such as labeling etc. I don't understand anything from the resulting picture. – percusse Sep 2 '14 at 17:54

Trying to get out of that "all chaos" I got this:

With the following code:

\documentclass[12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}

\begin{tikzpicture}[scale=2.5,dot/.style={fill,circle,inner sep=1.5pt}]

\path (80:3) coordinate (a) (20:3.5) coordinate (b) (0:0) node[dot,label=below left:$P$]{} coordinate(P)(-100:1)coordinate (e) (-160:1) coordinate (f)(80:2) node [dot,label=above left:$A$]{} coordinate (A) (20:2.5) node [dot,label=below:$B$]{} coordinate (B) ($(P)!(A)!(B)$) coordinate [label=below:$Q$](Q);
\draw[<->]  (a) node [above left ]{$l$} -- (e);
\draw[<->]  (b) node [below right]{$k$} -- (f);

\draw[purple!70!black,dashed] (A) -- (Q);
\tkzMarkRightAngle(A,Q,P);

\draw[|<->|] ($(P)!3mm!90:(A)$)--node[fill=white,sloped] {$r$} ($(A)!3mm!-90:(P)$);
\draw[|<->|] ($(P)!-3mm!90:(B)$)--node[fill=white,sloped] {$x$} ($(Q)!-3mm!-90:(P)$);
\draw[|<->|] ($(Q)!-3mm!90:(A)$)--node[fill=white,sloped] {$y$} ($(A)!-3mm!-90:(Q)$);
\path pic[draw, angle radius=9mm,"$\theta$",angle eccentricity=1.3] {angle = B--P--A};
\end{tikzpicture}

\end{document}

• Thanks for decoding that mess. There is one correction. $x$ denotes the length of $\overline{PQ}$. Please correct it for the other members of this site. – user143462 Sep 3 '14 at 0:02
• Updated my answer – AboAmmar Sep 3 '14 at 13:55
• causes error with \usepackage[ngerman]{babel}. in that case use pic text=$\theta$ instead of the quotes library. – jakun Jan 27 '17 at 18:12