I need to write some equations that contain something like
(A | B).
I could write
\left( A \middle| \right), but this changes spacing around external parentheses, as expained in many topics like this.
There is a nice working solution with
\DeclarePairedLimiterX as explained in this answer. However, for many reasons I would like to use
\middle| and fix the spacing around it (so that it is the same as around
\mid), in the same way as
\right are fixed in this answer or by the package
mleftright (see this answer). In other words, I would like
| to stretch like
\middle| and to have the same spacing as
\mid. Is it possible? I'm using