我有一个相似三角形的显示 - 一个三角形内接另一个三角形。我有五个顶点,分别标记为、、、和A
。线段和彼此平行。我喜欢标签和相对于线段的位置。我希望标签中的和标签中的具有相同的(相对)位置。B
C
B_1
B_2
BC
B_1C_1
B
C
BC
B
B_1
C
C_1
在 Kpym 的建议下,我曾经$C\smash{_{1}}$
获取C
并C_1
排版与线段等距的 。但C_1
由于下标1
,有一些向左的人为位移。(我\smash
在排版 $B\smash{_{1}}$ 时也使用了该命令。)
\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}
%Rays k and $\ell$ have a common endpoint at the origin, which is labeled A. With respect to
%the horizontal line through A, k is inclined at an angle of 50 degrees, and $\ell$ is
%inclined at an angle of 15 degrees. To place the label for A, the rays are extended 15pt by an
%invisible path command "before" A. The endpoints of these extensions are called "label_A_below"
%and "label_A_above" and the midpoint of the line segment between label_A_below and label_A_above
%is called "label_A". A node command typesets "A" at the point 7.5pt from A on the invisible
%line segment between A and label_A .
\coordinate (A) at (0,0);
\draw[fill] (A) circle (1.5pt);
\coordinate (label_A_below) at (-130:15pt);
\coordinate (label_A_above) at (-165:15pt);
\coordinate (label_A) at ($(label_A_below)!0.5!(label_A_above)$);
\node[blue] at ($(A)!7.5pt!(label_A)$){$A$};
%B' is a point on ray k and C' is a point on $\ell$.
\coordinate (B') at (50:7);
\draw[name path=ray_k, -latex,] (A) -- (B');
\node (label_ray_k) at ($(B') + (50:7pt)$){$k$};
\coordinate (C') at (15:5.5);
\draw[name path=ray_ell, -latex,] (A) -- (C');
\node (label_ray_ell) at ($(C') + (15:6pt)$){$\ell$};
%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) node [midway,right]{$y$};
\coordinate (U) at ($(C)!3mm!-45:(A)$);
\draw (U) -- ($(C)!(U)!(A)$);
\draw (U) -- ($(C)!(U)!(B)$);
%This command labels the length of AC.
\draw (A) -- (C) node [midway, below]{$x$};
%These commands draw an invisible line segment perpendicular to ray k from B to
%ray $\ell$. The intersection is labeled C_1. (The label for C_1 is placed after
%the point B_1 is defined.)
\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. The labels "$B_{1}$" and "$C_{1}$"
%are typeset either directly above or directly below this line segment.
\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) node [midway,right]{$y_{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)$);
%These commands put a brace below line segment AC_1 and label the length `$x_{1}$`. This brace
%needs to be shifted downward from AC_1 to avoid interference with the labels A, C, and C_1.
%First, coordinates for A_shift and C_1_shift are defined to be 5mm from AC_1. A brace is drawn
%between A_shift and D_shift.
\coordinate (A_shift) at ($(A)!5.5mm!-90:(C_1)$);
\coordinate (C_1_shift) at ($(C_1)!5.5mm!90:(A)$);
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (A_shift) --
node[below right=4mm and 0.0625mm, fill=white, inner sep=1pt]{$x_{1}$} (C_1_shift);
%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 above AB_1 for labels B and B_1.
\coordinate (A_shift_for_labels_version_1) at ($(A)!2.5mm!90:(B_1)$);
\coordinate (B_1_shift_for_labels) at ($(B_1)!2.5mm!-90:(A)$);
\coordinate (B_1_shift_for_labels_extension) at ($(B_1_shift_for_labels)!-0.25cm!(A_shift_for_labels_version_1)$);
\path[name path=path_for_labels_B_and_B_1] (A_shift_for_labels_version_1) -- (B_1_shift_for_labels_extension);
\coordinate (B_above) at ($(B)!-0.75cm!(C)$);
\path[name path=path_from_C_to_B_above] (C) -- (B_above);
\coordinate (B_1_above) at ($(B_1)!-0.75cm!(C_1)$);
\path[name path=path_from_C_1_to_B_1_above] (C_1) -- (B_1_above);
\coordinate[name intersections={of=path_for_labels_B_and_B_1 and path_from_C_to_B_above, by={B_label}}];
\coordinate[name intersections={of=path_for_labels_B_and_B_1 and path_from_C_1_to_B_1_above, by={B_1_label}}];
\node[green] at (B_label){$B$};
\node[blue] at (B_1_label){$B\smash{_{1}}$};
%These commands draw an invisible line segment 2.5mm below AC_1 for labels C and C_1. The center of the node
%containing $C_{1}$ is displaced upwards by the subscript "1" in $C_{1}$. To avoid this upward vertical
%displacement, a \smash command is issued.
\coordinate (A_shift_for_labels_version_2) 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_version_2) -- (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[blue] at (C_1_label){$C\smash{_{1}}$};
\end{tikzpicture}
\end{document}
答案1
您想要这样的东西吗?请注意,B_1
除非您希望标签打印在线上,否则您必须将标签向上移动。因此,\smash
如果您还要应用所要求的水平调整,那么使用这里就没有什么意义了。
水平调整是通过测量宽度$_1$
并使用该值的一半作为标记节点的偏移量来完成的。
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\newlength\myshift
\settowidth{\myshift}{$_1$}
\begin{tikzpicture}
%Rays k and $\ell$ have a common endpoint at the origin, which is labeled A. With respect to
%the horizontal line through A, k is inclined at an angle of 50 degrees, and $\ell$ is
%inclined at an angle of 15 degrees. To place the label for A, the rays are extended 15pt by an
%invisible path command "before" A. The endpoints of these extensions are called "label_A_below"
%and "label_A_above" and the midpoint of the line segment between label_A_below and label_A_above
%is called "label_A". A node command typesets "A" at the point 7.5pt from A on the invisible
%line segment between A and label_A .
\draw[fill] coordinate (A) circle (1.5pt);
\coordinate (label_A_below) at (-130:15pt);
\coordinate (label_A_above) at (-165:15pt);
\coordinate (label_A) at ($(label_A_below)!0.5!(label_A_above)$);
\node[blue] at ($(A)!7.5pt!(label_A)$){$A$};
%B' is a point on ray k and C' is a point on $\ell$.
\draw[name path=ray_k, -latex,] (A) -- (50:7) coordinate (B');
\node (label_ray_k) at ($(B') + (50:7pt)$){$k$};
\draw[name path=ray_ell, -latex,] (A) -- (15:5.5) coordinate (C');
\node (label_ray_ell) at ($(C') + (15:6pt)$){$\ell$};
%This command labels a point "B" 3.75cm from A on ray $k$.
\draw (A) -- (50:{15/4}) coordinate (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.
\draw (B) -- ($(A)!(B)!(C')$) coordinate (C) node [midway,right]{$y$};
\draw ($(C)!3mm!-45:(A)$) coordinate (U) -- ($(C)!(U)!(A)$);
\draw (U) -- ($(C)!(U)!(B)$);
%This command labels the length of AC.
\draw (A) -- (C) node [midway, below]{$x$};
%These commands draw an invisible line segment perpendicular to ray k from B to
%ray $\ell$. The intersection is labeled C_1. (The label for C_1 is placed after
%the point B_1 is defined.)
\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. The labels "$B_{1}$" and "$C_{1}$"
%are typeset either directly above or directly below this line segment.
\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) node [midway,right]{$y_{1}$};
\draw ($(C_1)!3mm!-45:(A)$) coordinate (U_1) -- ($(C_1)!(U_1)!(A)$);
\draw (U_1) -- ($(C_1)!(U_1)!(B_1)$);
%These commands put a brace below line segment AC_1 and label the length `$x_{1}$`. This brace
%needs to be shifted downward from AC_1 to avoid interference with the labels A, C, and C_1.
%First, coordinates for A_shift and C_1_shift are defined to be 5mm from AC_1. A brace is drawn
%between A_shift and D_shift.
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] ($(A)!5.5mm!-90:(C_1)$) coordinate (A_shift) --
node[below right=4mm and 0.0625mm, fill=white, inner sep=1pt] {$x_{1}$} ($(C_1)!5.5mm!90:(A)$) coordinate (C_1_shift);
%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 above AB_1 for labels B and B_1.
\coordinate (A_shift_for_labels_version_1) at ($(A)!2.5mm!90:(B_1)$);
\coordinate (B_1_shift_for_labels) at ($(B_1)!2.5mm!-90:(A)$);
\coordinate (B_1_shift_for_labels_extension) at ($(B_1_shift_for_labels)!-0.25cm!(A_shift_for_labels_version_1)$);
\path[name path=path_for_labels_B_and_B_1] (A_shift_for_labels_version_1) -- (B_1_shift_for_labels_extension);
\path[name path=path_from_C_to_B_above] (C) -- ($(B)!-0.75cm!(C)$) coordinate (B_above);
\path[name path=path_from_C_1_to_B_1_above] (C_1) -- ($(B_1)!-0.75cm!(C_1)$) coordinate (B_1_above);
\coordinate[name intersections={of=path_for_labels_B_and_B_1 and path_from_C_to_B_above, by={B_label}}];
\coordinate[name intersections={of=path_for_labels_B_and_B_1 and path_from_C_1_to_B_1_above, by={B_1_label}}];
\node[green] at (B_label){$B$};
\node[blue, xshift=.5\myshift, yshift=.5em] at (B_1_label){$B_{1}$};
%These commands draw an invisible line segment 2.5mm below AC_1 for labels C and C_1. The center of the node
%containing $C_{1}$ is displaced upwards by the subscript "1" in $C_{1}$. To avoid this upward vertical
%displacement, a \smash command is issued.
\coordinate (A_shift_for_labels_version_2) 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_version_2) -- (C_1_shift_for_labels);
\path[name path=path_from_B_to_C_below] (B) -- ($(C)!-0.75cm!(B)$) coordinate (C_below);
\path[name path=path_from_B_1_to_C_1_below] (B_1) -- ($(C_1)!-0.75cm!(B_1)$) coordinate (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[blue, xshift=.5\myshift] at (C_1_label){$C\smash{_{1}}$};
\end{tikzpicture}
\end{document}
如果您不介意标签写在线上,您当然可以删除yshift
并恢复\smash
。
编辑
这里证明 的C
排版C_1
好像_1
没有任何面积。
C_1
我在标签排版之前添加了以下行:
\node[red] at (C_1_label){$C$};
由于此节点为红色,而实际节点为蓝色,因此测试是红色C
在最终结果中是否可见。如下所示,红色不可见:
如果将_1
视为具有面积,则C
中的蓝色C_1
将相对于其下方的红色发生偏移C
。但事实并非如此。