I use the following command to typeset E[A|B]
\documentclass{article}
\usepackage{mathtools}
\DeclareMathOperator{\ExpOp}{E}
\DeclarePairedDelimiterX{\ExpArg}[1]{[}{]}{#1}
\newcommand{\Exp}{\ExpOp\ExpArg*}
\begin{document}
% usage:
$\Exp{A \mid B}$
\end{document}
Is it possible to define \Exp
to accept an optional size parameter like \bigg
for the brackets?
Best Answer
Since
\mid
does not make much sense then you read\Exp{A \mid B}
(and cannot be scaled), I suggest hiding the|
inside a specially crafted macro giving us a macro that support conditionals including scaling.Addition, if you do not have the 2014 version of mathtools, you can use this
I'd might even consider using
\operatorname{\mathbb{E}}
As far as I understand
\nonscript\:
makes\:
disappear in a script context. Since\vert
is a symbol not a fence,\vert - B
does not give the minus sign but rather an addition minus (wrong spacing).\mathopen
makes a potential-
behave as a sign rather than an addition.\allowbreak
just allows line breaks after\given
. Remove if not relevant (ie all conditionals are short).