Difference between revisions of "Units"

From Wiki
Jump to navigation Jump to search
m (category math added)
m (added a few units)
Line 2: Line 2:
  
 
The units module comes with ConTeXt's default distribution, and can be accessed via <cmd>usemodule</cmd>[units].
 
The units module comes with ConTeXt's default distribution, and can be accessed via <cmd>usemodule</cmd>[units].
The following is copied from the source file <tt>m-units.tex</tt> and only slightly modified:
+
The following is copied from the source file [[source:m-units.tex|m-units.tex]] and only slightly modified:
  
 
----
 
----
Line 50: Line 50:
 
===Macros defined in units===
 
===Macros defined in units===
  
* Modifiers: <cmd>Square</cmd>, <cmd>Cubic</cmd>, <cmd>Inverse</cmd>, <cmd>Pico</cmd>, <cmd>Nano</cmd>, <cmd>Micro</cmd>, <cmd>Milli</cmd>, <cmd>Centi</cmd>, <cmd>Deci</cmd>, <cmd>Hecto</cmd>, <cmd>Kilo</cmd>, <cmd>Mega</cmd>, <cmd>Giga</cmd>, <cmd>Tera</cmd>
+
* Prefixes: <cmd>Atto</cmd> a, <cmd>Femto</cmd> f, <cmd>Pico</cmd> p, <cmd>Nano</cmd> n, <cmd>Micro</cmd> μ, <cmd>Milli</cmd> m, <cmd>Centi</cmd> c, <cmd>Deci</cmd> d, <cmd>Hecto</cmd> h, <cmd>Kilo</cmd> k, <cmd>Mega</cmd> M, <cmd>Giga</cmd> G, <cmd>Tera</cmd> T, <cmd>Peta</cmd> P, <cmd>Exa</cmd> E (missing: <cmd>Zetta</cmd> Z, <cmd>Yotta</cmd> Y, <cmd>Zepto</cmd> z, <cmd>Yocto</cmd> y)
 +
* Suffixes: <cmd>Linear</cmd> <sup>1</sup>, <cmd>Square</cmd> <sup>2</sup>, <cmd>Cubic</cmd> <sup>3</sup>, <cmd>Inverse</cmd> or <cmd>ILinear</cmd> <sup>-1</sup>, <cmd>ISquare</cmd> <sup>-2</sup>, <cmd>ICubic</cmd> <sup>-3</sup>
 
* Fraction: <cmd>Per</cmd>, <cmd>Percent</cmd>, <cmd>Permille</cmd>, <cmd>Promille</cmd>
 
* Fraction: <cmd>Per</cmd>, <cmd>Percent</cmd>, <cmd>Permille</cmd>, <cmd>Promille</cmd>
 
* Time: <cmd>Second</cmd>, <cmd>Minute</cmd>, <cmd>Hour</cmd>, <cmd>Day</cmd>, <cmd>Month</cmd>, <cmd>Year</cmd>
 
* Time: <cmd>Second</cmd>, <cmd>Minute</cmd>, <cmd>Hour</cmd>, <cmd>Day</cmd>, <cmd>Month</cmd>, <cmd>Year</cmd>
 
* Length, Area, Volume: <cmd>Meter</cmd>, <cmd>Angstrom</cmd>, <cmd>Foot</cmd>, <cmd>Inch</cmd>, <cmd>Liter</cmd>
 
* Length, Area, Volume: <cmd>Meter</cmd>, <cmd>Angstrom</cmd>, <cmd>Foot</cmd>, <cmd>Inch</cmd>, <cmd>Liter</cmd>
 
* Mass, Force and Pressure: <cmd>Gram</cmd>, <cmd>Atom</cmd>, <cmd>Newton</cmd>, <cmd>Pascal</cmd>, <cmd>Mol</cmd>, , <cmd>at</cmd>, <cmd>Atm</cmd>, <cmd>Bar</cmd>, <cmd>Force</cmd>
 
* Mass, Force and Pressure: <cmd>Gram</cmd>, <cmd>Atom</cmd>, <cmd>Newton</cmd>, <cmd>Pascal</cmd>, <cmd>Mol</cmd>, , <cmd>at</cmd>, <cmd>Atm</cmd>, <cmd>Bar</cmd>, <cmd>Force</cmd>
* Energy and Electricity: <cmd>Joule</cmd>, <cmd>Watt</cmd>, <cmd>Cal</cmd>, <cmd>Farad</cmd>, <cmd>Ohm</cmd>, <cmd>Siemens</cmd>, <cmd>Ampere</cmd>, <cmd>Coulomb</cmd>, <cmd>Volt</cmd>, <cmd>Tesla</cmd>, <cmd>VoltAC</cmd>, <cmd>VoltDC</cmd>, <cmd>EVolt</cmd>
+
* Energy and Electricity: <cmd>Joule</cmd>, <cmd>Watt</cmd>, <cmd>Cal</cmd>, <cmd>Farad</cmd>, <cmd>Henry</cmd>, <cmd>Ohm</cmd>, <cmd>Siemens</cmd>, <cmd>Ampere</cmd>, <cmd>Coulomb</cmd>, <cmd>Volt</cmd>, <cmd>Tesla</cmd>, <cmd>Gauss</cmd>, <cmd>VoltAC</cmd>, <cmd>VoltDC</cmd>, <cmd>EVolt</cmd>
 
* Temperature: <cmd>Degrees</cmd>, <cmd>Kelvin</cmd>, <cmd>Celsius</cmd>, <cmd>Fahrenheit</cmd>
 
* Temperature: <cmd>Degrees</cmd>, <cmd>Kelvin</cmd>, <cmd>Celsius</cmd>, <cmd>Fahrenheit</cmd>
 
* Angle: <cmd>Rad</cmd>, <cmd>Deg</cmd>
 
* Angle: <cmd>Rad</cmd>, <cmd>Deg</cmd>
Line 61: Line 62:
 
* Chemistry and Radiation: <cmd>Atom</cmd>, <cmd>Mol</cmd>, <cmd>Molair</cmd>, <cmd>Equivalent</cmd>, <cmd>Bequerel</cmd>, <cmd>Sievert</cmd>
 
* Chemistry and Radiation: <cmd>Atom</cmd>, <cmd>Mol</cmd>, <cmd>Molair</cmd>, <cmd>Equivalent</cmd>, <cmd>Bequerel</cmd>, <cmd>Sievert</cmd>
 
* Informatics: <cmd>Baud</cmd>, <cmd>Bit</cmd>, <cmd>Byte</cmd>
 
* Informatics: <cmd>Baud</cmd>, <cmd>Bit</cmd>, <cmd>Byte</cmd>
* Other (please sort in): <cmd>Gray</cmd>, <cmd>Weber</cmd>, <cmd>Henry</cmd>, <cmd>Sterant</cmd>, <cmd>Gauss</cmd>
+
* Other (please sort in): <cmd>Gray</cmd>, <cmd>Weber</cmd>, <cmd>Sterant</cmd>
 
* some old dutch (not listed)
 
* some old dutch (not listed)
  
 
[[Category:Math]]
 
[[Category:Math]]

Revision as of 05:52, 18 December 2005

< Math >

The units module comes with ConTeXt's default distribution, and can be accessed via \usemodule[units]. The following is copied from the source file m-units.tex and only slightly modified:


Scientific units can be typeset in math mode pretty well, but occasionally one has to take care of spacing. Furthermore, entering these units is not that natural as wanted. Therefore this module presents a more natural way of doing things, like:

1.23 \Cubic \Meter \Per \Second

This example shows that we use the order in which we say things, instead of typeset things. There is no dedicated manual for this module, but an article (in dutch) has been published in [Maps#21], the journal of the NTG.


This runtime loadable module implements a way of defining units. The core macro is \dimension, a rather clever one that is able to cooperate with some other dimension related macros. As said, this module enables user to enter:

Some 10 \Square \Meter \Per \Second\ or more.

(Note that the space after \Second needs to be explicitly specified; otherwise, it will get eaten.)

The units itself are implemented as synonyms.

\definesynonyms [unit] [units] [\unitmeaning]
\setupsynonyms [unit] [textstyle=\dimension]

This definition means that we can ask for the meaning of a unit using \unitmeaning and get a list of used units by saying \placelistofunits.

We have to use the command \unitmeaning instead of \meaning, simply because the latter is a TeX primitive we don't want to lose. We use the label text mechanism for translations.


Macros defined in units