So I'm trying to implement a COOL-style \Sum macro which is supposed to support the following syntax:
\Sum{\ldots} % -> \sum \ldots
\Sum[i]{\ldots} % -> \sum_{i} \ldots
\Sum[i \in I]{\ldots} % -> \sum_{i \in I} \ldots
\Sum[i, 0, N]{\ldots} % -> \sum_{i=0}^{N} \ldots
\Sum[{i,j}, 0, N]{\ldots} % -> \sum_{i,j=0}^{N} \ldots
\Sum[{i,j,k}]{\ldots} % -> \sum_{i,j,k} \ldots
The important bit is that I would like braces to protect commas in the first argument. The actual implementation is in expl3 with the user interface using xparse. Unfortunately, xparse appears to always strip braces inside arguments if they surround the whole argument such that this protection will not work in all cases, no matter what my internal code does. Looking at the docs, I couldn't find a way to prevent this.
I tried macros signatures of the forms
\DeclareDocumentCommand \Sum { s >{ \SplitArgument{2}{,} } o m }
{ ... }
\DeclareDocumentCommand \Sum { s o m }
{ ... }
Am I missing something here, is there a (undocumented) way to make xparse not strip such braces short of circumventing xparse and implementing the interface manually (maybe using argument processors?)? If not, would this warrant a bug report/feature request at the latex github?


\Sum[{{i,j,k}}]{\ldots}. – Skillmon Dec 15 '18 at 13:57;as delimiter? You would need no braces. – egreg Dec 15 '18 at 14:03;would likely work for my usecases, I don't think I've ever used a semicolon in sum limits. Still, wrapping the argument in braces was the first and obvious (to me) thing I tried to protect arguments that contain the delimiter, and I was surprised that this didn't work. Maybe I'll go for ';' plus the workaround from the other answers (even though that might be overkill) – Wisperwind Dec 16 '18 at 13:05