![]() |
Arithmetic operations | ![]() |
Add or subtract numbers or lengths. For instance, <plus|1|2.3|5> yields 8.3 and <plus|1cm|5mm> produces . In the case of subtractions, the last argument is subtracted from the sum of the preceding arguments. For instance, <minus|1> produces -1 and <minus|1|2|3|4> yields 2.
Multiply the numbers expr-1 until expr-n. One of the arguments is also allowed to be a length, in which case a length is returned. Percentages such as 50% are also accepted as factors. For instance, <times|3|3> evaluates to 9 and <times|3|2cm> to .
Divide the product of all but the last argument by the last argument. For instance, <over|1|2|3|4|5|6|7> evaluates to 102.857, <over|3spc|7> to , and <over|1cm|1pt> to 28.4528.
Compute the result of the division of an integer expr-1 by an integer expr-2, or its remainder. For instance, <div|18|7>=2 and <mod|18|7>=4. The arguments may also be real numbers (in which case the quotient is rounded downwards) or two lengths (in which case div returns the number of times expr-2 fits into expr-1, and mod the remaining length).
Return the minimum or maximum of several numbers or several lengths. For instance, <maximum|1cm|5mm|2cm> yields .
Compute the square root, the exponential, the natural logarithm, the power \({\color{brown}{\text{{\itshape{expr-1}}}}}^{{\color{brown}{\text{{\itshape{expr-2}}}}}}\), the cosine, the sine and the tangent (with angles in radians) of real numbers. For instance, <pow|2|10> yields 1024. Notice that math-sqrt should not be confused with the sqrt primitive for typesetting roots.
Return the result of the comparison between two numbers or lengths. For instance, <less|123|45> yields false and <less|123mm|45cm> yields true. The equal and unequal primitives actually accept arbitrary expressions, which are compared as trees (except for two lengths, which are compared by value).
The blend primitive returns the color obtained by painting the (possibly transparent) color color-1 on top of color-2. The rgb-color primitive builds a color from its red, green, blue and optional alpha components, which are integers between 0 and 255. Conversely, rgb-access returns a component of a color, where component is one of r, g, b, a (or 0 until 3). Colors are returned in hexadecimal notation, such as #ff8000.