使用“-|”语法时出错

使用“-|”语法时出错

以下代码可以编译,因为我在最后两个命令前面添加了 %。在最后两个命令中,我尝试使用“-|”语法来定位一个点。

\documentclass{amsart}

\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes}


\begin{document}

\noindent \hspace*{\fill}
\begin{tikzpicture}

%A polygon is drawn that is symmetric across the line through the origin and inclined
%at an angle of 105 degrees. 
\path (0,0) coordinate (A) (150:2.25) coordinate (B) ($(B) +(70:1.5)$) coordinate (C) ($(C) +(-20:0.5)$) coordinate (D);
\draw (A) -- (B) -- (C) -- (D);

%In order for the polygon to be symmetric across the line through the origin and inclined
%at an angle of 105 degrees, since 105 - 45 = 60, side AL must be inclined at an angle of
%60 degrees. Since an exterior angle of the polygon formed from the line through A and B
%and side BC is 80 degrees, and since 60 + 80 = 140, side KL  must be inclined at an angle
%of 140 degrees.
\path (60:2.25) coordinate (L) ($(L) +(140:1.5)$) coordinate (K) ($(K) +(230:0.5)$) coordinate (J);
\draw (A) -- (L) -- (K) -- (J);

\draw[name path=line_segment_BL, dashed] (B) -- (L);
\path[green,  name path=a_path_to_locate_E] (D) -- ($(D) +(-110:1.25)$);
\path[name path=a_path_to_locate_I] (J) -- ($(J) +(-40:1.25)$);

%A path parallel to side AB is drawn.
\path[green,  name path=another_path_to_locate_E] ($(A)!0.75cm!-90:(B)$) -- ($(B)!0.75cm!90:(A)$);
\path[name path=another_path_to_locate_I] ($(A)!0.75cm!90:(L)$) -- ($(L)!0.75cm!-90:(A)$);

\coordinate[name intersections={of=a_path_to_locate_E and another_path_to_locate_E, by=E}];
\coordinate[name intersections={of=a_path_to_locate_I and another_path_to_locate_I, by=I}];

\draw (D) -- (E);
\draw (I) -- (J);

\draw[name path=line_of_symmetry, dashed] (A) -- (105:2.25);
\coordinate[name intersections={of=line_segment_BL and line_of_symmetry, by=P}];

\draw (E) -- (P);
\draw (I) -- (P);


%Line $\ell$ is drawn.
\path (A) -- ($(A) +(-75:2)$);
\coordinate (midpoint_of_ell) at ($(A) +(-75:1.25)$);
\draw[name path=a_path_along_bottom_of_diagram] ($(midpoint_of_ell) +(-3,0)$) -- ($(midpoint_of_ell) +(3,0)$);
\path[name path=a_path_along_left_side_of_diagram] (B) -- ($(B) +(0,-2.5)$);
\path[name path=a_path_along_right_side_of_diagram] (L) -- ($(L) +(0,-3.5)$);
%\coordinate (bottom_left_corner_of_diagram) at (a_path_along_bottom_of_diagram -| a_path_along_left_side_of_diagram);
%\coordinate (bottom_right_corner_of_diagram) at (a_path_along_bottom_of_diagram -| a_path_along_right_side_of_diagram);


\end{tikzpicture}
\end{document}

答案1

期望(<something 1> |- <something 2>)用坐标或节点替换和<something 1><something 2>您尝试使用在此上下文中没有意义的路径名称。

例如,

\node (bottom_left_corner_of_diagram) at (B -| L) {B-\textbar L};
\node (other) at (B |- L) {B\textbar-L};

生产

alignments

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{calc,positioning,intersections,quotes}
\begin{document}
\begin{tikzpicture}

%A polygon is drawn that is symmetric across the line through the origin and inclined
%at an angle of 105 degrees.
\path (0,0) coordinate (A) (150:2.25) coordinate (B) ($(B) +(70:1.5)$) coordinate (C) ($(C) +(-20:0.5)$) coordinate (D);
\draw (A) -- (B) -- (C) -- (D);

%In order for the polygon to be symmetric across the line through the origin and inclined
%at an angle of 105 degrees, since 105 - 45 = 60, side AL must be inclined at an angle of
%60 degrees. Since an exterior angle of the polygon formed from the line through A and B
%and side BC is 80 degrees, and since 60 + 80 = 140, side KL  must be inclined at an angle
%of 140 degrees.
\path (60:2.25) coordinate (L) ($(L) +(140:1.5)$) coordinate (K) ($(K) +(230:0.5)$) coordinate (J);
\draw (A) -- (L) -- (K) -- (J);

\draw[name path=line_segment_BL, dashed] (B) -- (L);
\path[green,  name path=a_path_to_locate_E] (D) -- ($(D) +(-110:1.25)$);
\path[name path=a_path_to_locate_I] (J) -- ($(J) +(-40:1.25)$);

%A path parallel to side AB is drawn.
\path[green,  name path=another_path_to_locate_E] ($(A)!0.75cm!-90:(B)$) -- ($(B)!0.75cm!90:(A)$);
\path[name path=another_path_to_locate_I] ($(A)!0.75cm!90:(L)$) -- ($(L)!0.75cm!-90:(A)$);

\coordinate[name intersections={of=a_path_to_locate_E and another_path_to_locate_E, by=E}];
\coordinate[name intersections={of=a_path_to_locate_I and another_path_to_locate_I, by=I}];

\draw (D) -- (E);
\draw (I) -- (J);

\draw[name path=line_of_symmetry, dashed] (A) -- (105:2.25);
\coordinate[name intersections={of=line_segment_BL and line_of_symmetry, by=P}];

\draw (E) -- (P);
\draw (I) -- (P);

%Line $\ell$ is drawn.
\path (A) -- ($(A) +(-75:2)$);
\coordinate (midpoint_of_ell) at ($(A) +(-75:1.25)$);
\draw[name path=a_path_along_bottom_of_diagram] ($(midpoint_of_ell) +(-3,0)$) -- ($(midpoint_of_ell) +(3,0)$);
\path[name path=a_path_along_left_side_of_diagram] (B) -- ($(B) +(0,-2.5)$);
\path[name path=a_path_along_right_side_of_diagram] (L) -- ($(L) +(0,-3.5)$);
\node (bottom_left_corner_of_diagram) at (B -| L) {B-\textbar L};
\node (other) at (B |- L) {B\textbar-L};

\end{tikzpicture}
\end{document}

相关内容