The intervals package^{∗}

Andrew D. Lewis

1998/04/03

1 Using the intervals macros

\interval This is pretty basic. You type

\interval{[,(}leftlimit,rightlimit{],)}

to specify an interval in ℝ (the real numbers). Thus, to get an open interval type \interval(a,b) for example. A closed interval is \interval[a,b] and so on for half-open intervals. If rightlim consists of more than one token, it should be enclosed in {} to make it a single token.

I sometimes write open intervals as ]a, b[ which looks ugly, but doesn’t create confusion with ordered pairs. In fact, this is the default with intervals. If you

\roundopens want open intervals as (a, b) use the command \roundopens. There is also a \squareopens command \squareopens which will reset to the default. You may also specify the

bracket type with options roundopens and squareopens to intervals.

2 Implementation

1 ⟨∗package⟩

Setup options.

2

 3 \DeclareOption{roundopens}{\def\@ADL@@roundopens{\@ne}}
 4 \DeclareOption{squareopens}{\def\@ADL@@roundopens{\z@}}
 5 \ExecuteOptions{squareopens}
 6 \ProcessOptions

The macros. This is straightforward.

7

 8 \newcommand\@ADLdef@@roundopens{%
 9 \def\interval{\@ifnextchar({\@ADL@openleftint}{\@ADL@closedleftint}}
10 \def\@ADL@openleftint(##1,##2{(##1,##2%
11 \@ifnextchar){\@ADL@openrightint}{\@ADL@closedrightint}}
12 \def\@ADL@closedleftint[##1,##2{[##1,##2%

∗This file has version number v1.1b, last revised 1998/04/03.

13 \@ifnextchar){\@ADL@openrightint}{\@ADL@closedrightint}}
14 \def\@ADL@openrightint){)}
15 \def\@ADL@closedrightint]{]}

16 }

17 \newcommand\@ADLdef@@squareopens{%
18 \def\interval{\@ifnextchar({\@ADL@openleftint}{\@ADL@closedleftint}}
19 \def\@ADL@openleftint(##1,##2{\,]##1,##2%
20 \@ifnextchar){\@ADL@openrightint}{\@ADL@closedrightint}}
21 \def\@ADL@closedleftint[##1,##2{[##1,##2%
22 \@ifnextchar){\@ADL@openrightint}{\@ADL@closedrightint}}
23 \def\@ADL@openrightint){[\,}
24 \def\@ADL@closedrightint]{]}

25 }

26 \newcommand\roundopens{\@ADLdef@@roundopens}
27 \newcommand\squareopens{\@ADLdef@@squareopens}
28 \ifnum\@ADL@@roundopens=\@ne\roundopens\else\squareopens\fi

29 ⟨/package⟩