1

I have a command \cont used mainly in the form \cont{X, Y} and defined using \SplitArgument, as shown in the source below. How can I define a starred version \cont* of this command that does two things, as indicated:

  • uses fences \bigl[ and \bigr] instead of ( and ); and
  • uses 4 arguments rather than 2, which get grouped in the outout as shown in the output equation (3)?

If it helps, I'm willing to change the separator in the original \cont to a semicolon instead of a comma, so that I would use, for example, \cont{X; Y} and then use the starred form as, for example, \cont*{X, x; Y, y}.

\documentclass[fleqn]{memoir}
\usepackage{xparse}
\usepackage{suffix}

\NewDocumentCommand{\cont}{ >{\SplitArgument{1}{,}} m }{\printcont#1} \NewDocumentCommand{\printcont}{mm}{{\mathcal{C}}({#1}\IfValueT{#2}{, {#2}})}

\newcommand{\contmaps}[2]{\mathcal{C}(#1, #2)} \WithSuffix\newcommand\contmaps*[2]{\mathcal{C}\bigl[(#1),(#2)\bigr]}

% How define this? %\WithSuffix\newcommand\cont* ..........

\begin{document}

\begin{equation}\label{one} \cont{X, Y} \end{equation} \begin{equation}\label{two} \contmaps{X}{Y} \end{equation} \begin{equation}\label{three} \contmaps{X, x}{Y, y} \end{equation} How define \verb!\cont! so next line gives same result as in equation (\ref{three})? \[6pt] \mbox{}\qquad\verb!\cont*{X, x, Y, y}!

\end{document}

to add starred form of command

murray
  • 7,944
  • I removed my answer, but I add a comment: leave \WithSuffix alone. – egreg Oct 12 '21 at 20:19
  • @egreg: Would you kindly restore your answer, since its method of handling both commas and semicolons will still be of use to me? – murray Oct 12 '21 at 21:26
  • No, sorry. You're asking something completely different. – egreg Oct 12 '21 at 21:31
  • @egreg: I posted as https://tex.stackexchange.com/q/618768/13492 a modified version of my original question. I think your now-deleted answer here would respond to that. – murray Oct 13 '21 at 01:23

0 Answers0