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.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIn LyX, what is a quick way to insert mismatched delimiters in math environment?
I tried typing \left|\right>
, but it is not interpreted automatically.
There are at least three different ways one can write such brackets, using ERTs or the LyX GUI.
\left
/\right
directlyTo 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
.
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:
Add the package to the document preamble. Under Document --> Properties --> LaTeX preamble write \usepackage{braket}
.
When in mathmode, add an ERT with Ctrl + L. (This isn't actually necessary.)
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).
The GUI-version is to click the Insert delimiters-button on the math toolbar and uncheck "Keep matched".
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:
\usepackage{braket}
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.
braket
package in my answer as well (the last part).
– Torbjørn T.
Jan 8 '13 at 20:46
My personal preference is to define keyboard shortcuts for the three items.
<|>
, click "new", and add math-insert \left\langle | \right\rangle
,
with the key Alt+Q Shift+|
.|>
click "new", and add math-insert \left| \right\rangle
, with the key Alt+Q Shift+>
.<|
, click "new", and add math-insert \left\langle \right|
, with the key Alt+Q Shift+<
.<||>
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.
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.
$|\psi\rangle$
for inlines and\left|\psi\right\rangle
for stretchy kets. Avoid using>
. – qubyte Mar 14 '12 at 16:32braket
package. – cgnieder Mar 14 '12 at 16:36