Decora el contorno con flechas en diferentes direcciones.

Decora el contorno con flechas en diferentes direcciones.

EnesteEn el post se explica detalladamente cómo decorar un contorno con flechas. ¿Cómo puedo hacer lo mismo, pero para que un contorno tenga flechas en una dirección y el otro contorno tenga flechas en la contraria? Los contornos están en el mismo tikzpictureentorno. ¿Es posible definir múltiples instancias de decoraciones, tal vez?

Respuesta1

Puede definir varias marcas y puede invertir dibujando el trazado en dirección inversa o definiendo la marca con flechas invertidas.

ingrese la descripción de la imagen aquí

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

información relacionada