Page MenuHomePhabricator

Support LaTeX macro \ket as shortcut for \left\vert #1\right\rangle
Open, MediumPublic1 Estimated Story PointsFeature

Description

Being able to use commands provided by some common LaTeX packages with the "native" mode of the Math extension of MediaWiki would be very beneficial. The packages I have in mind (apart from the obvious amsmath and mathtools) are physics and siunitx, from which most of the commands are relevant.

For instance, being able to simply write \ket{\psi} is a very basic functionality for any quantum physics related article, and the alternative \left\vert \psi \right\rangle very time consuming and error prone. Same goes for \pdv{f}{x}{y}. Having an implementation of common packages also allows to copy equation from personal drafts without time-consuming rewriting, hence easing the contributions.

To go beyond the packages I propose, the selection of packages implemented in Mathjax and LaTeXML is relevant.

Event Timeline

Physikerwelt subscribed.

\ket{#1} -> \left\vert \psi #1 \rangle can be done, if this is desired by the community.

For, \pdv{f}{x}{y} more information is needed. I suggest opening a separate ticket for that.

Physikerwelt renamed this task from Adding LaTeX commands from common LaTeX packages for Math native mode to Support LaTeX macro \ket as shortcut for \left\vert #1\right\rangle.Feb 21 2025, 6:57 AM
Physikerwelt set the point value for this task to 1.

Of course the implementation should be

\ket{#1} -> \left\vert #1 \right\rangle

to scale the symbols in case of a more complex formula; and at that point we may also define

\bra{#1} = \left\langle #1 \right\vert

for completeness. I don't think this definition should break anything, but I am not very expert.

Hi, I tried to implement the function on a test instance, but I struggled.
I see in texutil.json that there exists a nullary_macro_aliase way to define a command, but there don't seems to be any unnary_macro_aliase.
I also spotted the macro callback, but it don't seems functional except in some specific cases (\TeX and \boxed are not).

Is there a way to implement it you would recommend?

Aklapper removed Due Date which was set to Mar 13 2025, 11:00 PM.Jun 8 2026, 6:44 AM