Just out of interest would you mind sharing an example (eg a bit of screengrab) of the rendered result of the macro, and/or the macro itself? It sounds useful but I can’t quite visualise.
\newcommand{\ddim}[3]{\ensuremath{\underset{\scriptscriptstyle #2\times #3}{\rule[-1ex]{0ex}{+1ex}#1}}}
And you use it e.g. like `\ddim {A}NN` to indicate that A is NxN, or `Ax \ddim {=}N1 b` to show that this is an Nx1 equation. I suppose one could fine-tune it, but it was good enough for me.Looks like this: