# Several arguments in tikzset pic

I want to pass more than one argument to a pic defined with \tikzset.

I tried this and it works:

\tikzset{
Piece/.pic={
\draw (0:1) -- (120:1) -- (240:1) -- cycle;
\draw (0,0) node {$\Gamma_#1$};
}
};

\pic {Piece={k}};


I get the following image:

But what I really need is to have two subscripts, as in this one:

However, no matter what I write in the \pic command, it is treated as a string and associated to the #1 argument. I would like something like:

\tikzset{
Piece/.pic={
\draw (0:1) -- (120:1) -- (240:1) -- cycle;
\draw (0,0) node {$\Gamma_{#1,#2}$};
}
};

\pic {Piece={k,r}};


But this does not work.

How can I specify two different and independent arguments?

• – esdd
May 25 '16 at 15:09

You can switch to the alternative definition of the pic style family such that style 2 args or style n args, style args stuff from the regular pgfkeys syntax can be used for arguments.

\documentclass[tikz]{standalone}
\tikzset{
pics/Piece/.style n args={3}{
code = { %
\draw (0:1) -- (120:1) -- (240:1) -- cycle;
\draw (0,0) node[#2,#3] {$\Gamma_{#1}$};
}
}
}
\begin{document}
\begin{tikzpicture}
\pic {Piece={k}{draw=red}{fill=red!10}};
\end{tikzpicture}
\end{document}


• Ah, this is what he meant? :| May 25 '16 at 15:07
• Yes, this is what I meant. However, I tried this and for some reason it works for 2 parameters but not for 3. May 25 '16 at 15:16
• @AitorPérezPérez See the update May 25 '16 at 15:20
• Yes, that works. I changed the 2 to a 3, but I did not write "n args={3}", I don't know why "2 args" works but "3 args" does not. Thank you very much! May 25 '16 at 15:25