Mathematica Stack Exchange is a question and answer site for users of Mathematica. 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

In TraditionalForm, Mathematica formats kets incorrectly in certain expressions.

For example, if used in a summation with indices indicated, a ket becomes too "tall" (red) compared to the rest of the expression:

see the big ket

Is there a way to prevent this gigantism?

         RowBox[{"\[LeftBracketingBar]", "\[Psi]"}], "\[RightAngleBracket]"}], "=", 
         SubscriptBox["\[Delta]", "0"], 
          SubscriptBox["d", "0"]}]}]}], "\[RightAngleBracket]"}], "+", "\[Ellipsis]", "+", 
        RowBox[{"N", "-", "1"}]], 
         RowBox[{"N", "-", "1"}]]}]}]}], "\[RightAngleBracket]"}], "=", 
      RowBox[{"i", "=", "0"}], 
      RowBox[{"N", "-", "1"}]], 
      SubscriptBox["\[Delta]", "i"], 
       SubscriptBox["d", "i"]}]}]}]}], 
    FontColor->RGBColor[1, 0, 0]]}], TraditionalForm]], "DisplayFormula"]
share|improve this question
Would you please post code for that expression? – Vitaliy Kaurov Feb 21 '13 at 5:58
When my kets started getting big, way back when, I simply stopped feeding them. They still haven't forgotten. – Daniel Lichtblau May 10 '13 at 21:20
up vote 18 down vote accepted

To prevent this from happening, you may be able to make use of the new-in-8 keyboard shortcut EscketEsc, and similarly for the other symbols, EscbraEsc, EscbraketEsc. These shortcuts bring up a template which is already delimited appropriately. After entering this, you have to press Tab to get "teleported" into the placeholder where the contents of the ket is entered:

picture of the ket as it appears in the notebook

This approach works equally well in TraditionalForm or in normal Input cells, since it relies on the new (but undocumented) symbols Bra, Ket, and BraKet for its display form.

share|improve this answer
That was the problem. I was using the characters from the palette to build a ket "from scratch". I didn't know that there was built-in support. – raxacoricofallapatorius Feb 21 '13 at 17:07
Thanks - there is a hole in the docs for this. If you say ?Ket you get nothing. – Jens Feb 21 '13 at 17:18
@Jens When I run Options[$FrontEnd, InputAliases], "ket", "bra" and "braket" are not in the list. I am not sure if it is because you have loaded some package before that defines them, but they are not built-in alias for Mathematica. I like you idea anyway. So I have provided the code to define these alias in my answer. – Everett You May 10 '13 at 21:03
@EverettYou Jens' answer works perfectly fine here on mma9 and I haven't loaded anything. – R. M. May 11 '13 at 1:23
@EverettYou let me make a suggestion. Before you take such an aggressive stance, like "the answer simply does not work so I'm downvoting you", try providing extra information, such as version and os. That way, we can diagnose why it doesn't work, and make corrections as necessary. In particular, I wonder what OS you're running because I know you have access to v9. – rcollyer May 11 '13 at 2:31

Your are in computational mode, when Mathematica cares that you do not have any corresponding bra. It seems to me that you do not really care for computation and a reasonable thing would be to got to a typesetting realm. Then what about entering things as strings?

enter image description here

I used palettes to type it, but the code for this is:

TraditionalForm["\!\(\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(N \
- 1\)]\)\!\(\*SubscriptBox[\(\[Delta]\), \(i\)]\)|\!\(\*SubscriptBox[\
\(d\), \(i\)]\)\[RightAngleBracket]"]
share|improve this answer
Ket? Bra? That's some weird science. – Mr.Wizard Feb 21 '13 at 8:28
I made it red to highlight it. – raxacoricofallapatorius Feb 21 '13 at 14:03
@raxacoricofallapatorius this is why posting code would be useful. I corrected text. – Vitaliy Kaurov Feb 21 '13 at 14:49
@Mr.Wizard So true - I currently teach quantum mechanics, and this bra business does causes an awkward moment when you start talking about it. Maybe especially now because the field is slowly becoming more gender diverse. We should go back to teaching this stuff in German, that would solve the problem. – Jens Feb 21 '13 at 17:14
@Mr.Wizard yes! It's a complete weird science! And very beautiful too. :) – Murta Feb 21 '13 at 23:19

Jens's answer provides a good idea, but for some users (with v7 or older versions), "ket", "bra" and "braket" are not built-in Mathematica input aliases. To define these aliases in Mathematica, one may execute the following code:

 InputAliases -> 
  Join[{"ket" -> 
     TemplateBox[{"\[Placeholder]"}, "Ket", 
      DisplayFunction -> (RowBox[{"\[LeftBracketingBar]", #1, 
           "\[RightAngleBracket]"}] &)], 
    "bra" -> 
     TemplateBox[{"\[Placeholder]"}, "Bra", 
      DisplayFunction -> (RowBox[{"\[LeftAngleBracket]", #1, 
           "\[RightBracketingBar]"}] &)], 
    "braket" -> 
     TemplateBox[{"\[Placeholder]", "\[Placeholder]"}, "BraKet", 
      DisplayFunction -> (RowBox[{"\[LeftAngleBracket]", #1, "|", #2, 
           "\[RightAngleBracket]"}] &)]}, 
   OptionValue[Options[$FrontEnd], InputAliases]]]

Then you can use Esc ket Esc to enter the ket. The TemplateBox is used to delimit the template. One may change the DisplayFunction to specify the desired box appearance.

share|improve this answer
So you downvoted my "good idea" even though it's the accepted answer? What's the logic in that? If the alias doesn't work for you in particular, maybe you should first ask a question to clarify why it doesn't. – Jens May 10 '13 at 21:03
@Jens If you had provide the definition of these non-standard alias, that would be a wonderful answer. I was so annoyed to find that the alias not working. I am sorry to down-vote your answer in a bad mood. I am now willing to up-vote your answer if you could accommodate my code in your answer for those who did not have the alias predefined in their system. – Everett You May 10 '13 at 21:19
On v9, enter Options[EvaluationNotebook[], InputAliases] and see what you get. – rcollyer May 10 '13 at 21:55
I'm using v9 and [Esc]ket[Esc] works perfectly. – RunnyKine May 10 '13 at 23:30

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.