The following code instructs `TikZ`

to draw a right triangle AQP with a right angle at Q. I mark the length of line segment AQ by y. How do I rotate by 90 degrees the letter y so that it is upright? I would like to draw a line segment perpendicular to PA from A to the line containing the leg PQ, and I would like to label that point of intersection R.

```
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}[dot/.style={fill,circle,inner sep=1.5pt}]
\path
(80:5) node [dot,label=above left:$A$]{} coordinate (A)
(80:7) coordinate (a)
(20:9) coordinate (B)
(20:11) coordinate (b)
(0:0) node[dot,label=below left:$P$]{} coordinate(P)
(-100:1)coordinate (e)
(-160:1) coordinate (f);
\path coordinate (Q)at($(P)!(A)!(B)$) node at (Q)[dot,label=below:$Q$]{} ;
\draw[<->] (a)--(e);
\draw[<->, name path=kline] (f)--(b) node[below right]{$k$}; % First line for intersection
\draw[purple!70!black,dashed] (A)--(Q);
\tkzMarkRightAngle(A,Q,P);
\draw ($(P)!3mm!90:(A)$)--($(A)!3mm!-90:(P)$)coordinate(u); % Note here the invisible point u, where uA is normal to pA at point A
\draw[|<->|] ($(P)!-7mm!90:(Q)$)--node[fill=white,sloped] {$x$} ($(Q)!-7mm!-90:(P)$);
\draw[|<->|] ($(Q)!-3mm!90:(A)$)--node[fill=white] {$y$} ($(A)!-3mm!-90:(Q)$);
\tkzMarkAngle[size=0.75cm,color=cyan,mark=||](B,P,A);
\tkzMarkAngle[size=1cm,color=cyan,mark=|](P,A,Q);
\path [name path=ARline] (u)--($(A)!-10cm!(u)$); % Second line for intersection
\path [name intersections={of = ARline and kline, by=R}];
\draw (A)--(R)node[dot,label=below:$R$]{};
\tkzMarkRightAngle(R,A,P);
\end{tikzpicture}
\end{document}
```

## Best Answer

Your code produces errors; I tried to polish it by guessing what you were trying to do:

The code: