# character in between \left and \right in the same size in LaTeX

In LaTeX, it is common to use \left and \right to get parenthesis of the same size. I would like to put something in between them in the same size, like a vertical bar:

\left( \frac{a}{b} | q \right)


In this example, the vertical bar is to small.

Perhaps it is possible to save the size of the height and do something like:

\left( \frac{a}{b} \saveheight \right|\left. \restoreheight q \right)


with some definition of saveheight and restorheight, but this is just guessing from my side. Any ideas?

-
Interestingly, not even the people writing Wikipedia seem to know a solution, if you take a look at en.wikipedia.org/wiki/Bra-ket which is full of ugly examples ;-) –  Joey Dec 2 '09 at 6:43

You can write

\left( \frac{a}{b} \middle| q \right)


This only (of course?) works for delimiters that actually scale.

\middle is defined as part of eTeX, which is standard in all distributions for years now.

-
thanks, I did not know that at all! Perhaps it is to new for my 'not so short introduction to LaTeX' :). –  BlackShift Dec 4 '09 at 13:12

The best I could come up with is the following ugliness:

\left( \left. \frac ab \right| a \right)


or

\left( ab \left | a^2 \right. \right)


The downside is that you need to know which of the two parts is the larger one and appropriately enclose that in a \left-\right pair.

The other option would be to manually specify the size of the brackets:

\bigg( \frac ab \bigg| a \bigg)


Not nice, but probably the easiest to write and the hardest to get wrong. The size may need some fiddling, though (but whoever uses LaTeX is probably used to that).

Another, even more hacky solution would be to use an array:

\left( \begin{array}{c|c} \dfrac ab & a \end{array} \right)

\left( \begin{array}{c|c} ab & a^2 \end{array} \right)


This will work the same regardless of which side is larger, but care has to be taken with fractions (hence the \dfrac which forces display size) and you'll get extra space around the array which looks kinda ugly, imho. You can counter that by including negative space:

\left( \!\! \begin{array}{c|c} \dfrac ab & a \end{array} \!\! \right)

\left( \!\! \begin{array}{c|c} ab & a^2 \end{array} \!\! \right)


Two \! seem to be enough to make it good-looking again.

-