6

Possible Duplicate:
How to automatically resize the vertical bar in a set comprehension?

Trying to type the formula for a conditional probability like this

\mathrm{P} \left( whatever \mid whatever \right) = ...,

I'd like to have \mid the same size as the left and right parentheses.

How can I achieve this?

j.p.
  • 215

2 Answers2

6

use \middle| or for a double \middle|\middle|

\[ \left( \frac{a}{b^2}+1\middle| f(x)\right)\]
4

\middle doesn't add spaces around the symbol it produces and treats it as an ordinary symbol, like when we say \bigg| or even \bigg(. On the other hand it can't be put inside \mathrel.

The problem might arise when when \middle is used in a subscript; one can say either of

\left( something \nonscript\;\middle|\nonscript\; something \right)
\left( something \mathrel{}\middle|\mathrel{} something \right)

and the result will be the same as if we used \mid (of course if we decide that this vertical bar must be treated as a relation symbol). This is for writing macros that use the \middle feature, as in direct input one knows what space is necessary.

egreg
  • 1,121,712