Is it possible to give the optional arguments in this command a comma-separated syntax, i.e. \ads{A,1,2,3,4}
or \ads{A}[1,2,3,4]
? (I think I'd prefer the first variant.) Despite reading all the relevant posts I could find, I haven't so far managed to figure out to how to apply any of the approaches here.
\documentclass{article}
\usepackage{xparse,amsmath}
% A command to apply adscripts to a base;
% the sequential definition of bases is to avoid spurious vspace from empty over-/under-sets;
% the ordering is anticlockwise from bottom.
\NewDocumentCommand{\ads}{o m o O{} O{} o}{%
\ifx#1t\def\baseA{\text{#2}}\else\def\baseA{#2}\fi% define the base to be text, if desired
\def\baseB{\baseA_{#3}^{#4}}% apply subscript and superscript
\IfValueTF{#3}{\def\baseC{\underset{#3}{\baseB}}}{\def\baseC{\baseB}}% apply underset
\IfValueTF{#6}{\def\baseD{\overset{#6}{\baseC}}}{\def\baseD{\baseC}}% apply overset
\baseD%
}
\begin{document}
\[
\ads[t]{A}[1][2][3][4]
\]
\end{document}