装飾により線が消える

装飾により線が消える

次の図があります:

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

出力

青いエッジにすべて取り消し線を付けたいので、装飾で修正しました。

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

壊れた出力

明らかに、私はここで何か間違ったことをしました。エッジ自体が消え、矢印の先端がずれています。ソース側のものは消え、もう 1 つは非常に奇妙な位置にあります。

以外の矢印タイプをいくつか試し|、エッジの一部のみを装飾してみました。

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

壊れた出力が増える

どうやら、これを使って装飾すると問題が発生するようです。しかし、次のような場所にも似たようなコードがあります。ここそしてここ

ここで何を間違えたのでしょうか? 装飾を修正するにはどうすればいいでしょうか?

答え1

マニュアルの状態

デコレーションは入力パスを破壊します (特定のケースを除く。詳細は後述)。つまり、パス上の位置を決定するためにパスが使用されますが、デコレーションが完了するとこのパスはなくなります。通常、postactionマークを追加するには を使用する必要があります。

(あるケースは装飾ですmark connection node。)

decorates を に置き換えるpostaction=decorateと、目的の結果が得られると思います。

|完全に中心に配置されていないため、それは要点に触れるだけのはずだを要求した場合も同様のことが起こります。これは、\arrow{><}の (逆) 先端<が中間ではなく位置 0.5 に配置されるためです。

すべてのエッジを装飾したい場合は、次のevery edgeスタイルを使用します。

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

私は追加していませんarrows.meta図書館コードでは古い矢印は非推奨になっていますが、問題と解決策は同じです。

コード

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

出力

ここに画像の説明を入力してください

関連情報