I'd like to have an easy way to declare an operator that brackets its argument with a particular delimiter. As an example I'd like to be able to write
\Pr{X}
to mean the same as
\operatorname{Pr}\left[X\right]
FYI I know how to do
\newcommand{\Pr}[1]{\operatorname{Pr}\left[#1\right]}
but I thought I once saw a package that provided some command like
\DeclareBracketedOperator{\Pr}{Pr}{[}{]}
sort of a combination of \DeclarePairedDelimiter
and \DeclareMathOperator
and I think it also defined a starred version of the operator that didn't take any argument and didn't produce the delimiters.
Best Answer
I don't remember of any such package. Your
\Pr
command maybe obtained byWith this definition,
\Pr
would behave exactly as if it was defined with\DeclarePairedDelimiter
; that is, the*
-form would use\left
and\right
.If you want to always use
\left
and\right
, you might follow Werner's suggestion, or go the hard way:(requires amsmath, of course). Note:
\renewcommand{\Pr}{...}
is necessary, because\Pr
is already defined in LaTeX.