Symbols with units (and other <quantity> quirks)

16 views
Skip to first unread message

Sean Fitzpatrick

unread,
May 13, 2025, 5:58:09 PM5/13/25
to PreTeXt development
For numbers with units, we have the <quantity> markup, letting us write things like:

<quantity><mag>43</mag><unit prefix="centi" base="meter"/></quantity>

to get 43 cm.

It's a bit clunky, but it gets the job done.

There are limitations: the content allowed in <mag> is plain text only, with (it seems) accommodation for the use of \pi.

I am wondering if it would be desirable to allow <m> as a child of <mag>.

I can think of two use cases:

1. Negative quantities/rates. If I put something like -23 in a quantity, the minus sign is rendered as a dash, not a minus sign. That leads one to attempt something like:
<m>-</m><quantity><mag>23</mag><unit base="meter"/><per base="second"/></quantity>

2. Symbols with units: think of something like 2\pi r cm for a circumference. Right now I think I have to do:
<m>2\pi r</m><quantity><unit prefix="centi" base="meter"/></quantity>

and at that point, I am more likely to just author this as <m> 2\pi r \text{ cm}</m>.

Or is <quantity> something that we've sort of lost interest in generally?

Mark Fitch

unread,
May 14, 2025, 11:47:30 AM5/14/25
to prete...@googlegroups.com

I would be happy to see additional work on units. In my book I ran into some limitations (missing some units I think). Units in math (not just math in units) would be useful in books where we use units to help track steps (dimensional analysis).

There is a thread on pretext-support from 2019 (what is the <units> tag used for?) with some of the same ideas. The underlying package siunitx has a very recent update (May 7, 2025 on CTAN) which is a good sign.

--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/efa7bebe-e83c-466d-96ac-d94fd28cd843n%40googlegroups.com.

Alex Jordan

unread,
May 14, 2025, 12:11:22 PM5/14/25
to prete...@googlegroups.com
There is a long term plan for units, going back to when they were first put into PreTeXt long ago. The plan can be abandoned! But I can share it here.

The plan is:
  • Units in math mode. Waiting for an siunitx mathjax extension, and then you would not use the PTX "quantity" element at all. For example, <m>-\pi\unit{kg.m/s^2}</m>, or other valid siunitx syntax for unit and quantity expressions. Relatively recently Lee McPherson did this work:
    https://github.com/limefrogyank/siunitx-pcc
    And Davide Cervone was guiding that work. Unsure yet if it is ready to use, especially in MathJax 4 and especially with the latest syntax options for siunitx.
  • Units in text mode. Well, I'd think that if it is a quantity with a magnitude, does it ever make sense to not use math mode? But anyway, continuing to use the "quantity" element would be an option.

Someone could pick up on Lee's work to see how that goes for PTX. Someone could also reach out to Davide to inquire about that work ever being a native component to MathJax instead of an extension.

Or a new plan can be made.

Sean Fitzpatrick

unread,
May 14, 2025, 12:41:49 PM5/14/25
to prete...@googlegroups.com

I think units in math mode would solve everything for me.

It would be great if it gets built into MathJax, rather than needing to deal with extensions.


Rob Beezer

unread,
May 14, 2025, 1:53:42 PM5/14/25
to prete...@googlegroups.com
(Sent this last night, and it got hung up.)

On 5/13/25 3:58 PM, Sean Fitzpatrick wrote:
> Or is <quantity> something that we've sort of lost interest in generally?
We are generally very committed to everything we design markup for. ;-)

That said, Alex J is the lead on this one, so he can weigh in on the particulars
you propose. I think we may be holding out for a better "siunitx"
package/extension for MathJax, or something like that.

Rob
Reply all
Reply to author
Forward
0 new messages