chhecker / unify Goto Github PK
View Code? Open in Web Editor NEWFormat numbers, units, and ranges in Typst correctly.
License: MIT License
Format numbers, units, and ranges in Typst correctly.
License: MIT License
It would be nice if unicode exponents could be used to write units.
normal:
#qty("2.5", "J mol^-1 K^-1")
unicode:
#qty("2.5", "J mol⁻¹ K⁻¹")
It should be possible to set the default decimal separator. I tried doing
#set _format-float(decsep: ",")
$ num("2.0") $
as I prefer to leave the numbers in code with dots (yet want it to show up as 2,0), but it throws a syntax error. Any way to set that in another way?
(originally typst/packages#188)
Hi.
Sorry to disturb you.
When I tried to use the coulomb measurement ubit, it didn't work.
I realized, as in the attachement, that there was a typo in the unit.csv file, probabbly it is necessary to remove the character ".
By the way, in LaTeX SIunits, when you type the scientific notation the multiplication sign is a times and not a dot. Could it be possible to have the possibility tto choice between a dot or times symbol also in your package (I attach a file to be clearer).
Thank a lot and sorry for my bad English.
Best regards,
Roberto
units.csv.pdf
Generic.pdf
#unit("hz")
⇒ h
(hecto ?)#unit("Hz")
⇒ zH
(zepto Henry)Results of #qty
is similar.
I am using v0.4.2 and I've verified this issue on current main (d2ab4c3).
Don't use units-short: #unit("hertz")
works as expected.
h
is a valid prefix (hecto or 100).H
is a valid unit (Henry).z
is a valid prefix (zepto or Therefore the checks pass, and we try to parse z
and fail. However, we don't #panic
and let it go…
In #format-unit-short
, remove the else if
in the for
loop…
Lines 230 to 232 in d2ab4c3
if acc.len() > 0 {
panic("invalid unit: " + quantity)
}
This will make #unit("hz")
into error: panicked with: "invalid unit: hz"
.
In the same for
loop, add and unit == none
in this if, because the prefix must appear before the unit:
Lines 223 to 225 in d2ab4c3
This will make #unit("Hz")
into error: panicked with: "invalid unit: Hz"
.
Warning
This does NOT make #unit("Hz")
⇒ Hz
, because #format-unit-short
is eager — it consumes H
as Henry first.
I suggest a bigger refactor of the parsing logic in #format-unit-short
…
quantity in units-short
, unit = units-short.at(quantity)
, ✓.quantitiy
into two parts, if the first part is a prefix and the second is a unit, ✓.panic
.How do you think so? If you agree but are busy, I can try to work out a PR.
Typically, the only units you don't use spaces before are a lone-standing degree symbol and primes. This means there should be one if the unit is "°C", "°F" etc., since the "°" has a "suffix" (see e.g. [https://german.stackexchange.com/a/322]).
The Dyne is used in astronomy in the cgs unit system.
I'm looking for a way to add custom units (e.g., "hours") while importing unify from @preview
.
According to the Readme:
The possible values of the three latter parts are loaded at runtime from prefixes.csv, units.csv, and postfixes.csv (in the library directory). There, you can also add your own units.
However, when importing from @preview
, these CSVs aren't available to me.
Would it make sense to either
units
, units-short
, etc., as state
and add a function for easily adding a new unit, prefix, or postfix; or_format-unit
defaulting to the existing dictionaries, which should allow users to use set
rules to specify the extended dictionaries?A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.