Sort of crossposted to https://math.meta.stackexchange.com/questions/3845/mathjax-custom-commands
MathJax allows the use of \newcommand
in TeX. For example, this command:
\newcommand{\lorentz}[1]{\frac{#1}{\sqrt{1-\frac{v^2}{c^2}}}}
would be pretty useful in lots of situations. If this was placed somewhere in the body (AFAIK before it is called), then \lorentz{m_0}
would give the expression for relativistic mass. \lorentz{1}
would give the normal lorentz factor. lorentz{m_0c^2}
gives us the expression for energy.
Like this, I can think up quite a lot of TeXcodes that are tedious to type, but crop up often. \frac{1}{2}
and \frac{1}{\sqrt{2}}
are some (smaller and less tedious) examples. A few more commands that quickly give expressions for the nabla operator, div, grad, curl would be nice as well.
Basically, is there any way that we can have a user-dictated commandset?
IMO, it's easy to code it, just keep "$$ *insert commands here* $$" at the top of the <body>
tag. Less easy to code would be the way to make it user-dictated, but I'm thinking something akin to the way Community Promotion Ads - 2012 works would be easy to implement, as the code is already there. Just modify it so that it takes all the mathjax in the body of an answer with enough upvotes and appends it to some div in the beginning of the body tag (set display:none just to be safe).
Thoughts? Suggestions? Rants? Cookies?
\rangle
s. Can we at least get\ket{x}
? $\endgroup$\ket{..}
.. And any other thingy you can think of. Its better if you tell me which key combination for which function(alt or ctrl+key). Just make sure the markdown editor doesn't use 'em already. $\endgroup$\ket{}
? That won't render, though. The beauty of TeX commands is that they read (more or less) like equations sound in one's head. My ideal solution would be a central core of customized commands (i.e. including\ket{}
), which one could then personalize on the profile page. (Though I'm aware this is getting close to the pony tag.) $\endgroup$|(cursor)\rangle
. Remember the cursor will auto-position itself. So, the flow is like this:dollar symbol;psi;=;alt-k;1;right arrow to leave ket;+;alt-k;0;right arrow;dollar
for $\psi=|1\rangle+|0\rangle$. OK, I guess it can get complicated :/ (But it fits beautifully into the flow when typing chemical equations on chem.SE, so it may work) $\endgroup$\ket{}
and have it come out right is a valuable end in itself. Given that putting$\newcommand{\ket}[1]{|#1\rangle}$
on top of a post currently works, it shouldn't be unthinkable to define a core+personalized header that gets included on all posts, or all posts that use it. $\endgroup$