Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Juan A. Navarro, Leo Liu, lockstep, Caramdir, Alan Munn May 7 '11 at 14:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@Martin: Thanks for correcting the layout! – j.p. May 5 '11 at 15:05

2 Answers 2

up vote 5 down vote accepted

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

\[ \left( \frac{a}{b^2}+1\middle| f(x)\right)\]
share|improve this answer
Arg, 12sec to late ... I would have used \middle\vert, but \middle| seems to do the same. – Martin Scharrer May 5 '11 at 15:07
I was 29 seconds too late... – Gonzalo Medina May 5 '11 at 15:11
@Herbert: Thanks, works fine (I just have to adjust the spaces around the | a little)! – j.p. May 5 '11 at 15:13
@Martin: Sorry, but you could have been a little less altruistic and first answer the question before beautifying it. – j.p. May 5 '11 at 15:15
@Herbert: \vert is the same as |, \Vert is the same as \| – egreg May 5 '11 at 16:04

\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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.