Decore o contorno com setas em diferentes direções

Decore o contorno com setas em diferentes direções

Emessepost é explicado detalhadamente como decorar um contorno com setas. Como posso fazer o mesmo, mas de forma que um contorno tenha setas em uma direção e o outro contorno tenha setas na direção oposta? Os contornos estão no mesmo tikzpictureambiente. É possível definir múltiplas instâncias de decoração, talvez?

Responder1

Você pode definir múltiplas marcações e reverter desenhando o caminho na direção inversa ou definindo a marcação com setas invertidas.

insira a descrição da imagem aqui

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

informação relacionada