I'm trying to create a few commands to handle conditional probabilities. So far I am using the mathtools DeclarePairedDelimiter family of commands. Also, as far as I am aware, mathtools does not allow for breaking lines in the middle of the expressions, during an align environment for instance.
I want to use the convenience of DeclarePairedDelimiterXPP and at the same time, be able to do things manually when I need to span multiple lines. However, I want the spacing to be consistent, regardless of the style that I am using.
So far, I have used this definitions:
\newcommand{\given}{\vert}
\newcommand{\prob}{\mathbb{P}}
\DeclarePairedDelimiterXPP{\Prob}[1]
{\prob}{\lparen}{\rparen}{}
{\renewcommand{\given}{\nonscript\;\delimsize\vert\nonscript\;\mathopen{}}#1}
But if I do this, I would like to have exactly the same result if I try these three commands
\begin{align*}
& \Prob{X \given Y}
&& \Prob*{X \given \sum Y}
&& \Prob[\big]{X \given \sum Y} \\
& \prob(X \given Y)
&& \prob\left(X \middle\given \sum Y \right)
&& \prob\bigl( X \bigm\given \sum Y \bigr)
\end{align*}
Actually, I care a bit less about the middle case, since I'm probably never going to use \left, \middle and \right again.
If I redefine \given to be \mid, then the first case seems to work, but \mid is not a delimiter, so then I cannot do \bigm\given. Of course I could use \mid or \vert, depending on the case, but I'm trying to create semantic commands.
Is there a way to define \given in such a way that it has the spacing of \mid, but if it is preceded by \bigm or \Bigm for instance, it behaves as a delimiter?
I'm happy to hear any suggestion on how to deal with this issue.
Also, I would like to know whether it makes any difference in this case to define \prob using \newcommand or \DeclareMathOperator, and which one would be advisable and why. I can't see any visible difference in the output.
My best regards.