I'm trying to define a command that, given input on the form \mydef{pre}{main}{post}, gives output akin to:

(Where the "foo" and "bar" are just for reference, and the fraction inside is to provide a tall input.) That is, I want a paired delimiter with arguments for pre- and postscripts as subscripts. I want an unscaled default version, and preferably a starred version which scales automatically depending on main, but where the prescript is aligned with the postscript. The above is generated by the following:
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiterXPP{\mydef}[3]{_{#1}}{[}{]}{_{#3}}{#2}
\begin{document}
\[
foo \mydef*{pre}{\frac{main}{main}}{post} bar
\]
\end{document}
I figured that the \DeclarePairedDelimiterXPP command provided by mathtools was a good start, but I can't seem to get the prescript to align properly.
The \prescript command provided by the same package might be useful, but if you are going to recommend it, remember that it renders subscripts as if there were a superscript as well, which I don't want:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
{}_{pre} main \quad \prescript{}{pre}{main} \quad {}_{pre}^{} main
\]
\end{document}

So I would want a way around that.


tensorpackage, e.g.,\newcommand{\mydef}[3]{\tensor*[_{#1}]{#2}{_{#3}}}. – Marijn Nov 13 '17 at 20:55