[Tex/LaTex] How to decorate a \pic path

decorationstikz-pgf

Consider the following example using the angles library and a pic path to mark an angle:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{angles,decorations.markings}

\begin{document}

\begin{tikzpicture}[
  >=latex,
  decoration={
  markings,
  mark= at position 0.5 with
    {
      \arrow{<}
    }
  }
]

\draw 
  (2,1) coordinate (A) node[label={right:$A$}] {} --
  (0,0) coordinate (B) node[label={left:$B$}] {} --
  (2,-1) coordinate (C) node[label={right:$C$}] {}
  pic[->,draw=red,angle radius=1cm] {angle={C--B--A}}; 
\draw[<-] (3,1) -- (3,-1);   

% The problem is here; pic doesn't seem to obey the decoration
\begin{scope}[yshift=-3cm]
\draw 
  (2,1) coordinate (A) node[label={right:$A$}] {} --
  (0,0) coordinate (B) node[label={left:$B$}] {} --
  (2,-1) coordinate (C) node[label={right:$C$}] {}
  pic[draw=red,angle radius=1cm,postaction=decorate] {angle={C--B--A}};
\draw[postaction=decorate] (3,1) -- (3,-1);   
\end{scope}

\end{tikzpicture}

\end{document}

The result is:

enter image description here

The image on top shows an angle marked using a red arc with an arrow in one end; in the image on the bottom I tried to use a decoration to add the arrow in the middle of the arc, but the postaction=decorate option was ignored; the straight lines to the right are not relevant and are only there for comparison: a simple \draw path obeys the decoration.

What's the proper way to use a decoration for an arc created using the angle pic?

Best Answer

This went a little too deep than I initially intended to. I can't see how to wrap up the required changes in a coherent patch-y way so I propose to add the postaction=decorate to another location instead of the obvious place that you found out that it won't work.

So if we add

\tikzset{mydeco/.style={pic actions/.append code=\tikzset{postaction=decorate}}}

you would get a handle on controlling the decoration boolean at the right place within \tikz@finish. Otherwise it will always decorate.

\documentclass[tikz,border=10mm]{standalone}
\usetikzlibrary{angles,decorations.markings}

\tikzset{mydeco/.style={pic actions/.append code=\tikzset{postaction=decorate}}}
\begin{document}
\begin{tikzpicture}[
  >=latex,
  decoration={
  markings,
  mark= at position 0.5 with
    {
      \arrow{<}
    }
  }
]

\draw 
  (2,1) coordinate (A) node[label={right:$A$}] {} --
  (0,0) coordinate (B) node[label={left:$B$}] {} --
  (2,-1) coordinate (C) node[label={right:$C$}] {}
  pic[mydeco,draw=red,fill=yellow,angle radius=1cm,pic text=$A$] {angle={C--B--A}};

\end{tikzpicture}
\end{document}

enter image description here