I have a diagram of two right triangles - one inscribed in another. I have y and y' indicating the length of the leg opposite one of the acute angles. (The y is for the smaller triangle.) I also have a green line drawn that is the angle bisector of this acute angle. I want to get the two y's in the same relative position on the green line. I tried using the commands
\newlength\widthofprime
\settowidth{\widthofprime}{${}^{\prime}$}
\newlength\heightofprime
\settoheight{\heightofprime}{${}^{\prime}$}
to compensate for the space occupied by the prime. I would like to get help modifying this code to get the display that I want.
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}
\begin{document}
\noindent \hspace*{\fill}
\begin{tikzpicture}
%$\triangle{POQ}$ is a right triangle with it right angle at P, $\triangle{P'OQ'}$ is
%a right triangle with its right angle at P', and $\triangle{POQ}$ is inscribed in
%$\triangle{P'OQ'}$.
\coordinate (O) at (0,0);
\node[anchor={0.5*(15+50)}, inner sep=0] at ($(O) +({0.5*(195+230)}:0.15)$){$O$};
\coordinate (Q) at (50:{15/4});
\node[anchor={50-90}, inner sep=0] at ($(Q) +({50+90}:0.15)$){$Q$};
\coordinate (P) at ($(O)!(Q)!(15:1)$);
\node[anchor={15+90}, inner sep=0] at ($(P) +({15-90}:0.15)$){$P$};
%A right-angle mark is drawn at P.
\draw ($(P)!3mm!-45:(O)$) coordinate (U) -- ($(P)!(U)!(O)$);
\draw (U) -- ($(P)!(U)!(Q)$);
%P' is the intersection of ray{OP} and the line through Q that is perpendicular
%to ray{OQ}.
\path[name path=ray_on_which_points_P_and_P'_lie] (O) -- (15:4.75);
\path[name path=perpendicular_line_segment_from_Q] (Q) -- ($(Q)!2.75cm!90:(O)$);
\coordinate[name intersections={of=perpendicular_line_segment_from_Q and ray_on_which_points_P_and_P'_lie, by=P'}];
\node[anchor={15+90}, inner sep=0] at ($(P') +({15-90}:0.15)$){$P^{\prime}$};
%Q' is the intersection of ray{OQ} and the line through P' that is perpendicular
%to ray{OP}.
\path[name path=ray_on_which_points_Q_and_Q'_lie] (O) -- (50:5.75);
\path[name path=perpendicular_line_segment_from_P'] (P') -- ($(P')!3.25cm!-90:(O)$);
\coordinate[name intersections={of=perpendicular_line_segment_from_P' and ray_on_which_points_Q_and_Q'_lie, by=Q'}];
\node[anchor={50-90}, inner sep=0] at ($(Q') +({50+90}:0.15)$){$Q'$};
%The sides of the triangle are drawn.
\draw (O) -- (P');
\draw (O) -- (Q');
\draw (P) -- (Q);
\draw (P') -- (Q');
%A right-angle mark is drawn at P'.
\draw ($(P')!3mm!-45:(O)$) coordinate (U') -- ($(P')!(U')!(O)$);
\draw (U') -- ($(P')!(U')!(Q')$);
%The superscript "^{\prime}" in "$Q^{\prime}$" and "$P^{\prime}$" displaces the "Q" in "$Q^{\prime}$" and the
%"P" in "$P^{\prime}$" leftward artificially by half of its width. To cancel this artificial shift, a
%"\newlength" command is defined as the width of the subscript "^{\prime}," and the command
%"xshift=0.5\widthofprime" is issued to the node commands that position "$Q^{\prime}$" and "$P^{\prime}$."
\newlength\widthofprime
\settowidth{\widthofprime}{${}^{\prime}$}
\newlength\heightofprime
\settoheight{\heightofprime}{${}^{\prime}$}
%The length of PQ is labeled y.
\draw let \p1=($(P)-(Q)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-90}, inner sep=0] at ($($(P)!0.15cm!-90:(Q)$)! 0.5! ($(Q)!0.15cm!90:(P)$)$){$y$};
%The length of P'Q' is labeled y'.
\draw let \p1=($(P)-(Q)$), \n1={atan(\y1/\x1)} in node[xshift={cos(\n1)*(0.5\widthofprime)}, yshift={sin(\n1+180)*(0.5\heightofprime)}, anchor={\n1-90}, inner sep=0] at ($($(P')!0.15cm!-90:(Q')$)! 0.5! ($(Q')!0.15cm!90:(P')$)$){$y^{\prime}$};
\draw[green] (O) -- ({0.5*(15+50)}:6);
\node[align=center,font=\bfseries,anchor=north,yshift=-3mm] at (current bounding box.south) {An illustration of similar right triangles \\ $\mathbf{\triangle{POQ}}$ and $\mathbf{\triangle{P^{\prime}OQ^{\prime}}}$};
\end{tikzpicture}
\end{document}

$P\makebox[0pt][l]{\smash{$'$}}$will produce a prime that occupies no space. – egreg May 02 '16 at 22:34{$y^{\makebox[0pt][l]{\smash{${\prime}$}}}$}. That types the'in the "regular" font and not as a superscript. Theyiny'is now above the green line. – Adelyn May 02 '16 at 22:43y's in the same relative position on the green line. – Adelyn May 02 '16 at 22:45$'$, not$\prime$. You're probably computing wrongly the coordinates. – egreg May 02 '16 at 22:45{$y^{\makebox[0pt][l]{\smash{$'$}}}$}. Theyiny'is not typeset correctly. – Adelyn May 02 '16 at 22:51$y\phantom{'}$in theywithout prime? – Herr K. May 02 '16 at 22:52yin the smaller triangle is positioned correctly. – Adelyn May 02 '16 at 22:54^afteryin his code. Also, try adding thedrawoption tonodeto visualize the effect. – Herr K. May 02 '16 at 23:11^. The new code does not put theyiny'in the same position as theyfor the smaller triangle. Anyway, I want to know how to modify the code in my post. – Adelyn May 03 '16 at 02:25\smashcommand is appropriate. Why is theyiny'almost above the green line but the otheryis "in the middle" of the green line? – Adelyn May 03 '16 at 13:39y's, and the angle bisector in green. – Adelyn May 03 '16 at 16:50