newcommand for ket-bra

1,818

Solution 1

Use the braket package:

\documentclass{article}
\usepackage{braket}

\begin{document}

$\braket{\varphi|\psi}$

$\bra{\varphi}$

$\ket{\psi}$

$\ket{\varphi}\bra{\psi}$

\end{document}

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}

Share:
1,818

Related videos on Youtube

Irreversible
Author by

Irreversible

Updated on July 09, 2020

Comments

  • 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.