Starting a thread about units, mag, etc. Branching off from Jeremy S's request:
Why do we mark up quantities? It's certainly not always convenient to write <quantity><mag>2</mag><unit base="meter"/></quantity> instead of just "2 m".
- semantic markup so that "m" can be understood unambiguously as "meters", etc.
- guarantee consistent styling
- otherwise, how would you get exponents and other math-y unit layout?
- more?
An existing engine already does all this: the LaTeX siunitx package. Let's use that! OK, and now we will let the tail wag the dog a bit, because if we are going to have the advantages of using this package, we will have to work around its limitations.
So we use siunitx in LaTeX output. HTML to come later. If there is both a magnitude and a unit, the LaTeX is like \SI{2}{\meter}. (That's the old, deprecated syntax. Newer is \qty{2}{\meter}.) This works both in and out of math mode. What if we want a math expression for the magnitude? With an optional parameter, the siunitx still works, still in and out of math mode: \qty[parse-numbers = false]{\frac{\pi}{2}}{\meter}. So we have "parse-numbers = false" set globally, and we just lose out on the siunitx features that come along with number parsing. For example, we lose out on letting siunitx write a million meters as 1 000 000 m (with thin spaces). To avoid having to support the #quantity element inside #m, I would ask that authors:
- use #quantity when in text content
- directly use siunitx syntax (which is semantic) when inside math content
Ah, but now HTML... We have MathJax, which does not natively handle siunitx. A former PCC colleague worked on a MJ extension:
It was supposed to be working with MJ3. Untested with MJ4. And presently, it's just his work on GitHub, not distributed in a way we could actually use it.
If we had this, those last two bullets above would work out just as nicely for HTML. Instead, the status quo is that in text content, you don't get to have math in the #mag. (We make one allowance: if you write "\pi" in your #mag, you should get good output. Just on expressions with \pi and no other math structure. So like <mag>\pi/2</mag> can work.) And if you are in math mode in the first place, we are sorry but you must use non-semantic code like <m>2\,\frac{\mathrm{m}}{\mathrm{s}}</m>.
So this is where I've been for years now. Waiting and wanting siunitx in MathJax. And then you would n't really need #m to work inside of #mag. Inside #mag, you would just always write LaTeX math. Even when it's just a number.
I would not get in the way of anyone wanting to do something different then what I've outlined here. Also if I can assist someone taking on that siuntx work for MathJax, let me know how I can help (while understanding that I do not have the javascript chops to actually do it.)