Consider the following MWE where I define a macro to generate triangle Feynman diagrams with three inputs:
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{physics,tikz-feynman}
\usepackage{float}
\usepackage{graphicx}
\usepackage{xstring}
\tikzset{every picture/.append style={remember picture}}
\newcommand{\Ctype}[3]{
\begin{figure}[H]
\centering
\tikzfeynmanset{
every plain={blue},
every scalar={red},
}
\feynmandiagram[scale=.5,transform shape] [large, horizontal=a to t1] {
a -- [plain] t1
-- \IfEqCase{#1}{{P}{[scalar]}{M}{[scalar]}{R}{[plain]}{L}{[plain]}} t2
--\IfEqCase{#2}{{P}{[scalar]}{M}{[scalar]}{R}{[plain]}{L}{[plain]}} t3
-- \IfEqCase{#3}{{P}{[scalar]}{M}{[scalar]}{R}{[plain]}{L}{[plain]}} t1,
t2 -- [plain] p1 ,
t3 -- [plain] p2,
};
\IfEqCase{#1}{
{P}{\tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
\draw[thick,red] (m1) --(t1);}}
{M}{\tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
\draw[thick,red] (m1) --(t2);}}
}
\IfEqCase{#2}{
{P}{\tikz[overlay]{\path (t2) --(t3) coordinate[midway] (m2);
\draw[thick,red] (m2) --(t2);}}
{M}{\tikz[overlay]{\path (t2) --(t3) coordinate[midway] (m2);
\draw[thick,red] (m2) --(t3);}}
}
\IfEqCase{#3}{
{P}{\tikz[overlay]{\path (t3) --(t1) coordinate[midway] (m3);
\draw[thick,red] (m3) --(t3);}}
{M}{\tikz[overlay]{\path (t3) --(t1) coordinate[midway] (m3);
\draw[thick,red] (m3) --(t1);}}
}
\captionsetup{labelformat=empty}
\caption{$C_{#1#2#3}$}
\end{figure}}
\begin{document}
\Ctype{P}{P}{M}
\end{document}
I get the error:
Argument of \XC@definec@lor has an extra }. \Ctype{P}{P}{M}
How to fix this?