裝潢導致線條消失

裝潢導致線條消失

我有以下圖表:

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

輸出損壞

顯然我在這裡做錯了什麼。邊緣本身消失且箭頭尖端消失。源端的那個已經消失了,另一個的位置也很奇怪。

我嘗試了除 之外的其他幾種箭頭類型|,並嘗試僅裝飾一些邊緣:

\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

手動狀態

裝飾會破壞輸入路徑(某些情況除外,稍後詳述),這意味著它使用該路徑來確定路徑上的位置,但裝飾完成後該路徑就消失了。您通常需要使用 apostaction來新增標記。

(特定情況為裝飾mark connection node。)

我希望將 s替換decoratepostaction=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}

輸出

在此輸入影像描述

相關內容