https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Rsneha&feedformat=atomWiki - User contributions [en]2024-03-29T11:53:21ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Units&diff=25736Units2020-03-30T09:24:45Z<p>Rsneha: /* Macros defined in units */</p>
<hr />
<div>< [[Math]] [[Physics]] ><br />
<br />
The units module comes with ConTeXt's default distribution, and can be accessed via <cmd>usemodule</cmd>[units].<br />
<br />
However, in MkIV we have integrated an upgrade to this mechanism so if you're using that version you might want to skip this first part.<br />
<br />
Additional documentation about units in MkIV is available from the [[http://www.pragma-ade.com/general/manuals/units-mkiv.pdf Units manual]]<br />
<br />
The following is copied from the source file [[source:m-units.tex|m-units.tex]] and only slightly modified:<br />
<br />
----<br />
<br />
* Scientific units can be typeset in math mode pretty well, but occasionally one has to take care of spacing.<br />
Furthermore, entering these units is not that natural as wanted. Therefore this module presents a more natural way of doing things, like:<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
1.23 \Cubic \Meter \Per \Second<br />
</context><br />
<br />
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) <br />
has been published in [[http://www.ntg.nl/maps/pdf/21_16.pdf Maps#21]], the journal of the NTG.<br />
<br />
<br />
* 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:<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
Some 10 \Square \Meter \Per \Second\ or more.<br />
</context><br />
<br />
(Note that the space after <cmd>Second</cmd> needs to be explicitly specified; otherwise, it will get eaten.)<br />
<br />
<br />
* 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><br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
Units of measurement is \Unit \Milli \Meter<br />
</context><br />
<br />
The units itself are implemented as synonyms.<br />
<br />
<texcode><br />
\definesynonyms [unit] [units] [\unitmeaning]<br />
\setupsynonyms [unit] [textstyle=\dimension]<br />
</texcode><br />
<br />
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>.<br />
<br />
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.<br />
<br />
----<br />
<br />
===Macros defined in units===<br />
<br />
External link: <br />
[[https://www.easyunitconverter.com/ Easy Unit Converter]]<br />
<br />
* 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)<br />
* 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><br />
* Fraction: <cmd>Per</cmd>, <cmd>Percent</cmd>, <cmd>Permille</cmd>, <cmd>Promille</cmd><br />
* Time: <cmd>Second</cmd>, <cmd>Minute</cmd>, <cmd>Hour</cmd>, <cmd>Day</cmd>, <cmd>Month</cmd>, <cmd>Year</cmd><br />
* Length, Area, Volume: <cmd>Meter</cmd>, <cmd>Angstrom</cmd>, <cmd>Foot</cmd>, <cmd>Inch</cmd>, <cmd>Liter</cmd><br />
* 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><br />
* 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><br />
* Temperature: <cmd>Degrees</cmd>, <cmd>Kelvin</cmd>, <cmd>Celsius</cmd>, <cmd>Fahrenheit</cmd><br />
* Angle: <cmd>Rad</cmd>, <cmd>Deg</cmd>, <cmd>Sterant</cmd><br />
* Frequency, Optics and Acoustics: <cmd>Hertz</cmd>, <cmd>RevPerSec</cmd>, <cmd>RevPerMin</cmd>, <cmd>Candela</cmd>, <cmd>Lux</cmd>, <cmd>Bell</cmd><br />
* Chemistry and Radiation: <cmd>Atom</cmd>, <cmd>Mol</cmd>, <cmd>Molair</cmd>, <cmd>Equivalent</cmd>, <cmd>Bequerel</cmd>, <cmd>Sievert</cmd>, <cmd>Gray</cmd><br />
* Informatics: <cmd>Baud</cmd>, <cmd>Bit</cmd>, <cmd>Byte</cmd><br />
* some old dutch (not listed)<br />
<br />
===Define a new unit===<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
\unit[Mynewunit]{Nu}{New Unit}<br />
<br />
10 \Mynewunit<br />
<br />
</context><br />
<br />
===Using the built-in command===<br />
<br />
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 a few examples: <br />
<br />
<texcode><br />
10 \unit{km/h}<br />
\unit{10 km/h}<br />
\unit{~1 km/h}<br />
\unit{KiloMeter/Hour}<br />
\unit{10 cubic meter / second}<br />
\unit{kilo pascal square meter / second}<br />
\unit{kilo pascal square meter / kelvin second }$<br />
\unit{10 AC}<br />
$\frac{10 \unit{m/s}}{20 \unit{m/s}}$<br />
{\ss 30 \unit{kilo pascal square meter / second kelvin}}<br />
\unit{123.22^-3 km/s}<br />
\unit{123.22e-3 km/s}<br />
</texcode><br />
<br />
The command works in text as well as in math mode and spaces are normally ignored. You can define your own command: <br />
<br />
<texcode><br />
\defineunits[un][alternative=text,separator=medium]<br />
</texcode><br />
<br />
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 <br />
<br />
<texcode><br />
\setupunits[un][separator=cdot]<br />
</texcode><br />
<br />
In due time there will be a few more options. Numbers are formatted cf the digits mechanism (not discussed here). <br />
<br />
<br />
<br />
[[Category:Math]]<br />
[[Category:Modules]]</div>Rsnehahttps://wiki.contextgarden.net/index.php?title=Units&diff=25735Units2020-03-30T09:23:13Z<p>Rsneha: /* Macros defined in units */</p>
<hr />
<div>< [[Math]] [[Physics]] ><br />
<br />
The units module comes with ConTeXt's default distribution, and can be accessed via <cmd>usemodule</cmd>[units].<br />
<br />
However, in MkIV we have integrated an upgrade to this mechanism so if you're using that version you might want to skip this first part.<br />
<br />
Additional documentation about units in MkIV is available from the [[http://www.pragma-ade.com/general/manuals/units-mkiv.pdf Units manual]]<br />
<br />
The following is copied from the source file [[source:m-units.tex|m-units.tex]] and only slightly modified:<br />
<br />
----<br />
<br />
* Scientific units can be typeset in math mode pretty well, but occasionally one has to take care of spacing.<br />
Furthermore, entering these units is not that natural as wanted. Therefore this module presents a more natural way of doing things, like:<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
1.23 \Cubic \Meter \Per \Second<br />
</context><br />
<br />
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) <br />
has been published in [[http://www.ntg.nl/maps/pdf/21_16.pdf Maps#21]], the journal of the NTG.<br />
<br />
<br />
* 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:<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
Some 10 \Square \Meter \Per \Second\ or more.<br />
</context><br />
<br />
(Note that the space after <cmd>Second</cmd> needs to be explicitly specified; otherwise, it will get eaten.)<br />
<br />
<br />
* 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><br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
Units of measurement is \Unit \Milli \Meter<br />
</context><br />
<br />
The units itself are implemented as synonyms.<br />
<br />
<texcode><br />
\definesynonyms [unit] [units] [\unitmeaning]<br />
\setupsynonyms [unit] [textstyle=\dimension]<br />
</texcode><br />
<br />
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>.<br />
<br />
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.<br />
<br />
----<br />
<br />
===Macros defined in units===<br />
<br />
External link: <br />
[[https://www.easyunitconverter.com/]]<br />
<br />
* 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)<br />
* 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><br />
* Fraction: <cmd>Per</cmd>, <cmd>Percent</cmd>, <cmd>Permille</cmd>, <cmd>Promille</cmd><br />
* Time: <cmd>Second</cmd>, <cmd>Minute</cmd>, <cmd>Hour</cmd>, <cmd>Day</cmd>, <cmd>Month</cmd>, <cmd>Year</cmd><br />
* Length, Area, Volume: <cmd>Meter</cmd>, <cmd>Angstrom</cmd>, <cmd>Foot</cmd>, <cmd>Inch</cmd>, <cmd>Liter</cmd><br />
* 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><br />
* 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><br />
* Temperature: <cmd>Degrees</cmd>, <cmd>Kelvin</cmd>, <cmd>Celsius</cmd>, <cmd>Fahrenheit</cmd><br />
* Angle: <cmd>Rad</cmd>, <cmd>Deg</cmd>, <cmd>Sterant</cmd><br />
* Frequency, Optics and Acoustics: <cmd>Hertz</cmd>, <cmd>RevPerSec</cmd>, <cmd>RevPerMin</cmd>, <cmd>Candela</cmd>, <cmd>Lux</cmd>, <cmd>Bell</cmd><br />
* Chemistry and Radiation: <cmd>Atom</cmd>, <cmd>Mol</cmd>, <cmd>Molair</cmd>, <cmd>Equivalent</cmd>, <cmd>Bequerel</cmd>, <cmd>Sievert</cmd>, <cmd>Gray</cmd><br />
* Informatics: <cmd>Baud</cmd>, <cmd>Bit</cmd>, <cmd>Byte</cmd><br />
* some old dutch (not listed)<br />
<br />
===Define a new unit===<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
\unit[Mynewunit]{Nu}{New Unit}<br />
<br />
10 \Mynewunit<br />
<br />
</context><br />
<br />
===Using the built-in command===<br />
<br />
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 a few examples: <br />
<br />
<texcode><br />
10 \unit{km/h}<br />
\unit{10 km/h}<br />
\unit{~1 km/h}<br />
\unit{KiloMeter/Hour}<br />
\unit{10 cubic meter / second}<br />
\unit{kilo pascal square meter / second}<br />
\unit{kilo pascal square meter / kelvin second }$<br />
\unit{10 AC}<br />
$\frac{10 \unit{m/s}}{20 \unit{m/s}}$<br />
{\ss 30 \unit{kilo pascal square meter / second kelvin}}<br />
\unit{123.22^-3 km/s}<br />
\unit{123.22e-3 km/s}<br />
</texcode><br />
<br />
The command works in text as well as in math mode and spaces are normally ignored. You can define your own command: <br />
<br />
<texcode><br />
\defineunits[un][alternative=text,separator=medium]<br />
</texcode><br />
<br />
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 <br />
<br />
<texcode><br />
\setupunits[un][separator=cdot]<br />
</texcode><br />
<br />
In due time there will be a few more options. Numbers are formatted cf the digits mechanism (not discussed here). <br />
<br />
<br />
<br />
[[Category:Math]]<br />
[[Category:Modules]]</div>Rsneha