rule | input | output |
---|---|---|
'^' creates a superscript | m^2 | m2 |
'_' creates a subscript | h_0 | h0 |
subscripts and superscripts can be combined | h_0^3 | h03 |
use '[_subscript^superscript]' to create an overstrike | h[_0^3] | h3 0 |
a '/' at the beginning adds the superscript '-1' | /s | s−1 |
hyphen is transformed to minus sign when preceding a unit | -h^2 | −h2 |
'x' at the beginning is transformed to '×' | x10^3 kg^2 m^-1 | ×103 kg2 m−1 |
ASCII terms from biology/chemistry turned into terminology forms | ug | µg |
can create italics with '*' or '_'; create bold text with '**' or '__' | *m*^**2** | m2 |
special symbol set surrounded by colons | :permille:C | ‰C |
chemistry notation: '%C6H6%' | g/L %C6H12O6% | g/L C6H12O6 |
define_units
define_units(units_notation)
With define_units()
you can work with a specially-crafted units notation string and emit the units as HTML (with the .to_html()
method). This function is useful as a standalone utility and it powers the fmt_units()
method in Great Tables.
Parameters
units_notation :
str
-
A string of units notation.
Returns
:
UnitDefinitionList
-
A list of unit definitions.
Specification of units notation
The following table demonstrates the various ways in which units can be specified in the units_notation
string and how the input is processed by the define_units()
function. The concluding step for display of the units in HTML is to use the to_html()
method.