UNITDEF: Difference between revisions

From iMath
Jump to navigation Jump to search
(Created page with "{{Keyword | 1= <code>UNITDEF { "printname", symbol = expression }</code> | 2= Defines a new unit. The symbol is the name of the unit and must begin with a percent sign...")
 
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
|
|
1=
1=
<code>UNITDEF { "printname", [[symbol]] = [[expression]] }</code>
<code>UNITDEF { "printname", [[symbol]]&#124;[[string]] = [[expression]] }</code>
|
|
2=
2=
Defines a new unit. The symbol is the name of the unit and must begin with a percent sign % to distinguish it from a variable name. The expression defines the unit in terms of units already known to iMath. If this expression contains data types apart from units, powers of units, numerics, or constants already known to iMath, a warning is issued, but the unit definition is created anyway.  
Defines a new unit. The symbol is the name of the unit and must begin with a percent sign % to distinguish it from a variable name. If this is not possible (e.g. your unitname contains special characters like superscripts), you can use a quoted string instead. The expression defines the unit in terms of units already known to iMath. If this expression contains data types apart from units, powers of units, numerics, or constants already known to iMath, a warning is issued, but the unit definition is created anyway.  


The printname (enclosed in double quotes) is optional and gives a text to be printed instead of the symbol. This is useful when defining units whose name is not a valid symbol.
The printname (enclosed in double quotes) is optional and gives a text to be printed instead of the symbol. This is useful when defining units whose name is not a valid symbol.
Line 13: Line 13:


<code>UNITDEF{ "&#39;&#39;", %inch = 0.0254 %metre }</code> defines inches and tells iMath to print them as a double dash.
<code>UNITDEF{ "&#39;&#39;", %inch = 0.0254 %metre }</code> defines inches and tells iMath to print them as a double dash.
|
4=
[[PREFIXDEF]]
|
5=
2.2.0 or earlier. The alternative quoted string for the unit name was implemented in iMath 2.2.10
}}
}}
[[Category:Definition]]
[[Category:Definition]]

Latest revision as of 18:52, 17 April 2020

Syntax

UNITDEF { "printname", symbol|string = expression }

Implemented in iMath since version 2.2.0 or earlier. The alternative quoted string for the unit name was implemented in iMath 2.2.10.

Explanation

Defines a new unit. The symbol is the name of the unit and must begin with a percent sign % to distinguish it from a variable name. If this is not possible (e.g. your unitname contains special characters like superscripts), you can use a quoted string instead. The expression defines the unit in terms of units already known to iMath. If this expression contains data types apart from units, powers of units, numerics, or constants already known to iMath, a warning is issued, but the unit definition is created anyway.

The printname (enclosed in double quotes) is optional and gives a text to be printed instead of the symbol. This is useful when defining units whose name is not a valid symbol.

Example

UNITDEF { "", %mm = 10^{-3} %metre } defines a new unit %mm.

UNITDEF{ "''", %inch = 0.0254 %metre } defines inches and tells iMath to print them as a double dash.

See also

PREFIXDEF