我画了一个梯形,并画出了它的对角线。底边的中点和对角线的交点共线。(如果有人能为我提供这个命题的参考,我将不胜感激。)我附上了这条用绿色画出的线。我想让支架的尖端位于绿线上,而不是“将端点向左移动一点,发现它不太正确,然后将端点向下移动一点”。
\documentclass{amsart}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\begin{document}
\begin{tikzpicture}
%Trapezoid ABCD is drawn.
\coordinate (A) at (0,0);
\coordinate (B) at (5.5,0);
\coordinate (C) at ($(B) +(110:2.25)$);
\coordinate (D) at ($(C) +(-2.5,0)$);
\draw (A) -- (B) -- (C) -- (D) -- (A) -- cycle;
\draw[dashed] (A) -- (C);
\draw[dashed] (B) -- (D);
%The intersection of the diagonals is labeled E.
\path[name path=a_path_to_locate_E] (A) -- (C);
\path[name path=another_path_to_locate_E] (B) -- (D);
\coordinate[name intersections={of=a_path_to_locate_E and another_path_to_locate_E, by=E}];
%The intersections of the line through E parallel to the bases of the trapezoid are labeled
%F and G.
\path[name path=a_path_to_locate_F] (A) -- (D);
\path[name path=another_path_to_locate_F] let \p1=($(A)-(B)$), \n1={atan(\y1/\x1)} in (E) -- ($(E) +({\n1-180}:2)$);
\coordinate[name intersections={of=a_path_to_locate_F and another_path_to_locate_F, by=F}];
%
\path[name path=a_path_to_locate_G] (B) -- (C);
\path[name path=another_path_to_locate_G] let \p1=($(A)-(B)$), \n1={atan(\y1/\x1)} in (E) -- ($(E) +(\n1:2)$);
\coordinate[name intersections={of=a_path_to_locate_G and another_path_to_locate_G, by=G}];
%The line segment FG through E is drawn.
\draw (F) -- (G);
%The labels for the trapezoid are typeset.
\node[anchor=north, inner sep=0, font=\footnotesize] at ($(A) +(0,-0.15)$){$A$};
\node[anchor=north, inner sep=0, font=\footnotesize] at ($(B) +(0,-0.15)$){$B$};
\node[anchor=south, inner sep=0, font=\footnotesize] at ($(C) +(0,0.15)$){$C$};
\node[anchor=south, inner sep=0, font=\footnotesize] at ($(D) +(0,0.15)$){$D$};
\path[name path=a_path_for_label_F] ($(A)!0.15cm!90:(D)$) -- ($(D)!0.15cm!-90:(A)$);
\path[name path=a_path_for_labels_G] ($(B)!0.15cm!-90:(C)$) -- ($(C)!0.15cm!90:(B)$);
\path[name path=another_path_for_label_F] (F) -- ($(F)!{-0.25cm}!(G)$);
\path[name path=another_path_for_label_G] (G) -- ($(G)!{-0.25cm}!(F)$);
\coordinate[name intersections={of=a_path_for_label_F and another_path_for_label_F, by=label_for_F}];
\node[anchor=east, inner sep=0, font=\footnotesize] at (label_for_F){$F$};
\coordinate[name intersections={of=a_path_for_labels_G and another_path_for_label_G, by=label_for_G}];
\node[anchor=west, inner sep=0, font=\footnotesize] at (label_for_G){$G$};
\node[anchor=south, inner sep=0, font=\footnotesize] at ($(E) +(0,0.15)$){$E$};
%The lengths of the bases of the trapezoid are typeset.
\path[name path=path_for_label_for_a] ($(A)!0.15cm!-90:(B)$) -- ($(B)!0.15cm!90:(A)$);
\path[name path=path_for_label_for_c] ($(C)!0.15cm!-90:(D)$) -- ($(D)!0.15cm!90:(C)$);
\draw[green, name path=the_line_through_E_and_the_midpoints_of_the_bases] let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in
($($(A)!0.5!(B)$) +({\n1-180}:0.25)$) -- ($($(C)!0.5!(D)$) +(\n1:0.25)$);
\coordinate[name intersections={of=path_for_label_for_a and the_line_through_E_and_the_midpoints_of_the_bases, by=label_for_a}];
\path let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in node[anchor=\n1, inner sep=0, font=\footnotesize] at (label_for_a){$a$};
\coordinate[name intersections={of=path_for_label_for_c and the_line_through_E_and_the_midpoints_of_the_bases, by=label_for_c}];
\path let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-180}, inner sep=0, font=\footnotesize] at (label_for_c){$c$};
%The length of FG is typeset. Its length is labeled e. As the midpoints of the bases are collinear
%with E, the label for the length of FG is typeset on the line containing these three points.
\draw[decorate,decoration={brace,raise=2.5pt,amplitude=5pt,mirror}] (F) -- (G);
\path[name path=path_for_label_for_e] ($(F)!0.35cm!-90:(G)$) -- ($(G)!0.35cm!90:(F)$);
\coordinate[name intersections={of=path_for_label_for_e and the_line_through_E_and_the_midpoints_of_the_bases, by=label_for_e}];
\draw let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in node[anchor=\n1, inner sep=0, font=\footnotesize] at (label_for_e){$e$};
\end{tikzpicture}
\end{document}
答案1
对于括号,您需要有 TikZ 库,decorations.pathreplacing
而不是decorations.markings
。通过此更改,您的 MWE 可以工作。但是,我完全不明白您的代码,因此,根据使用您的代码获得的图像:
我完全重写了你的代码:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles,backgrounds,calc,
decorations.pathreplacing,intersections,
patterns,positioning,quotes}
\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}[
every label/.style = {font=\footnotesize, inner sep=2pt}
]
% Coordinates with labels of trapezoid vertices
\coordinate[label=below:$A$] (A) at (0,0);
\coordinate[label=below:$B$] (B) at (5.5,0);
\coordinate[label=above:$C$] (C) at ($(B) +(110:2.25)$);
\coordinate[label=above:$D$] (D) at ($(C) +(-2.5,0)$);
% Trapezoid ABCD is drawn.
\draw (A) -- (B) -- (C) -- (D) -- (A) -- cycle;
\draw[dashed] (A) -- (C) (B) -- (D);
% Coordinates E, F and G with labels
\coordinate[label=above:$E$] (E) at (intersection cs:first line={(A)--(C)},
second line={(B)--(D)});
\coordinate[label= left:$F$] (F) at (intersection cs:first line={(A)--(D)},
second line={(E)--(E-|A)});
\coordinate[label=right:$G$] (G) at (intersection cs:first line={(B)--(C)},
second line={(E)--(E-|B)});
% Line F -- G
\draw (F) -- (G);
% Green line a -- c with labels a, e and c
\draw[green, shorten >=-2mm, shorten <=-2mm]
($(A)!0.5!(B)$) node[label=below:$a$] {} --
coordinate[label=left:$e$] (e)
($(C)!0.5!(D)$) node[label=above:$c$] {};
% brace between F and G, it is not clear if it have a node, so ???
\draw[decorate,decoration={brace,raise=2.5pt,amplitude=5pt,mirror},red]
(F) -- node[below=5pt] {???} (G);
\end{tikzpicture}
\end{document}
图像和代码是您想要的吗?
编辑:读完您的回答后,我发现主要问题是如何以确定性的方式将括号放在绿线上“极端”下方。所以我再次更改了附录。现在它包含了一种计算纵横比的可能方法,从而得到所需的结果。
附录:从你的回答中,我发现你喜欢使用不对称支架,其起点位于绿线 a – c 上。为此,我采用了以下选项aspect
:
对于此图像,我将上述代码的末尾改为\draw (F) -- (G);
:
% Green line a -- c with labels a and c
\draw[green, shorten >=-1pt, shorten <=-1pt]
($(A)!0.5!(B)$) coordinate[label=below:$a$] (a) --
($(C)!0.5!(D)$) coordinate[label=above:$c$] (c) ;
% brace parallel to line between F and E,
\draw let \p1 = ($(c)-(a-|c)$),
\p2 = ($(a)-(a-|c)$),
\n1 = {veclen(\y1,\x1)},
\n2 = {veclen(\y2,\x2)} in
[decorate,
decoration={brace,raise=2.5pt,amplitude=5pt,mirror,
aspect=0.5-0.075*\n2/\n1 % 0.075=(raise + amplitude)/(100 pt)
},red,
]
(F) -- node[below=6pt,xshift=-8.5pt*\n2/\n1,% 8,5pt = 2,5pt + 6pt
font=\footnotesize] {$e$} (G);
\end{tikzpicture}
代码的注释中描述了如何计算选项aspect
以及如何计算括号下方节点的移位。我希望我现在正确理解了你的问题。
答案2
\documentclass{amsart}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
%Trapezoid ABCD is drawn.
\coordinate (A) at (0,0);
\coordinate (B) at (5.5,0);
\coordinate (C) at ($(B) +(110:2.25)$);
\coordinate (D) at ($(C) +(-2.5,0)$);
\draw (A) -- (B) -- (C) -- (D) -- (A) -- cycle;
\draw[dashed] (A) -- (C);
\draw[dashed] (B) -- (D);
%The intersection of the diagonals is labeled E.
\path[name path=a_path_to_locate_E] (A) -- (C);
\path[name path=another_path_to_locate_E] (B) -- (D);
\coordinate[name intersections={of=a_path_to_locate_E and another_path_to_locate_E, by=E}];
%The intersections of the line through E parallel to the bases of the trapezoid are labeled
%F and G.
\path[name path=a_path_to_locate_F] (A) -- (D);
\path[name path=another_path_to_locate_F] let \p1=($(A)-(B)$), \n1={atan(\y1/\x1)} in (E) -- ($(E) +({\n1-180}:2)$);
\coordinate[name intersections={of=a_path_to_locate_F and another_path_to_locate_F, by=F}];
%
\path[name path=a_path_to_locate_G] (B) -- (C);
\path[name path=another_path_to_locate_G] let \p1=($(A)-(B)$), \n1={atan(\y1/\x1)} in (E) -- ($(E) +(\n1:2)$);
\coordinate[name intersections={of=a_path_to_locate_G and another_path_to_locate_G, by=G}];
%The line segment FG through E is drawn.
\draw (F) -- (G);
%The labels for the trapezoid are typeset.
\node[anchor=north, inner sep=0, font=\footnotesize] at ($(A) +(0,-0.15)$){$A$};
\node[anchor=north, inner sep=0, font=\footnotesize] at ($(B) +(0,-0.15)$){$B$};
\node[anchor=south, inner sep=0, font=\footnotesize] at ($(C) +(0,0.15)$){$C$};
\node[anchor=south, inner sep=0, font=\footnotesize] at ($(D) +(0,0.15)$){$D$};
\path[name path=a_path_for_label_F] ($(A)!0.15cm!90:(D)$) -- ($(D)!0.15cm!-90:(A)$);
\path[name path=a_path_for_labels_G] ($(B)!0.15cm!-90:(C)$) -- ($(C)!0.15cm!90:(B)$);
\path[name path=another_path_for_label_F] (F) -- ($(F)!{-0.25cm}!(G)$);
\path[name path=another_path_for_label_G] (G) -- ($(G)!{-0.25cm}!(F)$);
\coordinate[name intersections={of=a_path_for_label_F and another_path_for_label_F, by=label_for_F}];
\node[anchor=east, inner sep=0, font=\footnotesize] at (label_for_F){$F$};
\coordinate[name intersections={of=a_path_for_labels_G and another_path_for_label_G, by=label_for_G}];
\node[anchor=west, inner sep=0, font=\footnotesize] at (label_for_G){$G$};
\node[anchor=south, inner sep=0, font=\footnotesize] at ($(E) +(0,0.15)$){$E$};
%The lengths of the bases of the trapezoid are typeset. The midpoints of the bases are collinear
%with E. For convenience, the line through the midpoints of the bases and E is called
%"the_middle_line."
\path[name path=path_for_label_for_a] ($(A)!0.15cm!-90:(B)$) -- ($(B)!0.15cm!90:(A)$);
\path[name path=path_for_label_for_c] ($(C)!0.15cm!-90:(D)$) -- ($(D)!0.15cm!90:(C)$);
\draw[green, name path=the_middle_line] let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in
($($(A)!0.5!(B)$) +({\n1-180}:0.25)$) -- ($($(C)!0.5!(D)$) +(\n1:0.25)$);
\coordinate[name intersections={of=path_for_label_for_a and the_middle_line, by=label_for_a}];
\path let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in node[anchor=\n1, inner sep=0, font=\footnotesize] at (label_for_a){$a$};
\coordinate[name intersections={of=path_for_label_for_c and the_middle_line, by=label_for_c}];
\path let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-180}, inner sep=0, font=\footnotesize] at (label_for_c){$c$};
%The length of FG is typeset. Its length is labeled e. As the midpoints of the bases are collinear
%with E, the label for the length of FG is typeset on the line containing these three points.
%A brace is typeset under FG. To be sure that the center of the brace is on the_middle_line, a line
%0.25cm under FG is drawn. For convenience, this line is called "the_line_under_FG." The endpoints
%of the brace is half the length of FG from the intersection of the_middle_line and the_line_under_FG.
%Since the options raise=2.5pt and amplitude=5pt are used, and since FG is a horizontal line, to
%center the tip of the brace on the_middle_line, both endpoints are raised 7.5pt.
\path[name path=the_line_under_FG] ($(F)!0.25cm!-90:(G)$) -- ($(G)!0.25cm!90:(F)$);
\coordinate[name intersections={of=the_middle_line and the_line_under_FG, by=center_for_brace}];
\draw[green, decorate,decoration={brace,raise=2.5pt,amplitude=5pt,mirror}] let \p1=(F), \p2=(G), \n1={veclen((\x2-\x1), (\y2-\y1))} in
($(center_for_brace) +({-1*(0.5*\n1)},0) +(0,7.5pt)$) -- ($(center_for_brace) +({0.5*\n1},0) +(0,7.5pt)$);
%
\path[name path=path_for_label_for_e] ($(F)!0.35cm!-90:(G)$) -- ($(G)!0.35cm!90:(F)$);
\coordinate[name intersections={of=path_for_label_for_e and the_middle_line, by=label_for_e}];
\draw let \p1=($($(A)!0.5!(B)$)-($(C)!0.5!(D)$)$), \n1={atan(\y1/\x1)} in node[anchor=\n1, inner sep=0, font=\footnotesize] at (label_for_e){$e$};
\end{tikzpicture}
\end{document}