I am trying to have the ket symbol which is usually written in latex as \ket{\psi}
. However, this doesn't work when written within the $$ ... $$
. This also doesn't work when written using IPython.display
.
相关问题
- Why shouldn't I use pixels as unit with Box2D?
- Library to convert latex to png in Java
- Access IPython's profile history (history.sqli
- Change a SKPhysicsBody's body shape
- Error: missing \begin{document} in LaTeX [closed]
相关文章
- cython in jupyter notebook
- python: ignoring leading “>>>” and “…” in interact
- Position resizable circles near each other
- Markdown: How to reference an item in a numbered l
- how to print source code of object I defined use
- IPython won't start
- Ipython kernel error after uninstalling anaconda
- how to align kable and ggplot in one row (side by
So your
\ket
macro is coming from some package or other which I don't know what it is. This doesn't explain why it doesn't work in$$ ... $$
-- you have to work at it to get things to not work in display math -- but it does explain why it doesn't work in IPython: whichever package this is isn't being loaded in IPython's canned TeX environment (or) IPython's emulation of TeX math input language does not include this macro.Here's a reasonable definition in terms of primitive math symbols, which should work fine in display mode. I don't know if you can put this into IPython verbatim, but you should at least be able to write out the expansion longhand when needed (e.g.
$$ \left| \psi \right\rangle $$
)EDIT: define macros using LaTeX preferred interface, rather than primitive
\def
.I was able to extend @zwol 's answer to create a \braket command as well for use in a Jupyter notebook:
Gives:
IPython uses MathJax to render LaTeX in the notebook. MathJax is great but only supports a subset of LaTeX hence there are some limitations. See MathJax homepage for details.
A new command like proposed by @Zack will work fine though. Be aware that such custom commands will likely lead to some issues when converting to LaTeX (nbconvert).