Open main menu

Changes

83 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}}[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:
</context>
 
===Using the built-in command===
 
In MkIV you can use the built-in {{cmd|unit}} command. This time we don't use commands, if only because it is somewhat cumbersome. Let's give 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}
\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>
 
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}
</texcode>
|
|<context mode=mkiv>
\starttext
\startlines
\unit{10 kg}
\unit{10kg}
\unit{10 kilo gram}
\unit{10 kilogram}
\unit{10 Kilo Gram}
\unit{10 KiloGram}
\stoplines
\stoptext
</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. 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).
 
[[Category:Sciences]]
[[Category:Modules]]