Command/unit

From ConTeXt wiki
Jump to: navigation, search

\unit

Syntax

\unit{...}
{...} number and/or physical units

Description

The \unit command typesets physical units, with or with a number preceding them. Units and their prefixes may be spelled out or abbreviated, with or without spaces or initial capitals; this will be converted to the correct abbreviated form and typeset. Any numbers that are encountered after units are assumed to be powers; one may also write e.g. squared meter. Multiplication is implicit; division may be written as per. The font automatically adapts to the environment.

The number before the digits is interpreted as just that, a number. There are a few special characters you can put in to format it; most importantly, e123 is interpreted as times 10^123. The ^{...} used to be interpreted as a synonym for e, but nowadays[nov 2012] it functions in the normal TeX way, namely to typeset an exponent.

. a decimal mark (default) or a number separator
, a number separator (default) or a decimal mark
@ or _ or ~ a number-sized space
 : a separator-sized space

Example

Various ways to write a unit:

\startlines
1: 10 \unit{km/h}
2: 10 \unit{KiloMeter/Hour}
3: 10 \unit{kilometer/hour}
4: 10 \unit{kilometer per hour}
5: 10 \unit{km / h}
6: 10 \unit{ km / h }
7: 10 \unit{km/h2}
8: \unit{123.22^-3 km/s}
9: \unit{123.22e-3 km/s}
10: {\ss 30 \unit{kilo pascal square meter / second kelvin}}
11: $\frac{10 \unit{m/s}}{20 \unit{m/s}} $
\stoplines

Units automatically have a space put in front of them.

[\unit{micro ohm}]\par    %  space before unit
[10\unit {micro ohm}]\par %  space before unit
[10 \unit{micro ohm}]\par %  space before unit
[ \unit  {micro ohm}]\par %  space before unit
[\unit{10 micro ohm}]\par %  space before unit

There are various ways put separators in numbers:

\starttabulate[|l|l|l|]
\HL
\NC \unit{10 kilo gram}       \NC \digits{10}        \NC \unit{10}        \NC \NR
\NC \unit{1 kilogram}         \NC \digits{1}         \NC \unit{1}         \NC \NR
\NC \unit{0.1 kilogram}       \NC \digits{0.1}       \NC \unit{0.1}       \NC \NR
\NC \unit{1.1 kilogram}       \NC \digits{1.1}       \NC \unit{1.1}       \NC \NR
\NC \unit{11 kilogram}        \NC \digits{11}        \NC \unit{11}        \NC \NR
\HL
\NC \unit{00,000.10 kilogram} \NC \digits{00,000.10} \NC \unit{00,000.10} \NC \NR
\NC \unit{@@,@@0.10 kilogram} \NC \digits{@@,@@0.10} \NC \unit{@@,@@0.10} \NC \NR
\NC \unit{__,___.10 kilogram} \NC \digits{__,___.10} \NC \unit{__,___.10} \NC \NR
\NC \unit{__,__0:10 kilogram} \NC \digits{__,__0:10} \NC \unit{__,__0:10} \NC \NR
\NC \unit{__,___:10 kilogram} \NC \digits{__,___:10} \NC \unit{__,___:10} \NC \NR
\HL
\stoptabulate

See also

Help from ConTeXt-Mailinglist/Forum

All issues with:

C O N T E X T G A R D E N

Personal tools
Namespaces
Variants
Actions
Help
External Help
Installation
Navigation
Toolbox