Difference between revisions of "Units"

From Wiki
Jump to navigation Jump to search
(new)
 
m (Added typeset examples, and changed a note into a TODO tag.)
Line 1: Line 1:
 
< [[Math]] >
 
< [[Math]] >
  
The units module comes with ConTeXt's default distribution.
+
The units module comes with ConTeXt's default distribution, and can be accessed via <cmd>\usemodule[units]</cmd>.
 
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 <tt>m-units.tex</tt> and only slightly modified:
  
Line 12: Line 12:
 
1.23 \Cubic \Meter \Per \Second
 
1.23 \Cubic \Meter \Per \Second
 
</texcode>
 
</texcode>
 +
 +
<context>
 +
\usemodule[units]
 +
1.23 \Cubic \Meter \Per \Second
 +
</context>
  
 
This example shows that we use the order in which we say things, instead of typeset things. There is a separate [http://www.pragma-ade.com/general/manuals/ manual for this module].  
 
This example shows that we use the order in which we say things, instead of typeset things. There is a separate [http://www.pragma-ade.com/general/manuals/ manual for this module].  
  
--> link is dead, couldn't find the manual --[[User:Hraban|Hraban]]
+
{{todo|Link is dead, couldn't find the manual --[[User:Hraban|Hraban]]}}
  
 
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:
 
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:
  
 
<texcode>
 
<texcode>
some 10 \Square \Meter \Per \Second or more
+
Some 10 \Square \Meter \Per \Second\ or more.
 
</texcode>
 
</texcode>
 +
 +
<context>
 +
\usemodule[units]
 +
Some 10 \Square \Meter \Per \Second\ or more.
 +
</context>
 +
 +
(Note that the space after <cmd>Second</cmd> needs to be explicitly specified; otherwise, it will get eaten.)
  
 
The units itself are implemented as synonyms.
 
The units itself are implemented as synonyms.
Line 38: 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>, <cmd></cmd>
+
* 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>
 
* 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>

Revision as of 05:06, 5 September 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 a separate manual for this module.


TODO: Link is dead, couldn't find the manual --Hraban (See: To-Do List)


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 loose. We use the label text mechanism for translations.


Macros defined in units