我在 tikz 中绘制了一个简单的力图。放置在弧上的节点背景已填充;这适用于我的三个弧中的两个。第一个确实显示了彩色背景,但它位于弧后面,因此弧会显示出来。当我重新排列命令的顺序时,仍然是第一个执行的命令具有“错误”的背景。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc, arrows}
\begin{document}
\Large
\thispagestyle{empty}
\centering
\tikz[scale=1.5]{
\coordinate (C) at (0,0);
\fill[black] (C) circle (4pt) node[above, outer sep=3mm] {$C$};
\draw[very thick,->, >=stealth] (C) -- (180:3) node[above] {$BC$ (known)};
\draw[very thick,->, >=stealth] (C) -- (216.8:3) node[below] {$CG$ (known)};
\draw[very thick,->, >=stealth] (C) -- (-90:3) node[below] {$CF$ (known)};
\draw[very thick,->, >=stealth] (C) -- (-58:3) node[below] {$CE$};
\draw[very thick,->, >=stealth] (C) -- (26.6:3) node[above] {$CD$ };
\draw[very thick, dashed] (C) -- (-0:3);
\draw[thick, <->, >=stealth] ($ (C)+(2,0) $)arc (0:-58:2) node[fill = pink, inner sep = 0.125em] at ($ (C)+(199:2) $) {$\theta$ (known)};
\draw[thick, <->, >=stealth] ($ (C)+(2,0) $)arc (0:26.6:2) node[fill=pink, inner sep = 0.125em] at ($ (C)+(10:2) $) {$\alpha$ (known)};
\draw[thick, <->, >=stealth] ($ (C)+(-2,0) $)arc (180:216.8:2) node[fill=pink, inner sep = 0.125em] at ($ (C)+(335:2) $) {$\phi$ (known)};
}
\end{document}
有人能看出我哪里错了吗?
谢谢,戴夫
答案1
您绘制了标签$\theta$ (known)
(在最后一行之前的第三行),然后绘制了弧线(最后一行)。因此,标签的顺序应固定如下(请注意,我将其\theta
与互换\phi
,以保持绘制弧线然后在顶部绘制标签的正确顺序):
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc, arrows}
\begin{document}
\Large
\thispagestyle{empty}
\centering
\tikz[scale=1.5,>=stealth]{
\coordinate (C) at (0,0);
\fill (C) circle (4pt) node[above, outer sep=3mm] {$C$};
\draw[very thick,->] (C) -- (180:3) node[above] {$BC$ (known)};
\draw[very thick,->] (C) -- (216.8:3) node[below] {$CG$ (known)};
\draw[very thick,->] (C) -- (-90:3) node[below] {$CF$ (known)};
\draw[very thick,->] (C) -- (-58:3) node[below] {$CE$};
\draw[very thick,->] (C) -- (26.6:3) node[above] {$CD$ };
\draw[very thick, dashed] (C) -- (-0:3);
\draw[thick, <->] ($(C)+(2,0) $) arc (0:-58:2) node[fill=pink, inner sep = 0.125em] at ($ (C)+(335:2)$){$\phi$ (known)};
\draw[thick, <->] ($(C)+(2,0) $) arc (0:26.6:2) node[fill=pink, inner sep = 0.125em] at ($ (C)+(10:2) $){$\alpha$ (known)};
\draw[thick, <->] ($(C)+(-2,0)$) arc (180:216.8:2) node[fill=pink, inner sep = 0.125em] at ($ (C)+(199:2)$){$\theta$ (known)};
}
\end{document}
答案2
这里不需要计算节点的位置。你可以简单地通过添加到节点选项中midway
沿弧线添加它们。midway
您还可以通过合理使用范围来避免连续重复样式选项,从而使代码更加灵活且更易于理解。
例如,
\documentclass[border=10pt,multi,tikz,dvipsnames]{standalone}
\usetikzlibrary{calc,arrows.meta}
\begin{document}
\tikz[scale=1.5,>=Stealth]{
\coordinate (C) at (0,0);
\fill (C) circle (4pt) node[above, outer sep=3mm] {$C$};
\begin{scope}[very thick, ->]
\draw (C) -- (180:3) node[above] {$BC$ (known)};
\draw (C) -- (216.8:3) node[below] {$CG$ (known)};
\draw (C) -- (-90:3) node[below] {$CF$ (known)};
\draw (C) -- (-58:3) node[below] {$CE$};
\draw (C) -- (26.6:3) node[above] {$CD$ };
\end{scope}
\draw[very thick, dashed] (C) -- (-0:3);
\begin{scope}[thick, <->, every node/.style={midway, fill=pink, inner sep = 0.125em}]
\draw ($(C)+(2,0) $) arc (0:-58:2) node {$\phi$ (known)};
\draw ($(C)+(2,0) $) arc (0:26.6:2) node {$\alpha$ (known)};
\draw ($(C)+(-2,0)$) arc (180:216.8:2) node {$\theta$ (known)};
\end{scope}
}
\end{document}
如果你愿意,你也可以让它更简洁。然而,这可能会使代码更难理解,而不是更容易理解。
例如,以下是等效的。
\documentclass[border=10pt,multi,tikz,dvipsnames]{standalone}
\usetikzlibrary{calc,arrows.meta}
\begin{document}
\tikz[scale=1.5,>=Stealth]{
\draw [very thick, ->, fill] (0,0) coordinate (C) circle (4pt) node[above, outer sep=3mm] {$C$} (C) foreach \i/\j/\k in {180:3/above/{$BC$ (known)},216.8:3/below/{$CG$ (known)},-90:3/below/{$CF$ (known)},-58:3/below/{$CE$},26.6:3/above/{$CD$}} { edge node [\j, at end] {\k} (\i) };
\draw[very thick, dashed] (C) -- (-0:3);
\foreach \i/\j/\k in {+/0:-58:2/\phi,+/0:26.6:2/\alpha,-/180:216.8:2/\theta}
\draw [thick, <->] ($(C)+(\i 2,0)$) arc (\j) node [midway, fill=pink, inner sep = 0.125em] {$\k$ (known)};
}
\end{document}