In LyX, what is a quick way to insert mismatched delimiters in math environment?

I tried typing \left|\right>, but it is not interpreted automatically.

  • 1
    Better to use $|\psi\rangle$ for inlines and \left|\psi\right\rangle for stretchy kets. Avoid using >.
    – qubyte
    Mar 14, 2012 at 16:32
  • 5
    I don't know about Lyx, but there's the braket package.
    – cgnieder
    Mar 14, 2012 at 16:36

5 Answers 5


There are at least three different ways one can write such brackets, using ERTs or the LyX GUI.

1. Use \left/\right directly

To be able to write \left|\right\rangle, you have to use ERTs, which you add with Insert --> TeX code or Ctrl + L. Add an ERT for the \left|, exit the ERT, for example by hitting the right arrow key, write the term that should be within the delimiters, then finally add another ERT for \right\rangle.

2. Braket

The braket package mentioned by cgnieder defines eight new commands, \Bra, \Ket, \Braket and \Set which uses \left and \right to stretch the delimiters, and similar commands all lowercase (\bra,\ket,\braket,\set), which doesn't have stretchable delimiters. See below for how it looks in LyX and the corresponding output.

To use this in LyX you can do as follows:

  1. Add the package to the document preamble. Under Document --> Properties --> LaTeX preamble write \usepackage{braket}.

  2. When in mathmode, add an ERT with Ctrl + L. (This isn't actually necessary.)

  3. Write the command you want to use. The second curly brace will be autocompleted when you type the first (at least in my copy of LyX).

LyX View and PDF view of braket-package

3. GUI

The GUI-version is to click the Insert delimiters-button on the math toolbar and uncheck "Keep matched".

insert delimiters button and dialog in LyX


My personal preference is to define keyboard shortcuts for the three items.

  1. Go to Tools->Preferences->Editing->Shortcuts.
  2. For <|>, click "new", and add math-insert \left\langle | \right\rangle, with the key Alt+Q Shift+|.
  3. For |> click "new", and add math-insert \left| \right\rangle, with the key Alt+Q Shift+>.
  4. For <|, click "new", and add math-insert \left\langle \right|, with the key Alt+Q Shift+<.
  5. For <||> click "new", and add math-insert \left\langle \left| \right| \right\rangle, with the key Alt+Q =.

This way you don't need to use the GUI each time, not the braket package, and avoid having non-WYSIWYG items in your document.


Here is a quicker way: Predefined vectors are offered by the LaTeX-package braket that is loaded with the LaTeX-preamble line:

When you open a new document, go to Documents > Settings > LaTeX-preamble. Then type into the field:


Now, go back to your new document and type:

\Bra{\psi}  <---a bra will show
\Ket {\psi}  <----a ket will show
\Braket{\psi|\psi}  <--- the inner product: <x|x>

Hope this helps.


I love the braket package but creating shortcuts was by far the best option when it comes to speed and intuitive use. I went to Tools->Preferences->Editing->Shortcuts and created new shortcuts like:

Example of my ket:

Latex code: math-insert \left\vert \right\rangle with the shortcut "Ctrl+Shift+k".

I encourage you to define it your own way, with the keys that make more sense to you.


For those of you who are here to type bra-ket notation for Markdown or web applications, you can try the following method:

\newcommand{\bra}[1]{\left \langle #1 \right \rvert}
\newcommand{\ket}[1]{\left \rvert #1 \right \rangle}
\newcommand{\E}[1]{\left \langle #1 \right \rangle}
\newcommand{\braket}[2]{\left \langle #1 \middle \rvert #2 \right \rangle}
\newcommand{\braxket}[3]{\left \langle #1 \middle \rvert #2 \middle \rvert #3 \right \rangle}

\bra{\Psi}, \;
\ket{\varphi}, \;
\E{\frac{\Psi^\dag\Psi}{2/3}}, \;
\braket{\frac{\Psi}{2/3}}{\varphi}, \;

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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