What I am looking for is a single newcommand, let's call it \wedges, with a variable number of inputs that yields in a flexible way the following result:
I have already written the code for the variable input commands for the unbarred and barred parts isolated, they are respectively \cunei (italian for wedges) and \bcunei (b stands for barred). Thus \wedges = \cunei \wedge \bcunei. The code (inspired from here) is the following and outputs the above picture:
\documentclass[11pt,a4paper]{amsart} % Just to shorten barring z \newcommand{\bz}{\bar{z}} % Wedge part (commands are \cunei, \checknextarg, \gobblenextarg) \makeatletter \newcommand{\cunei}[1]{% dz^{#1}\checknextarg} \newcommand{\checknextarg}{\@ifnextchar\bgroup{\gobblenextarg}{}} \newcommand{\gobblenextarg}[1]{\wedge dz^{#1}\@ifnextchar\bgroup{\gobblenextarg}{}} \makeatother % Wedge bar part (commands are \bcunei, \bchecknextarg, \bgobblenextarg, note the b in front) \makeatletter \newcommand{\bcunei}[1]{% d\bz^{#1}\bchecknextarg} \newcommand{\bchecknextarg}{\@ifnextchar\bgroup{\bgobblenextarg}{}} \newcommand{\bgobblenextarg}[1]{\wedge d\bz^{#1}\@ifnextchar\bgroup{\bgobblenextarg}{}} \makeatother \begin{document} \[ \cunei{a}{b}{c}{d} \wedge \bcunei{e}{f}{g} \] \end{document} I am not satisfied with this since in case of only:
it is still quite verbose, the code is: \cunei{a} \wedge \bcunei{b}. Whereas ideally I would like something like \wedges{a}{\bar{b}} to produce it, where the command \wedges has flexible number of inputs and when it detects the \bar{} as input automatically writes d\bz^{}, instead of dz^{} (actually, since the exponents are usually always j,k,l,m, etc I again, as I did for z in the above code, will introduce newcommands as \bj, \bk, \bl, \bm, etc to shorten \bar{j},..., so I want the command to detect \bj, not \bar{j}, if that makes a difference). Is there a way to do this? If it may help note that unbarred and barred elements are always ordered, first the unbarred ones and then the barred ones. Thanks.





\@consand\@nextto add or remove entries. See tex.stackexchange.com/questions/610633/… for example.