# Defining macros for Mathjax extension

⇠ Back to Blog:Hacks


mwMathJaxConfig.js

There's already a list of definitions. The syntax is not the most obvious as it needs to translates $\mathrm{\TeX}$ syntax into javascript. Macros I use all the times are:


And this needs be written:

bra: ['{\\left\\langle #1\\right|}',1], ket: ['{\\left| #1\\right\\rangle}',1], ud: ['{#1^{\\dagger}}',1], Tr: '\\mathrm{Tr}'

This turns, e.g., $$\ud{a}\ket{n}=\sqrt{n+1}\ket{n+1}$$ into:

$$\ud{a}\ket{n}=\sqrt{n+1}\ket{n+1}$$