# How to decorate a \pic path?

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$}] {}
\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$}] {}
\draw[postaction=decorate] (3,1) -- (3,-1);
\end{scope}

\end{tikzpicture}

\end{document}

The result is:

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?

-
I used the same code and I got the same result ! – Alain Matthes Mar 14 at 6:50

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.

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

-
By the way, I would consider this as a bug since it can fail in other ways too. – percusse Aug 1 '14 at 14:26
I used the code given in the doc and I noticed that it is necessary to use a good order for arguments to get a correct result – Alain Matthes Mar 14 at 6:54

There are two paths used by the angle pic: one to fill the background of the angle and one to draw the arc. And if a pic text is given an additional node will be placed inside the angle. But only the arc path should be decorated.

The arc is drawn by the command \tikz@lib@angle@foreground (see the tikzlibraryangles.code.tex file):

\def\tikz@lib@angle@foreground#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, fill=none, shade=none]
....
}

You can patch this command using the etoolbox package to add the style myarc as a hook. Then you can pass the decoration to this new style:

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

\tikzset{
myarc/.style={},
myarc style/.style={myarc/.append style={#1}}}

\usepackage{etoolbox}
\makeatletter
\makeatother

\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$}] {}
\draw[<-] (3,1) -- (3,-1);

\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$}] {}