2

I have the following diagram:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
  \newcommand\rad{.75}
  \foreach \a/\r in {60/0, 0/3, 120/3, 240/3}{
    \begin{scope}[shift={(\a:\r*\rad)}]
      \draw(60+\a:\rad)  node (A\a) {} circle (.5mm) [fill];
      \draw(180+\a:\rad) node (B\a) {} circle (.5mm) [fill];
      \draw(300+\a:\rad) node (C\a) {} circle (.5mm) [fill];
    \end{scope}
  }
  \path[blue, thick, <->]
  (A60)  edge (B120)
  (B60)  edge (B240)
  (C60)  edge (B0)
  (A0)   edge [bend right] (C120)
  (A120) edge [bend right] (C240)
  (A240) edge [bend right] (C0);
\end{tikzpicture}
\end{document}

Output

I want the blue edges to all have a strike-through, so I modified it with decorations:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
  \newcommand\rad{.75}
  \foreach \a/\r in {60/0, 0/3, 120/3, 240/3}{
    \begin{scope}[shift={(\a:\r*\rad)}]
      \draw(60+\a:\rad)  node (A\a) {} circle (.5mm) [fill];
      \draw(180+\a:\rad) node (B\a) {} circle (.5mm) [fill];
      \draw(300+\a:\rad) node (C\a) {} circle (.5mm) [fill];
    \end{scope}
  }
  \path[blue, thick, <->, decoration={markings,mark=at position 0.5 with {\arrow{|}}}]
  (A60)  edge [decorate] (B120)
  (B60)  edge [decorate] (B240)
  (C60)  edge [decorate] (B0)
  (A0)   edge [decorate, bend right] (C120)
  (A120) edge [decorate, bend right] (C240)
  (A240) edge [decorate, bend right] (C0);
\end{tikzpicture}
\end{document}

Broken output

Obviously I did something wrong here. The edges themselves disappear and the arrow tips are off. The one on the source side is gone and the other one has very weird positioning.

I tried a few other arrow types other than |, and tried only decorating some of the edges:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
  \newcommand\rad{.75}
  \foreach \a/\r in {60/0, 0/3, 120/3, 240/3}{
    \begin{scope}[shift={(\a:\r*\rad)}]
      \draw(60+\a:\rad)  node (A\a) {} circle (.5mm) [fill];
      \draw(180+\a:\rad) node (B\a) {} circle (.5mm) [fill];
      \draw(300+\a:\rad) node (C\a) {} circle (.5mm) [fill];
    \end{scope}
  }
  \path[blue, thick, <->, decoration={markings,mark=at position 0.5 with {\arrow{><}}}]
  (A60)  edge [decorate] (B120)
  (B60)  edge [decorate] (B240)
  (C60)  edge (B0)
  (A0)   edge [bend right] (C120)
  (A120) edge [bend right] (C240)
  (A240) edge [decorate, bend right] (C0);
\end{tikzpicture}
\end{document}

More broken output

So it seems that decorating with this causes the issue. However I see pretty similar code in places like here and here.

What have I done wrong here? How do I fix my decorations?

1 Answers1

2

The manual states

The decoration destroys the input path (except in certain cases, detailed later), which means that it uses the path for determining positions on the path, but after the decoration is done this path is gone. You typically need to use a postaction to add markings.

(The certain case is the mark connection node decoration.)

Replace the decorates with postaction=decorateand you'll get what you're after, I hope.

The | is not perfectly centered because it's supposed to only touch the point. Similar things happen if you ask for \arrow{><} because the (reverse) tip of < is put at position 0.5 and not some middle.

If you want all edges to be decorated use the every edge style:

\path[…, decoration = {…}, every edge/.append style={postaction=decorate}] …;

I haven't added the arrows.meta library in the code even though the old arrows are deprecated but the problem and the solution is the same.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
  \newcommand\rad{.75}
  \foreach \a/\r in {60/0, 0/3, 120/3, 240/3}{
    \begin{scope}[shift={(\a:\r*\rad)}]
      \draw(60+\a:\rad)  node (A\a) {} circle (.5mm) [fill];
      \draw(180+\a:\rad) node (B\a) {} circle (.5mm) [fill];
      \draw(300+\a:\rad) node (C\a) {} circle (.5mm) [fill];
    \end{scope}
  }
  \path[blue, thick, <->, decoration={markings,mark=at position 0.5 with {\arrow{|}}}]
  (A60)  edge [postaction=decorate] (B120)
  (B60)  edge [postaction=decorate] (B240)
  (C60)  edge (B0)
  (A0)   edge [bend right] (C120)
  (A120) edge [bend right] (C240)
  (A240) edge [postaction=decorate, bend right] (C0);
\end{tikzpicture}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821