4

I have a simple force drawing in tikz. Nodes placed on arcs have background filled; this is working on two of my three arcs. The first does show a colored background but it is behind the arc so the arc shows through. When I rearrange the order of the commands, it is still the first command executed that has the 'faulty' background.

\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}

Can anyone see where I'm going wrong?

Thanks, Dave

2 Answers 2

4

You drew the label $\theta$ (known) (on the third line before the last one) before its arc which is at the last line. So, the order of labels should be fixed as follows (note that I exchanged \theta with \phi to keep the correct order of drawing the arc then its label on top):

\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}

enter image description here

0
4

There is no need to calculate the positions for the nodes here. You can simply add them midway along the arc by adding midway to the node options.

You can also make the code more flexible and easier to understand by judicious use of scopes to avoid repeating style options for consecutive.

For example,

\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}

auto-placed nodes on arcs

If you wished, you could also make this more concise. However, this may make the code more difficult to understand rather than easier.

For example, the following is equivalent.

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .