Consider the following MWE:
Code: Select all
\documentclass{article}
\usepackage{mathtools}
\usepackage{xparse}
\makeatletter
\def\resetMathstrut@{%
\setbox\z@\hbox{%
\mathchardef\@tempa\mathcode`\[\relax
\def\@tempb##1"##2##3{\the\textfont"##3\char"}%
\expandafter\@tempb\meaning\@tempa \relax
}%
\ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@}
\makeatother
\begingroup
\catcode`(\active \xdef({\left\string(}
\catcode`)\active \xdef){\right\string)}
\endgroup
\mathcode`(="8000 \mathcode`)="8000
\newcommand{\testA}[2]{{\mkern -#1mu}#2{\mkern -#1mu}}
\newcommand{\testB}[4]{{\mkern -#1mu}#2^{\mkern -#3mu #4}}
\begin{document}
\begin{equation}
\testA{4}{(\frac{1}{3}a)} \qquad \testB{4}{(\frac{1}{3}a)}{6}{n}
\end{equation}
\end{document}
I would like to make \testA and \testB into a single command, say \test, with a different number of arguments. I have a feeling that the \NewDocumentCommand command from the

How do I do this?
Thank you in advacnce!