以下代码用于描述三条平行线k
、\ell
和m
以及两条遍历s
和。 、和的t
交点分别称为、和。 (这些点的标签未显示。)我已将线段的长度标记为 ,并将处的线段长度标记为。k
\ell
m
s
A
B
C
AB
x + 5
BC
4x + 5
我想要进行两项修改。首先,我希望标签x + 5
和与4x + 5
它们下方的线之间的距离是它们上方的线之间的距离的一半。(水平线“堆叠”在k
顶部和m
底部。因此,点A
、B
和C
堆叠在A
顶部和C
底部。)其次,我希望和的节点x + 5
排版4x + 5
方向与线k
、\ell
和相同m
。例如,这是我用来排版的命令4x + 5
。我还绘制了一条绿线来说明我想要的节点位置。它说明了节点放置的轻微错误。
\node[anchor=15, inner sep=0, rotate=15, font=\footnotesize] at ($($(B)!{2/3}!(C)$) +(195:0.3)$){$4x+5$};
\draw[line width=0.2pt, green] ($(B)!{2/3}!(C)$) -- ($($(B)!{2/3}!(C)$) +({195}:2)$);
所有四个node
命令都位于代码的末尾。
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes,decorations.markings,decorations.pathreplacing,}
\begin{document}
\begin{tikzpicture}
%Three parallel lines k, \ell, and m are drawn. Two traversals s and t are to be drawn.
%The ratios of the lengths of the line segments along the traversals between k and \ell
%to the lengths of the line segments along the traversals between \ell and m is to be
%3 to 2.
%
%A, B, and C are points on t; C is a point on line m, B is a point on line ell, and A is
%a point on line k. P, Q, and R are points on s; R is a point on line m, Q is a point
%on line ell, and P is a point on line k. The length of line segment AB is 6, and the
%length of line segment BC is 9. To maintain the same ratio between corresponding points
%on line s, a circle of radius 6 about R is drawn and one of the intersections with line
%ell is labeled Q, and a circle of radius 4 about Q is drawn and one of the intersections
%with line k is labeled P.
\path[name path=line_m] (0,0) -- (15:15);
\coordinate (C) at (15:5);
\coordinate (R) at (15:12);
\coordinate (B) at ($(C) +(50:2.25)$);
\path[name path=line_ell, latex-latex] ($(B) +(195:3)$) -- ($(B) +(15:12)$);
\path[name path=circular_arc_to_locate_Q] (R) circle (1.5);
\coordinate[name intersections={of=line_ell and circular_arc_to_locate_Q}];
\coordinate (Q) at (intersection-2);
\coordinate (A) at ($(B) +(50:1.5)$);
\path[name path=line_k, latex-latex] ($(A) +(195:3)$) -- ($(A) +(15:9)$);
\path[name path=circular_arc_to_locate_P] (Q) circle (1);
\coordinate[name intersections={of=line_k and circular_arc_to_locate_P}];
\coordinate (P) at (intersection-2);
\draw[latex-latex] ($(C) +(195:3)$) -- ($(R) +(15:2)$);
\node[anchor=195, inner sep=0] at ($(R) +(15:2) +(15:0.15)$){$m$};
\draw[latex-latex] ($(B) +(195:3)$) -- ($(Q) +(15:2)$);
\node[anchor=195, inner sep=0] at ($(Q) +(15:2) +(15:0.15)$){$\ell$};
\draw[latex-latex] ($(A) +(195:3)$) -- ($(P) +(15:2)$);
\node[anchor=195, inner sep=0] at ($(P) +(15:2) +(15:0.15)$){$k$};
%Traversals s and t are drawn. Invisible lines parallel to k, \ell, and m
%that pass through the arrowheads of s are used to bound t.
\draw[name path=path_for_traversal_t, latex-latex] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(R) +(\n1:1)$) -- ($(P) +({\n1-180}:1)$);
\draw let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-180}, inner sep=0] at ($($(R) +(\n1:1)$) +(\n1:0.15)$){$t$};
\path[name path=path_for_traversal_s] ($(C) +(-130:2)$) -- ($(A) + (50:2)$);
\path[name path=path_for_the_lower_arrowhead_of_s] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(R) +(\n1:1)$) -- ($(R) +(\n1:1) +(195:11)$);
\path[name path=path_for_the_upper_arrowhead_of_s] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(P) +({\n1-180}:1)$) -- ($(P) +({\n1-180}:1) +(195:7)$);
\coordinate[name intersections={of=path_for_traversal_s and path_for_the_lower_arrowhead_of_s, by={lower_arrowhead_for_s}}];
\coordinate[name intersections={of=path_for_traversal_s and path_for_the_upper_arrowhead_of_s, by={upper_arrowhead_for_s}}];
\draw[latex-latex] (lower_arrowhead_for_s) -- (upper_arrowhead_for_s);
\draw let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in node[anchor=50, inner sep=0] at ($(lower_arrowhead_for_s) +(-130:0.15)$){$s$};
%The lengths of the line segments on the traversals between the parallel lines are typeset.
\node[anchor=15, inner sep=0, rotate=15, font=\footnotesize] at ($($(A)!0.5!(B)$) +(195:0.3)$){$x+5$};
\draw[line width=0.2pt, green] ($(A)!0.5!(B)$) -- ($($(A)!0.5!(B)$) +({195}:2)$);
\node[anchor=15, inner sep=0, rotate=15, font=\footnotesize] at ($($(B)!0.5!(C)$) +(195:0.3)$){$4x+5$};
\draw[line width=0.2pt, green] ($(B)!0.5!(C)$) -- ($($(B)!0.5!(C)$) +({195}:2)$);
\draw node[anchor=195, inner sep=0, rotate=15, font=\footnotesize] at ($($(P)!0.5!(Q)$) +(15:0.3)$){$4$};
\draw[line width=0.2pt, green] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(P)!0.5!(Q)$) -- ($($(P)!0.5!(Q)$) +(15:2)$);
\draw node[anchor=195, inner sep=0, rotate=15, font=\footnotesize] at ($($(Q)!0.5!(R)$) +(15:0.3)$){$6$};
\draw[line width=0.2pt, green] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(Q)!0.5!(R)$) -- ($($(Q)!0.5!(R)$) +(15:2)$);
\end{tikzpicture}
\end{document}
答案1
像这样吗?
[已编辑,使用 1/3 而不是 1/2,因为我最初误读了问题中的要求。]
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usetikzlibrary{calc,positioning,intersections,quotes,decorations.markings,decorations.pathreplacing,}
\begin{document}
\begin{tikzpicture}
%Three parallel lines k, \ell, and m are drawn. Two traversals s and t are to be drawn.
%The ratios of the lengths of the line segments along the traversals between k and \ell
%to the lengths of the line segments along the traversals between \ell and m is to be
%3 to 2.
%
%A, B, and C are points on t; C is a point on line m, B is a point on line ell, and A is
%a point on line k. P, Q, and R are points on s; R is a point on line m, Q is a point
%on line ell, and P is a point on line k. The length of line segment AB is 6, and the
%length of line segment BC is 9. To maintain the same ratio between corresponding points
%on line s, a circle of radius 6 about R is drawn and one of the intersections with line
%ell is labeled Q, and a circle of radius 4 about Q is drawn and one of the intersections
%with line k is labeled P.
\path[name path=line_m] (0,0) -- (15:15);
\coordinate (C) at (15:5);
\coordinate (R) at (15:12);
\coordinate (B) at ($(C) +(50:2.25)$);
\path[name path=line_ell, latex-latex] ($(B) +(195:3)$) -- ($(B) +(15:12)$);
\path[name path=circular_arc_to_locate_Q] (R) circle (1.5);
\coordinate[name intersections={of=line_ell and circular_arc_to_locate_Q}];
\coordinate (Q) at (intersection-2);
\coordinate (A) at ($(B) +(50:1.5)$);
\path[name path=line_k, latex-latex] ($(A) +(195:3)$) -- ($(A) +(15:9)$);
\path[name path=circular_arc_to_locate_P] (Q) circle (1);
\coordinate[name intersections={of=line_k and circular_arc_to_locate_P}];
\coordinate (P) at (intersection-2);
\draw[latex-latex] ($(C) +(195:3)$) coordinate (c) -- ($(R) +(15:2)$) coordinate (r);
\node[anchor=195, inner sep=0] at ($(R) +(15:2) +(15:0.15)$){$m$};
\draw[latex-latex] ($(B) +(195:3)$) coordinate (b) -- ($(Q) +(15:2)$) coordinate (q);
\node[anchor=195, inner sep=0] at ($(Q) +(15:2) +(15:0.15)$){$\ell$};
\draw[latex-latex] ($(A) +(195:3)$) coordinate (a) -- ($(P) +(15:2)$) coordinate (p);
\node[anchor=195, inner sep=0] at ($(P) +(15:2) +(15:0.15)$){$k$};
%Traversals s and t are drawn. Invisible lines parallel to k, \ell, and m
%that pass through the arrowheads of s are used to bound t.
\draw[name path=path_for_traversal_t, latex-latex] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(R) +(\n1:1)$) -- ($(P) +({\n1-180}:1)$);
\draw let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-180}, inner sep=0] at ($($(R) +(\n1:1)$) +(\n1:0.15)$){$t$};
\path[name path=path_for_traversal_s] ($(C) +(-130:2)$) -- ($(A) + (50:2)$);
\path[name path=path_for_the_lower_arrowhead_of_s] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(R) +(\n1:1)$) -- ($(R) +(\n1:1) +(195:11)$);
\path[name path=path_for_the_upper_arrowhead_of_s] let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in ($(P) +({\n1-180}:1)$) -- ($(P) +({\n1-180}:1) +(195:7)$);
\coordinate[name intersections={of=path_for_traversal_s and path_for_the_lower_arrowhead_of_s, by={lower_arrowhead_for_s}}];
\coordinate[name intersections={of=path_for_traversal_s and path_for_the_upper_arrowhead_of_s, by={upper_arrowhead_for_s}}];
\draw[latex-latex] (lower_arrowhead_for_s) -- (upper_arrowhead_for_s);
\draw let \p1=($(P)-(R)$), \n1={atan(\y1/\x1)} in node[anchor=50, inner sep=0] at ($(lower_arrowhead_for_s) +(-130:0.15)$){$s$};
% \foreach \i in {A,B,C,P,Q,R,a,b,c,r,q,p} \node at (\i) {\i};
%The lengths of the line segments on the traversals between the parallel lines are typeset.
\draw node[inner sep=0] at ($($(P)!0.3!90:(Q)$)!{2/3}!($(Q)!0.3!-90:(P)$)$) {$4$};
\draw node[inner sep=0] at ($($(Q)!0.3!90:(R)$)!{2/3}!($(R)!0.3!-90:(Q)$)$) {$6$};
\path ($(a)!2/3!(b)$) -- ($(p)!2/3!(q)$) node [pos=.25, sloped] {$x+5$};
\path ($(b)!2/3!(c)$) -- ($(q)!2/3!(r)$) node [pos=.2, sloped] {$4x+5$};
\end{tikzpicture}
\end{document}
请注意,如果您确实希望标签位于绿线中心,则应该使用1/2
而不是2/3
:
\path ($(a)!.5!(b)$) -- ($(p)!.5!(q)$) node [pos=.25, sloped] {$x+5$};
\path ($(b)!.5!(c)$) -- ($(q)!.5!(r)$) node [pos=.2, sloped] {$4x+5$};
\draw[line width=0.2pt, green] ($(B)!0.5!(C)$) -- ($($(B)!0.5!(C)$) +({195}:2)$);
或者,您可以旋转节点,但这似乎更容易。如果您想使用这个,您只需rotate=<angle>
在节点的选项中使用即可。例如:
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \i [count=\j] in {0,30,60,...,330}
\node [rotate=\i, draw] at (2*\j,0) {angle \i};
\end{tikzpicture}
\end{document}