Skip to content

Units

Wrap a quantity — a value and its symbol — in unit{}.

Expression Renders as
unit{7 cm} 7cm
unit{1000 m} 1,000m
unit{7 cm^2} 7cm2
unit{5 mm^3} 5mm3
unit{45 °} 45°
unit{20 °C} 20°C
unit{4.50 €} 4.50
math{unit{2 h} unit{30 min}} 2h 30min
unit{1/2 L} 12L
math{unit{5 cm} + unit{3 cm} = unit{8 cm}} 5cm + 3cm = 8cm
The side measures unit{7 mm}. The side measures 7mm.
unit{4 dL} = unit{Q{} L} 4dL = ?L

math{} is not the right tool for this: it splits its content character by character against math_chars, so math{7 cm} sets the c of cm in the math font and the m in the text font. unit{} renders the symbol whole, in the text font.

The symbol is the trailing lexeme; everything before it is the value, parsed in math mode — so numbers are localised and fractions work. The value may also be omitted (unit{cm} renders the symbol alone) or be an answer placeholder (unit{Q{} L} above, or unit{A{} cm} for a silent one).

A no-break space separates the value from the symbol, except where the convention says otherwise: the degree sign of an angle sits against its value (45°) while °C keeps its space (20 °C). This is a property of each symbol, not something to remember at writing time.

Exponents may be written ^{2}, ^2 or ² (likewise for cubes), and are accepted on any symbol. Areas and volumes are therefore nothing more than length symbols carrying an exponent; there is no separate notation to learn.

A unit{} holds a single symbol, since everything before it is read as the value: a composite duration is two units side by side, written inside math{}math{unit{2 h} unit{30 min}}, not unit{2 h 30 min}. The math{} wrapper is what keeps the space between them; at text level, a run of pure whitespace between two keywords is dropped.

unit{} works wherever the other keywords do: at text level, inside math{}, frac{}, table{} or stack{}.

The symbol is validated. It is checked against the recognised symbols — lengths (km to mm), masses (kg to mg), capacities (kL to mL), the degree sign, °C, the euro sign and the durations h, min and s. An unrecognised symbol is an error, never a silent passthrough: that guarantee is the reason to write unit{7 cm} rather than hoping math{} guesses right, where m, g, L, h or s are just as legitimately variables. Both litre spellings (L and l, with their prefixed forms) are accepted, and the symbol is rendered exactly as written — neither is rewritten into the other.