How to type Dirac Braket properly

I am using \langle and \rangle to type Dirac brakets. But the symbols can not resize automatically to fit the symbols inside, as this:
image
But document here shows a right example without explaining how to put it:
image
So how to accomplish this?

The brackets you can enter by typing <, followed by the Tab key six times.
You can get the right size separating symbol | by typing | and Tab twice.

I have tried type < and tab but give up mid way… And I just found one can put < and shift+tab to save more time. Or maybe users can change the cyclic order of < by themselves?

1 Like

I found it is easy to type Bra, just type | after I have typed < and shift+tab. But how to type Ket more conveniently?

You can do < and Shift-Tab, then put the cursor in front of <> and press Delete, then |.

1 Like

You can use ALT+L followed with < to type langle, and ALT+R followed with > to type rangle. Besides, to type | inside the Dirac Braket, just use ALT+M followed with |. These three ALT+L/M/R prefix keys can actually be used with all types of brackets. Note that all ALT+R keys must be preceded with ALT+L keys. Sometimes, these prefix keys can be omitted. For example, to type Ket, you can just type | and ALT+R with >; and to type Bra, just use ALT+L with < and |.

5 Likes

Maybe you can try to create commands to simplify every input operation of Dirac notation. Here is my programme

4 Likes

It is easy to input most of them without macros.

For bra’s: first input {, then press Tab to get ⟨⟩, and input, say, a, and then |, you will get ⟨a|.

For pro’s and mel’s, the same steps as above, and after inputting |, you press Tab, getting ⟨a|⟩.

To get ave’s, you just do the first two steps for bra’s.

It is slightly more difficult to input kets. You first input things like ⟨a⟩, then remove and replace it by |.

2 Likes

For kets in the math mode, there are no difficulties either since they follow the same pattern. First, input | to get ||, then input, for example, a, and finally }, you will get |a}, and pressing Tab will yield |a⟩.

For more details on asymmetric brackets, please refer to The Jolly Writer Chapter 4.5.

3 Likes

I started a physics style package plugin:

We can work together to improve it. I just added ket, ket*, bra, bra*.

You can follow the pattern add more macros as an equiv of the LaTeX physics package.