Expressions

From ConTeXt wiki
Revision as of 17:08, 2 February 2009 by Braslau (talk | contribs) (Created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

< 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 optionally terminated by one \relax (that 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.

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)