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

4

1

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?

BlackShift

Posted 2009-11-30T08:16:30.037

Reputation: 371

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

– Joey – 2009-12-02T06:43:17.763

Answers

6

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.

Will Robertson

Posted 2009-11-30T08:16:30.037

Reputation: 190

thanks, I did not know that at all! Perhaps it is to new for my 'not so short introduction to LaTeX' :). – BlackShift – 2009-12-04T13:12:26.810

0

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.

Joey

Posted 2009-11-30T08:16:30.037

Reputation: 36 381