TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I m using the braket notation to write a physics report (with the braket package). Writing a plus and a minus within a ket or a bra looks really ugly (bra is < | and ket is | > ) Are there any ideas on how to make it look better? having a line like this:

|1,-1>=<--|1, -1>|-->+<-+|1, -1>|-+>+<+-|1, -1>|+ -> etc

is pretty unreadable in the pdf, as the pluses/minuses inside and outside the braket notation are indistinguishable. The idea is that a smaller or smaller and thicker plus/minus only within the braket notation would make it more readable, only I don't know if such a symbol exists. Would I have to create it manually? I d like to avoid that, as it would decrease my typing speed seriously, even with a shortcut..

share|improve this question
post a complete example ... – Herbert Apr 11 '11 at 9:53
Also, I am hoping you are not using what you highlighted as code as the actual code. The braket package defines the commends \bra{} and \ket{} and more... – Willie Wong Apr 11 '11 at 13:48
Is the following a correct interpretation of your question? You want to define a command \bra{} which takes one argument, such that for all instances of the symbols + and -, you want them to be set in a different fontsize/weight? – Willie Wong Apr 11 '11 at 14:13
No, I didn't make myself clear. I do use \bra{}, \ket{} and \braket{}, that's the whole point of the braket package. The thing is if I fill it will +-, The +- inside and outside the brakets are indistinguishable. I need another type of +-, maybe smaller and thicker, to distinguish them visually on the final pdf! – sfranky Apr 11 '11 at 14:54
To an extent, your problem will be unavoidable, because what you are writing is the quantum-physical version of a tongue-twister. Adding more space between your terms using \; macros is the simplest, and perhaps the best, thing that you can do – after changing to a different typeface for the contents of the \bracket{}s and \ket{}s of course. – Niel de Beaudrap Apr 11 '11 at 21:32
up vote 5 down vote accepted

I am not too sure what font to use for the internal + and -, so I just used \hbox{\texttt{+}}. In TeX, each character has a \mathcode, describing its behavious in maths. All of them lie between "0000 and "7FFF (in hexadecimal), except the special mathcode "8000, which makes the character act like an active character. Within the group which \bra, \ket and \braket define, I get + and - to be active and expand to \braket@inner@minus and \braket@inner@plus.


\catcode`\-=13\relax %active
\catcode`\+=13\relax %active
\@firstofone{\endgroup %end the local changes to catcodes.
      \mathcode`\noexpand +=\the\mathcode`+%
      \mathcode`\noexpand -=\the\mathcode`-%
% old definition:
% \newcommand{\bra}[1]{\mathinner {\langle {#1}|}}
% new definition:
\renewcommand{\bra}[1]{\mathinner {\langle \braket@inner@defs {#1}|}}
\renewcommand{\ket}[1]{\mathinner {|\braket@inner@defs{#1}\rangle }}
\renewcommand{\braket}[1]{\mathinner {\langle \braket@inner@defs {#1}\rangle }}

\bra{++--}A^\dag A\ket{-+-+} = \braket{++--|A^\dag A|-+-+} = \cdots
\bra{++}(A+B)\ket{--} \neq \braket{++|(A+B)|--}
share|improve this answer
" is used for hexadecimal numbers. \mathcodes are 15-bit numbers, i.e., between "0000 and "7ffff. "8000 is a special \mathcode. See The TeXbook or TeX by Topic for details. – TH. Apr 12 '11 at 8:06
this is great! however, although it does work standalone, I can't seem to embed it in my text..It complains about encoding of a font I think (I m writing in greek).. I ll check the code carefully and see what the cause could be. Thanks !! – sfranky Apr 12 '11 at 8:14
Also, I copied part of the math in your example, and noticed that this doesn't work for underbraces! If I write something under the underbrace, the plus sign is the thicker one, not the normal one. Otherwise, the result is what I wanted! – sfranky Apr 12 '11 at 8:23
Is your underbrace within the argument of \bra{}? – Bruno Le Floch Apr 13 '11 at 13:35
sorry for the late reply I wasn't notified.. yes, it usually is. – sfranky Apr 15 '11 at 18:25

Assuming I got it right what dingo_d said:

  \left|1,-1\right\rangle = \bra{--}1,-1\rangle\ket{--} +
    \bra{-+}1,-1\rangle\ket{-+} +

enter image description here

My eyes hurt… :-(
I threw the .3ex from a hat. If it helps, it was a nice looking hat.

share|improve this answer
That's what the braket package does! My problem is visual. If I could print in colour and it was allowed in dirac notation, I would have the inner =- painted another colour to distinguish them from the others! btw, my eyes and my mind hurts when I read this.. – sfranky Apr 11 '11 at 14:57
Sorry, dingo_d is right, I didn't look at your code carefully. Thank you, I assumed it just redefines bra and ket as if braket didn't exist. This solution seems ok, too, but it doesn't work for the \braket{}, which can be < > , < | > , or < | | >. Also, how can I put the \def parts outside the $$ environment and into the preamble? – sfranky Apr 12 '11 at 8:49
@sfranky: I assume you're using LaTeX? I'm sorry, I don't really know enough about it to be of help here. – morbusg Apr 12 '11 at 14:35

When I want to write something in QM with braket notation I use \langle and \rangle, looks just fine and you can combine it with simple | sign.

HTH ^^

share|improve this answer
What's wrong with the code morbusg posted? You can clearly see the thick minus and plus on the outside and smaller on the inside... Plus have you looked at some books in QM, they all have the same sized + and -, talk about headache there :D Also, how come I can only answer to my own big answer? :\ – dingo_d Apr 12 '11 at 7:51
I just made up for that :) \langle and \rangle are fine, but I am speedtyping and I need to be able to hit the fewest keystrokes possible. In vim, i have these remaps: << ---> \bra{ , >> ---> \ket{ , <> ---> \braket{ which makes this really fast for me!! – sfranky Apr 12 '11 at 8:52
Oh, I see, hmmmm I'm sure you could try to make another definitions like morbusg suggested but for various combination (braket). I renamed the \bra and \ket with \< and \> and it works. But I see that if you'd write \bra{+}\ket{-} you'd get aa extra | which is not good... I think that you just need to redefine the morbusgs definitions a bit and you're good to go :) – dingo_d Apr 12 '11 at 9:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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