さまざまな方向の矢印で輪郭を装飾する

さまざまな方向の矢印で輪郭を装飾する

これ矢印で輪郭を装飾する方法が詳しく説明されています。 同じことを、一方の輪郭に一方向の矢印を付け、もう一方の輪郭に反対方向の矢印を付けて行うにはどうすればよいでしょうか。 輪郭は同じtikzpicture環境にあります。 おそらく、装飾の複数のインスタンスを定義することは可能でしょうか。

答え1

複数のマーキングを定義することができ、逆方向にパスを描画するか、逆矢印でマーキングを定義することで反転することができます。

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

\documentclass[border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset
  {marking1/.style=
     {decoration=
        {markings,
         mark=at position 0.5 with {\arrow[line width=1pt]{>}}
        },
      postaction=decorate
     },
   marking1reversed/.style=
     {decoration=
        {markings,
         mark=at position 0.5 with {\arrow[line width=1pt]{<}}
        },
      postaction=decorate
     },
   marking2/.style=
     {decoration=
        {markings,
         mark=at position 0.33 with {\arrow[line width=1pt]{stealth}},
         mark=at position 0.66 with {\arrow[line width=1pt,xscale=-1]{stealth}}
        },
      postaction=decorate
     }
  }
\begin{document}
\begin{tikzpicture}
  % a path with three sections
  \draw[marking1] (0,0) -- (2,0);
  \draw[marking1] (2,0) -- (1,1);
  \draw[marking1] (1,1) -- (0,0);
  % path drawn in the opposite direction, with the same marking
  \begin{scope}[xshift=3cm]
    \draw[marking1] (0,0) -- (1,1);
    \draw[marking1] (1,1) -- (2,0);
    \draw[marking1] (2,0) -- (0,0);
  \end{scope}
  % the original path, but with another marking that reverses the arrows
  \begin{scope}[xshift=6cm]
    \draw[marking1reversed] (0,0) -- (2,0);
    \draw[marking1reversed] (2,0) -- (1,1);
    \draw[marking1reversed] (1,1) -- (0,0);
  \end{scope}
  % the original path with a completely different marking
  \begin{scope}[xshift=9cm]
    \draw[marking2] (0,0) -- (2,0);
    \draw[marking2] (2,0) -- (1,1);
    \draw[marking2] (1,1) -- (0,0);
  \end{scope}
\end{tikzpicture}
\end{document}

関連情報