I need to embed a (complex) TikZ picture in a command in order to reuse it in several scales and colors. No problems when scaling, but I cannot change the color of the image (see image below for MWE output).
MWE:
\documentclass{article}
\usepackage{tikz}
\tikzset{mystyle/.style={fill=#1}, mystyle/.default=black}
\newcommand{\aaa}{
\begin{scope}
\path[mystyle] (0,0) -- (1,0) -- (0,1) -- cycle;
\end{scope}
}
\newcommand{\bbb}{
\begin{scope}[mystyle=blue]
\path[mystyle] (0,0) -- (1,0) -- (0,1) -- cycle;
\end{scope}
}
\begin{document}
\begin{tabular}{rl}
Black triangle:&
\begin{tikzpicture}
\aaa
\end{tikzpicture}
\\
Red triangle:&
\begin{tikzpicture}[mystyle=red]
\aaa
\end{tikzpicture}
\\
Red triangle:&
\begin{tikzpicture}
\begin{scope}[mystyle=red]
\aaa
\end{scope}
\end{tikzpicture}
\\
Blue triangle:&
\begin{tikzpicture}
\bbb
\end{tikzpicture}
\\
Red triangle:&
\begin{tikzpicture}[mystyle=red]
\bbb
\end{tikzpicture}
\\
Red triangle:&
\begin{tikzpicture}
\begin{scope}[mystyle=red]
\bbb
\end{scope}
\end{tikzpicture}
\end{tabular}
\end{document}



\newcommand{aaa}[1][black]{\begin{scope}\path[mystyle=#1](0,0)...\end{scope}}. Then\aaaor\aaa[red], ... – Ignasi Oct 19 '15 at 16:53mystyle/.default=blacksays 'whenevermystyleis called with no argument, useblack'. So you setmystyle=bluefor the scope, but then you override that value withmystyle=mystyle=blackfor the\path. – cfr Oct 19 '15 at 22:21pic? – Philipp Imhof Oct 20 '15 at 08:33