다양한 방향의 화살표로 윤곽선 장식

다양한 방향의 화살표로 윤곽선 장식

~ 안에이것포스트에 화살표로 윤곽선을 장식하는 방법이 자세히 설명되어 있습니다. 한 윤곽선에는 한 방향의 화살표가 있고 다른 윤곽선에는 반대 방향의 화살표가 있도록 하려면 어떻게 해야 합니까? 윤곽선은 동일한 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}

관련 정보