Difference between revisions of "Expressions"
m |
(→Expressions: I removed the "optional" for \relax. It actually isn't, except in a controlled environment) |
||
Line 11: | Line 11: | ||
by one of the commands <code>\numexpr</code>, <code>\dimexpr</code>, | by one of the commands <code>\numexpr</code>, <code>\dimexpr</code>, | ||
<code>\glueexpr</code>, or <code>\muexpr</code> | <code>\glueexpr</code>, or <code>\muexpr</code> | ||
− | (determining the type <i>t</i>) and | + | (determining the type <i>t</i>) and terminated by <code>\relax</code> (which |
will be absorbed by the scanning mechanism). An expression consists of one | will be absorbed by the scanning mechanism). An expression consists of one | ||
or more terms of the same type to be added or subtracted; a term of type <i>t</i> | or more terms of the same type to be added or subtracted; a term of type <i>t</i> |
Revision as of 18:20, 2 February 2009
< Main Page | Inside ConTeXt >
ConTeXt implements extensions from eTeX including the evaluation of expressions (quoted from the [eTeX manual]):
Expressions
eTeX introduces the notion of expressions of type number, dimen, glue, or
muglue, that can be used whenever a quantity of that type is needed. Such
expressions are evaluated by eTeX's scanning mechanism; they are initiated
by one of the commands \numexpr
, \dimexpr
,
\glueexpr
, or \muexpr
(determining the type t) and terminated by \relax
(which
will be absorbed by the scanning mechanism). An expression consists of one
or more terms of the same type to be added or subtracted; a term of type t
consists of a factor of that type, optionally multiplied and/or
divided by numeric factors; finally a factor of type t is either a
parenthesized subexpression or a quantity (number, etc.) of that type.
Examples
It has been pointed out that
the only important thing for \dimexpr
is to write the dimen value
as first value after the \dimexpr
command and then the numeric values.
Notice that the following expression is also valid:
\placesidebyside {\externalfigure[cow][width=.4\textwidth]} {\framed[width=.4\textwidth,height=\dimexpr.4\textwidth*200/275\relax] {\vbox{this is a box}}}
TODO: Add more illustrative examples. (See: To-Do List) |