Now I use "mid" for all vertical bars, but I wonder what's the proper ways.
The first scenario is vertical bar for absolute value. Now I just right $x\leq \mid x \mid$
. but is this correct?
The second scenario is in conditional expectation. Now I write E[x \mid y]
, but sometimes if the "x" part is complex, it might be quite "tall", I wonder if there's a way to have a "automatically adjusted" vertical bar. Is there?
Best Answer
As others have remarked, vertical bars can be obtained with different commands and one should use the correct one in each case:
\mid
when it's a relation symbol, for instance in set notation or for “divides”;\lvert
or\rvert
when it's a (left or right) delimiter; note that this requiresamsmath
that's recommended anyway when a document needs math.Just typing
|
can work, but there are some subtleties, so it's better to use the above commands. Similarly, for the double bar is\parallel
when it's a relation symbol;\lVert
or\rVert
when it's a delimiter.You can exploit
mathtools
for your symbol for expectation, but with some more tricks in order to make the bar doing the right thing.In the same style as macros declared with
\DeclaredPairedDelimiter
, you can give\expect
an optional argument that can be one among\big
,\Big
,\bigg
or\Bigg
for manually sizing the delimiters or use\expect*
in order to get automatic sizing (use it sparingly).Here you can use
|
for conditional expectation, because the macros take care of its relation nature.UPDATE
A revamped definition that uses new features of
expl3
andxparse
. This also allows to specify the measure of the expectation.