• Create BookmarkCreate Bookmark
• Create Note or TagCreate Note or Tag
• PrintPrint

### A.3. Control structure extensions

#### A.3.1. calc—Arithmetic calculations

The package calc (by Kresten Thorup and Frank Jensen) contains a set of macros for enhanced arithmetic in LaTeX. Usual arithmetic in TeX is done by simple low-level operations like \advance and \multiply. This package defines an infix notation arithmetic for LaTeX. In fact, it reimplements the LaTeX commands \setcounter, \addtocounter, \setlength, and \addtolength so that they can accept integer and length expressions rather than simple numbers and lengths.

An integer expression can contain integer numbers, TeX’s integer registers, LaTeX’s counters (e.g., \value{ctr}), parentheses, and binary operators (-, +, *, /). For instance, to advance a counter by five:

A-3-1

An example is the definition of a command to print the time (note that the TeX register \time contains the number of minutes since midnight):

PREVIEW

Not a subscriber?

Start A Free Trial

• Create BookmarkCreate Bookmark
• Create Note or TagCreate Note or Tag
• PrintPrint