newcommand for ket-bra


Solution 1

Use the braket package:








enter image description here

Solution 2

try the command \ketbra{\phi}{\psi}, this should minimize the distance between the ket and the bra.

command \ketbra{\phi}{\psi}


Related videos on Youtube

Author by


Updated on July 09, 2020


  • Irreversible
    Irreversible over 3 years

    How can create a \newcommand that be able generate:

    |\phi\rangle\langle \psi|

    However \ket{\phi}\bra{\psi} does that but we think that the distance between ket and bra in |\phi\rangle\langle \psi| is shorter than that of \ket{\phi}\bra{\psi}.

    • Troy
      Troy almost 6 years
      \op{\phi}{\psi} from the physics package does this.
  • Mensch
    Mensch over 4 years
    Welcome to TeX.SE! Can you please add a screenshot of your result? (And no, I did not downvote!)
  • Anti Earth
    Anti Earth over 3 years
    This is actually the correct answer - use \ketbra from the physics package.
  • egreg
    egreg over 3 years
    @AntiEarth The physics package has several drawbacks.
  • orlp
    orlp over 2 years
    The spacing for the ketbra is too large.
  • egreg
    egreg over 2 years
    @orlp I believe this is a precise choice by the author of braket. Nothing prevents you from defining \newcommand{\ketbra}[2]{\mathinner{|{#1}\rangle\,\langle{#2}‌​|}} that would use just one thin space in the middle instead of two.