Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support physical units #129

Open
suruena opened this issue May 16, 2021 · 2 comments
Open

Support physical units #129

suruena opened this issue May 16, 2021 · 2 comments

Comments

@suruena
Copy link

suruena commented May 16, 2021

Currently, it's cumbersome to write physical units with AsciiMath, for example: 42\ "N" = 42\ "kg"*"m"//"s"^2

Note that \ (escaping the space) is needed to ensure an space is inserted between the number and the unit, double quotes to ensure the unit symbol is not in italics, and // to have the usual division style. Furthermore, it's not possible to use double quotes when the unit symbol contains a Greek character (such as microsecods), so as far as I know it's not possible to show those units symbols with the correct typography.

It would be very nice if AsciiMath provided some specific syntax for correctly representing physical units easily, maybe when surrounded by apostrophes or something similar:

42 'N'= 42 'kg*m/s^2'

Ideally, having a simplified syntax for units would make this feature even more readable (e.g see UCUM for a plain text syntax designed for physical units), as anyway it has no sense to write any AsciiMath expression inside this units environment:

42 'N'= 42 'kg m/s2'

In both cases, this would make AsciiMath even more attractive for engineers, thank you very much.

@Tronic
Copy link

Tronic commented Dec 21, 2022

Suggesting something even simpler, e.g.

g = 9.81.m/s^2

Noting that dot directly following a number has no useful meaning (prints currently simply as a dot). Using some character other than dot could be safer, if it needs to be a strictly nonbreaking change. Either way, quotes at both ends of the unit are still quite ugly.

Units formatting also should add a narrow non-breaking space between the number and its unit where I believe \, is normally used in LaTeX for this.

Sometimes units need to be printed without a number so that is also a concern. Technically the dot prefix could also work for this:

[a] = .m/s^2

One concern is when to break out of unit mode, and in that regard the surrounding quotes are simpler. Otherwise spaces, parenthesis and division could either be part of the unit expression or a continuation of the equation (after which letters should appear as variables again).

@aslakr
Copy link

aslakr commented Jan 19, 2023

There is an old note from 2003 on how to use units in MathML https://www.w3.org/TR/mathml-units/ with a short segment on presentation MathML.

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle>
<mn>42</mn>
<mo rspace="thickmathspace">&InvisibleTimes;</mo>
<mi mathvariant="normal" class="MathML-Unit">N</mi>
<mo>=</mo>
<mn>42</mn>
<mo rspace="thickmathspace">&InvisibleTimes;</mo>
<mi mathvariant="normal" class="MathML-Unit">kg</mi>
<mo>&middot;</mo>
<mfrac>
<mi mathvariant="normal" class="MathML-Unit">m</mi>
<msup>
<mi mathvariant="normal" class="MathML-Unit">s</mi>
<mn>2</mn>
</msup>
</mfrac>
</mstyle>
</math>

One could maybe write the si units in full

42*newton = 42*kilogram*metre/second^2

a bit similar to https://ctan.org/pkg/siunitx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants