Changes

Jump to navigation Jump to search
1,097 bytes removed ,  08:28, 2 July 2022
m
Text replacement - "pragma-ade.com" to "pragma-ade.nl"
< [[Math]] [[Physics]] >
The units module comes with ConTeXt's default distribution. In MkIV the units module comes built-in, however there is still the option to access the old module and can be accessed its commands via <{{cmd>|usemodule</cmd>}}[units].
However, Additional documentation about units in MkIV we have integrated an upgrade to this mechanism so if you're using that version you might want to skip this first partis available from the [[http://www.pragma-ade.nl/general/manuals/units-mkiv.pdf Units manual]]
Additional documentation about units ===Using the built-in command=== In MkIV is available from you can use the [[httpbuilt-in {{cmd|unit}} command to parse units. Some examples of this are shown below<texcode>10 \unit{km/h}\unit{10 km/wwwh}\unit{~1 km/h}\unit{KiloMeter/Hour}\unit{10 cubic meter / second}\unit{kilo pascal square meter / second}\unit{kilo pascal square meter / kelvin second }$\unit{10 AC}$\frac{10 \unit{m/s}}{20 \unit{m/s}}${\ss 30 \unit{kilo pascal square meter / second kelvin}}\unit{123.pragma22^-ade3 km/s}\unit{123.com22e-3 km/generals}</manualstexcode> ConTeXt will take care of spacing and formatting. The parser is fairly flexible, and the following all work and give the same output. {| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>\unit{10 kg}\unit{10kg}\unit{10 kilo gram}\unit{10 kilogram}\unit{10 Kilo Gram}\unit{10 KiloGram}</units-texcode>||<context mode=mkiv>\startlines\unit{10 kg}\unit{10kg}\unit{10 kilo gram}\unit{10 kilogram}\unit{10 Kilo Gram}\unit{10 KiloGram}\stoplines</context>|} The command works in text as well as in math mode and spaces are normally ignored. You can define your own command:  <texcode>\defineunits[un][alternative=text,separator=medium]</texcode> Valid separators are <code>cdot</code>, <code>big</code>, <code>medium</code>, and <code>space</code> with the first being the default.pdf Units manualYou can later tune the rendering with  <texcode>\setupunits[un][separator=cdot]</texcode> In due time there will be a few more options. Numbers are formatted cf the digits mechanism (not discussed here). ===Using the old units module===
The following is copied from the source file [[source:m-units.tex|m-units.tex]] and only slightly modified:
* This runtime loadable module implements a way of defining units. The core macro is <{{cmd>|dimension</cmd>}}, a rather clever one that is able to cooperate with some other dimension related macros. As said, this module enables user to enter:
<context source="yes">
</context>
(Note that the space after <{{cmd>|Second</cmd> }} needs to be explicitly specified; otherwise, it will get eaten.)
* Units act upon signals that they insert in the text, in case no quantity is given you need to start the unit sequence using <{{cmd>|Unit</cmd>}}
<context source="yes">
</texcode>
This definition means that we can ask for the meaning of a unit using <{{cmd>|unitmeaning</cmd> }} and get a list of used units by saying <{{cmd>|placelistofunits</cmd>}}.
We have to use the command <{{cmd>|unitmeaning</cmd> }} instead of <{{cmd>|meaning</cmd>}}, simply because the latter is a TeX primitive we don't want to lose. We use the label text mechanism for translations.
----
External link:
[[httphttps://www.unceasyunitconverter.educom/~rowlett/units/index.html How Many? A Dictionary of Units of MeasurementEasy Unit Converter]]
* 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>}}* 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>}}* 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, Electricity and Magnetism: <{{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>}}, <{{cmd>|Weber</cmd>}}* Temperature: <{{cmd>|Degrees</cmd>}}, <{{cmd>|Kelvin</cmd>}}, <{{cmd>|Celsius</cmd>}}, <{{cmd>|Fahrenheit</cmd>}}* Angle: <{{cmd>|Rad</cmd>}}, <{{cmd>|Deg</cmd>}}, <{{cmd>|Sterant</cmd>}}* Frequency, Optics and Acoustics: <{{cmd>|Hertz</cmd>}}, <{{cmd>|RevPerSec</cmd>}}, <{{cmd>|RevPerMin</cmd>}}, <{{cmd>|Candela</cmd>}}, <{{cmd>|Lux</cmd>}}, <{{cmd>|Bell</cmd>}}* Chemistry and Radiation: <{{cmd>|Atom</cmd>}}, <{{cmd>|Mol</cmd>}}, <{{cmd>|Molair</cmd>}}, <{{cmd>|Equivalent</cmd>}}, <{{cmd>|Bequerel</cmd>}}, <{{cmd>|Sievert</cmd>}}, <{{cmd>|Gray</cmd>}}* Informatics: <{{cmd>|Baud</cmd>}}, <{{cmd>|Bit</cmd>}}, <{{cmd>|Byte</cmd>}}
* some old dutch (not listed)
===Using the built-in command=== In MkIV you can use the built-in <cmd>unit</cmd> command. This time we don't use commands, if only because it is somewhat cumbersome. Let's give Define a few examples:  <texcode>10 \unit{km/h}\unit{10 km/h}\unit{~1 km/h}\unit{KiloMeter/Hour}\unit{10 cubic meter / second}\unit{kilo pascal square meter / second}\new unit{kilo pascal square meter / kelvin second }$\unit{10 AC}$\frac{10 \unit{m/s}}{20 \unit{m/s}}${\ss 30 \unit{kilo pascal square meter / second kelvin}}\unit{123.22^-3 km/s}\unit{123.22e-3 km/s}</texcode> The command works in text as well as in math mode and spaces are normally ignored. You can define your own command:  <texcode>\defineunits[un][alternative=text,separator=medium]</texcode> Valid separators are <code>cdot</code>, <code>big</code>, <code>medium</code>, and <code>space</code> with the first being the default. You can later tune the rendering with  <texcode>\setupunits[un][separator=cdot]</texcode> In due time there will be a few more options. Numbers are formatted cf the digits mechanism (not discussed here).  ===Expressing Physical quantities=== A physical quantity is number plus unit, and should not be split. A simple way to do this follows - define your own macro: <texcode>\define[3]\physicalquantityle{\hbox{#1 \times \lunit{10^#2 #3}}}</texcode> You can then write\physicalquantityle{number}{exponent}{unit} This seems to give better results than any other way I have found of combining digits and units. The full range of variants allow expression of physical quantities with and without exponents, with units in long form or not:<texcode>\define[2]\physicalquantity{\hbox{\unit{#1 #2}}}% \physicalquantity{number}{unit} -- gives short form of unit\define[2]\physicalquantityl{\hbox{\lunit{#1 #2}}}% \physicalquantityl{number}{unit} -- gives long form of unit\define[3]\physicalquantitye{\hbox{#1 \times \lunit{10^#2 #3}}}% \physicalquantitye{number}{exponent}{unit} -- gives short form of unit\define[3]\physicalquantityle{\hbox{#1 \times \lunit{10^#2 #3}}}% \physicalquantityle{number}{exponent}{unit} -- gives long form of unit</texcode>  You can also do ranges of units, that are otherwise messy to code up on an individual basis  <texcode>\define[3]\physicalquantityspread{\hbox{#1\endash \lunit{#2 #3}}}</texcode> You can then write:\physicalquantityspread{start}{end}{unit} 
<context source="yes">
\usemodule[units]
\unit[Mynewunit]{Nu}{New Unit}
10 \Mynewunit
</context>
[[Category:MathSciences]]
[[Category:Modules]]

Navigation menu