Mc-Zen / zero

Advanced scientific number formatting for Typst.
https://typst.app/universe/package/zero
MIT License
30 stars 2 forks source link

Possible to render as string instead of math mode #2

Closed aszenz closed 2 months ago

aszenz commented 2 months ago

I'm using this library for formatting numbers like amounts and quantities in an Invoice without using scientific numbering, currently the numbers are shown differently (font) since they are rendered in math mode.

It is difficult to override math styles and keep them in sync with other text styles, so it would be great if the library provided a way to render the output as just text

Mc-Zen commented 2 months ago

Hi @aszenz ,

this sounds doable! Returning a plain string won't be possible because num will become a type when user-defined types are available with Typst but returning content should be fine.

I think, the best idea, would be to add a boolean parameter math to num that can be configured via

#set-num(math: false)
aszenz commented 2 months ago

Hi @aszenz ,

this sounds doable! Returning a plain string won't be possible because num will become a type when user-defined types are available with Typst but returning content should be fine.

I think, the best idea, would be to add a boolean parameter math to num that can be configured via

#set-num(math: false)

Sounds good, will that resolve the styling issues, I'm assuming content will be styled the same as the rest of the text in the document.

Mc-Zen commented 2 months ago

Yes, in the current draft it looks like this:


#set text(font: "Allura")
Default mode: #num[234,3]

#set-num(math: false)
No math: #num[234,3]

image

Mc-Zen commented 1 month ago

Hi @aszenz , this is now available by the way (import "@preview/zero:0.2.0")

aszenz commented 1 month ago

Hi @aszenz , this is now available by the way (import "@preview/zero:0.2.0")

Thanks I'm already using, great work!!