Unify: square brackets around units

For context:

In my field it is common to mark units with square brackets, so they are not confused with constants or variables. e.:

  • g gravity ↔ [g] gram
  • m mass ↔ [m] metre
  • l length ↔ [l] litre (though some capitalize it)
  • s strecke ↔ [s] second

This is why I wanted to have square brackets around units in unify (or fancy-units maybe too). And I wanted to have that automatically and globally.

Here the code so far:

// I turned myself into a bracket! I am bracket-unit!

#import "@preview/unify:0.8.1": num, unit as unify-unit

#let qty(value, unit-value, ..args) = {
  num(value, ..args)
  h(0.1em)
  [[#unify-unit(unit-value, ..args)]]
}

#let unit(unit-value, ..args) = {
  [[#unify-unit(unit-value, ..args)]]
}

#qty("123","m") \
#qty("123e-2","m") \
#unit("m")

which gives:

I have not made changes for qtyrange yet, I will add it later, or maybe someone here would like to add it.

Please also tell me if there is a simpler way to do this and if i can summarize this into a single callable function or a global option of some sort.

A solution for fancy-units would be nice too

Usually i call a single #let UnitSetup... from another file with a #show: UnitSetup

But I am unsure how this will jive with an import of a package inside it.

As mentioned in:

Am I the only one who needs this? I have found nothing thus far