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"]
  • 3
    $\begingroup$ Would you please post code for that expression? $\endgroup$ Feb 21, 2013 at 5:58
  • 3
    $\begingroup$ When my kets started getting big, way back when, I simply stopped feeding them. They still haven't forgotten. $\endgroup$ May 10, 2013 at 21:20

3 Answers 3


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.

  • $\begingroup$ 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. $\endgroup$
    – orome
    Feb 21, 2013 at 17:07
  • 1
    $\begingroup$ Thanks - there is a hole in the docs for this. If you say ?Ket you get nothing. $\endgroup$
    – Jens
    Feb 21, 2013 at 17:18
  • $\begingroup$ @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. $\endgroup$ May 10, 2013 at 21:03
  • $\begingroup$ @EverettYou Jens' answer works perfectly fine here on mma9 and I haven't loaded anything. $\endgroup$
    – rm -rf
    May 11, 2013 at 1:23
  • 2
    $\begingroup$ @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. $\endgroup$
    – rcollyer
    May 11, 2013 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]"]
  • 3
    $\begingroup$ Ket? Bra? That's some weird science. $\endgroup$
    – Mr.Wizard
    Feb 21, 2013 at 8:28
  • $\begingroup$ I made it red to highlight it. $\endgroup$
    – orome
    Feb 21, 2013 at 14:03
  • $\begingroup$ @raxacoricofallapatorius this is why posting code would be useful. I corrected text. $\endgroup$ Feb 21, 2013 at 14:49
  • $\begingroup$ @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. $\endgroup$
    – Jens
    Feb 21, 2013 at 17:14
  • $\begingroup$ @Mr.Wizard yes! It's a complete weird science! And very beautiful too. :) $\endgroup$
    – Murta
    Feb 21, 2013 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.

  • 5
    $\begingroup$ 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. $\endgroup$
    – Jens
    May 10, 2013 at 21:03
  • $\begingroup$ @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. $\endgroup$ May 10, 2013 at 21:19
  • $\begingroup$ On v9, enter Options[EvaluationNotebook[], InputAliases] and see what you get. $\endgroup$
    – rcollyer
    May 10, 2013 at 21:55
  • $\begingroup$ I'm using v9 and [Esc]ket[Esc] works perfectly. $\endgroup$
    – RunnyKine
    May 10, 2013 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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