I'd like to automatically determine the whitespace inside the arguments of a binary operator and provide appropriate spacing around the operator automatically. Example:
\documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\binding}{mm}{#1\!\mapsto\!#2} \ExplSyntaxOff \begin{document} \noindent \verb!\(\binding{a}{b}\)! should produce \(a{\mapsto}b\).\\ \verb!\(\binding{aa}{bb}\)! should produce \(aa\!\mapsto\!bb\).\\ \verb!\(\binding{f(a+b)}{g(c+d)}\)! should produce \(f(a+b)\mapsto g(c+d)\).\\ \verb!\(\binding{f\,a}{g\,b}\)! should produce \(f\,a\,\mapsto\,g\,b\). \verb!\(\binding{i}{(\binding{a}{b})}\)! should produce \(i\mapsto(a{\mapsto}b)\). \end{document} How to do that in latex3? As a start, I would be happy just to distinguish between the first two kinds of inputs, i.e., to test whether the two arguments are at most one symbol long. As a maximum capability, I'd like to ensure that the whitespace before/after \mapsto is slightly larger than the largest whitespace in any of the two arguments.
