sisetup.unit

sisetup.unit(unit, **unit_kw)

Returns the LaTeX code for the given unit.

Parameters:
unitpython:str

The unit to be typeset as a string. Multiple units can be combined using a semicolon ";" inbetween. The units can be combined with a prefix, e.g. "kilo.meter" and a power, which can be specified by either a number or key word again seperated with a dot ".". The following examples are equivalent: "kilo.meter.-2", "per.kilo.meter.2", "per.kilo.meter.squared", "per.square.kilo.meter".

**unit_kw

Keyword arguments to overwrite the options in sisetup.unit_kw. The options are only overwritten for this call.

Returns:
python:str

The LaTeX code for the given unit.

Return type:

str

Examples

>>> from mplunitx import sisetup
>>> si = sisetup()
>>> si.unit("per.square.kilo.meter")
'$\mathrm{km}^{-2}$'