1

I have a display of similar triangles - one inscribed in another. 2.5mm below one line segment, the labels C and C_1 are positioned. Actually, 2.5mm below the line segment, the centers of the nodes for C and C_1 are positioned. The subscript on C_1 is preventing them from being equidistant from the line segment. How do I make them equidistant?

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}




\begin{tikzpicture}

\coordinate (A) at (0,0);
\coordinate (B') at (50:7.5);
\path[name path=ray_k] (A) -- (B');
\coordinate (C') at (15:7.5);
\path[name path=ray_ell] (A) -- (C');


%This command labels a point "B" 3.75cm from A on ray $k$.
\coordinate (B) at (50:{15/4});
\draw (A) -- (B);

%These commands label the projection of AB onto \ell "C."  A line segment is drawn between
%B and C, and a right-angle mark is placed at C.
\coordinate (C) at ($(A)!(B)!(C')$);

\draw (B) -- (C);

%These commands draw a right-angle mark at C.
\coordinate (U) at ($(C)!3mm!-45:(A)$);
\draw (U) -- ($(C)!(U)!(A)$);
\draw (U) -- ($(C)!(U)!(B)$);


%These commands draw an invisible line segment perpendicular to ray k from B to
%ray $\ell$. The intersection is labeled C_1.
\path[name path=perpendicular_line_segment_from_B] (B) -- ($(B)!3.5cm!90:(A)$);
\coordinate[name intersections={of=perpendicular_line_segment_from_B and ray_ell, by={C_1}}];


%The following commands define B_1 as the intersection of k and a line segment
%perpendicular to $\ell$ through C_1. A line segment is drawn between
%B_1 and C_1, and a right-angle mark is placed at C_1.
\path[name path=perpendicular_line_segment_from_C_1] (C_1) -- ($(C_1)!4cm!90:(C')$);
\coordinate[name intersections={of=perpendicular_line_segment_from_C_1 and ray_k, by={B_1}}];
\draw (C_1) -- (B_1);

%These commands draw a right-angle mark at C_1.
\coordinate (U_1) at ($(C_1)!3mm!-45:(A)$);
\draw (U_1) -- ($(C_1)!(U_1)!(A)$);
\draw (U_1) -- ($(C_1)!(U_1)!(B_1)$);


%This command draws the two sides of the triangle with a common vertex A.
\draw (A) -- (B_1);
\draw (A) -- (C_1);



%These commands draw an invisible line segment 2.5mm below AD for labels C and C_1.
\coordinate (A_shift_for_labels) at ($(A)!2.5mm!-90:(C_1)$);
\coordinate (C_1_shift_for_labels) at ($(C_1)!2.5mm!90:(A)$);
\path[name path=path_for_labels_C_and_C_1] (A_shift_for_labels) -- (C_1_shift_for_labels);
\coordinate (C_below) at ($(C)!-0.75cm!(B)$);
\path[name path=path_from_B_to_C_below] (B) -- (C_below);
\coordinate (C_1_below) at ($(C_1)!-0.75cm!(B_1)$);
\path[name path=path_from_B_1_to_C_1_below] (B_1) -- (C_1_below);
\coordinate[name intersections={of=path_for_labels_C_and_C_1 and path_from_B_to_C_below, by={C_label}}];
\coordinate[name intersections={of=path_for_labels_C_and_C_1 and path_from_B_1_to_C_1_below, by={C_1_label}}];
\node[green] at (C_label){$C$};
\node[green] at (C_1_label){$C_{1}$};

\end{tikzpicture}

\end{document}
user74973
  • 4,071
  • 1
    Use $\strut C$ – percusse Jun 27 '15 at 16:45
  • 1
    or \node[green] at (C_label){$C_{\phantom{1}}$}; – Ignasi Jun 27 '15 at 16:49
  • 1
    or [anchor=base] or [anchor=mid] or [anchor=north] or whichever you prefer... – cfr Jun 27 '15 at 20:48
  • @Ignasi I like the spacing of "C" in this case. Can I get the space occupied by the subscript "1" to be ignored? – user74973 Jun 27 '15 at 21:26
  • @percusse I would like the "$C_{1}$" moved. How do I use $\strut C$? – user74973 Jun 27 '15 at 21:31
  • 1
    @user74973 to ignore only the vertical space $C\smash{_{1}}$ can be used. – Kpym Jun 28 '15 at 06:18
  • @Kpym The \smash command does ignore the vertical space, and both C and C_1 are typeset equidistant from the ray. It does not ignore the horizontal space, and the "C" in C_1 is displaced leftward. How do I get TikZ to ignore the area the subscript occupies when positioning C_1? – user74973 Jun 28 '15 at 15:01
  • @user74973 if you want to ignore both (width and height) you can use $C\mathrlap{\smash{_{1}}}$. To be able to use \mathrlap you have to replace amsmath with mathtools. Probably this is not the best way to do it, but it works for me. – Kpym Jun 28 '15 at 18:21
  • @Kpym Yeah, I don't want to get away from amsmath. I tried using an mbox[0pt] to get TikZ to ignore the subscript in the following command: \node[green] at (C_1_label){$C\smash{\makebox[0pt]{${}_{1}$}}$};. The subscript is typeset flush against the C, though. – user74973 Jun 29 '15 at 00:59
  • 1
    @user74973 You don't go away from amsmath by replacing it with mathtools, who is an extension of amsmath AND loads it. You can ckeck this question. – Kpym Jun 29 '15 at 04:53
  • @Kpym Another member, cfr, suggested the following edits to my code. He put \newlength\myshift and \settowidth{\myshift}{$_1$} before the tikzpicture environment, and he put \node[blue, xshift=.5\myshift] at (B_1_label){$B_{1}$}; and \node[blue, xshift=.5\myshift] at (C_1_label){$C\smash{_{1}}$}; in the code. I like what he did. The code does typeset, for example, the C in C_1 at the position called C_1_label just as it would typeset C at C_1_label. – user74973 Jun 29 '15 at 14:49
  • @Kpym I understand that \myshift occupies the same width as the subscript 1. How does xshift=.5\myshift "cancel" the width occupied by 1? – user74973 Jun 29 '15 at 14:49

0 Answers0