The LaTeX commands \mid and \vert may be used to make a vertical bar. I can appreciate that \vert is short for vertical, but why \mid? Is it short for middle? and if so, middle of what?


3 Answers 3


I can't claim to possess any special insights into Don Knuth's linguistic preferences. I can tell you something about the use of \mid, though. The instruction \mid (in math mode, of course), produces a vertical bar with a "thick space" on either side. A good use of this symbol, for example, is when one needs to denote the fact that the material to the left of the vertical bar is being conditioned on what's to the right of the vertical bar. For instance, if X is a random variable, one might denote its expectation conditional on the r.v. being greater than 0 as $\mathrm{E}(\,X\mid X>0\,)$:

enter image description here

Note that this could also be produced, far less succinctly, as $\mathrm{E}(\,X\;|\; X>0\,)$ because \; inserts a "thick space".

If you want larger versions of the vertical bar as a relational symbol, while preserving the nice spacing on either side, you can write \bigm|, \Bigm|, \biggm|, and \Biggm|.

There is actually no \middle construct in the orginal TeX engine. This omission is addressed in eTeX ("Extended TeX") and successors such as pdfTeX. I.e., something like \middle| will work on most systems that are based on eTeX or one of its descendants. For more on \mid and \middle, you may want to check out the TeX FAQ topic Set specifications and Dirac brackets. One caveat, though: \middle, unlike \mid, will not automatically insert any space around the vertical bar; that's left to the user...

  • thanks, the first i know why we need the \mid.
    – yanpengl
    Commented Apr 27, 2023 at 14:12

Here are two examples out of many where middle vertical bar is needed

X = \left\{x\in\mathbb{R} \middle| \int_0^xf(z)dx<0\right\}

enter image description here

and for mostly inline math

A sentence for $X = \left\{x\in\mathbb{R}\mid x<0\right\}$ some more math.

enter image description here

  • 11
    It may be worth mentioning that \mid will insert thickspace (\;) on either side of the vertical bar, whereas \middle| will not. This difference is clearly visible by comparing the two examples you provide.
    – Mico
    Commented Apr 22, 2012 at 23:17
  • 2
    @Mico True, but seems like I'm a tad late. Your answer is much better.
    – percusse
    Commented Apr 23, 2012 at 1:35

It’s because Donald Knuth intended \mid to be used in the middle of a pair of left and \right delimiters. When you don’t want that, just a vertical bar, you use \vert.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .