fenjalien / metro

A typst package to add typsetting to units!
Apache License 2.0
66 stars 5 forks source link

Bug(?): `minimum-decimal-digits` on integers #14

Closed Jollywatt closed 9 months ago

Jollywatt commented 9 months ago

It seems that #num(42.0, minimum-decimal-digits: 2) doesn't work as expected, rendering as $42$ instead of $42.00$.

As a side note, and I realise this might be deliberate for consistency with siunitx, but it would be great to have an option decimal-digits as well as minimum-decimal-digits, which behaves like the sprintf format %.*f. As it stands, I can't figure out how to format an arbitrary number to an exact number of decimal places without using oxifmt (e.g., #num(strfmt("{:.2}", 42))) -- but it seems a bit silly to load both packages for this!

Jollywatt commented 9 months ago

It looks like this behaviour might be intentional since metro distinguishes between #num(minimum-decimal-digits: 2)[42] and #num(minimum-decimal-digits: 2)[42.]. If so, regard this as a feature request! The problem still arises if your number is stored as data (a float).

fenjalien commented 9 months ago

Yes this is a bug but it seems to be fixed with the current dev version. I should be making a release soon!