I would like to use the double -latex
arrow style in a whole scope.
When I define a simple style myarrow plain
which only sets red color the scope style is applied in \begin{scope}[myarrow plain] \draw ... \end{scope}
and I don't have to say \draw[myarrow plain]
: plain explicit and plain scope in the image.
For myarrow complex
style, which entails double -latex
, the scope only changes foreground color (complex scope below) and I have to say \draw[myarrow complex]
to have the double arrow (complex explicit).
Can I get an explanation how to declare the myarrow complex
style correcetly so that the scope uses it? I am guessing it has to do with postaction, or appending vs. defining to style, but I know too little about TikZ internals (so far).
\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
% https://tex.stackexchange.com/a/72793
\tikzset{
double -latex/.style args={#1 colored by #2 and #3}{
-latex,line width=#1,#2,
postaction={draw,-latex,#3,line width=(#1)/3,shorten <=(#1)/4,shorten >=4.5*(#1)/3},
}
}
\tikzset{
myarrow complex/.style={line width=2mm,double -latex=2mm colored by brown and red},
myarrow plain/.style={-latex,color=red}
}
\begin{document}
\begin{tikzpicture}
\begin{scope}[myarrow complex]
\draw (0,1) to node[pos=.5,below]{complex scope} (4,1);
\draw[myarrow complex] (0,0) to node[pos=.5,below]{complex explicit} (4,0);
\end{scope}
\begin{scope}[myarrow plain]
\draw[myarrow plain] (0,3) to node[pos=.5,below]{plain explicit} (4,3);
\draw (0,2) to node[pos=.5,below]{plain scope} (4,2);
\end{scope}
\end{tikzpicture}
\end{document}