1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
\documentclass[a4paper,article]{memoir}
\usepackage[T1]{fontenc}
\usepackage{amsmath,enumitem,showexpl}
%\usepackage[scaled]{beramono}
\title{The \textsf{interval} package}
\author{Lars Madsen\thanks{Email: daleif@imf.au.dk}\\ \small (on behalf of By the Danish \TeX\ collective)}
\setsecnumdepth{none}
%\setlength\overfullrule{5pt}
\usepackage{interval}
\begin{document}
\maketitle
\section{Motivation}
\label{sec:motivation}
In mathematics there are two syntax' when it comes to specifying open
and closed intervals.
The first use parantheses to mark an open end
\begin{align*}
[a,b] \qquad (a,b] \qquad [a,b)\qquad (a,b),
\end{align*}
while the other use brackets throughout
\begin{align*}
[a,b] \qquad ]a,b] \qquad [a,b[\qquad ]a,b[,
\end{align*}
The former poses no problem in \TeX, but the later does, as, e.g., a
closing bracket is being used in place of an opening fence, and thus
have the wrong category when it comes to spacing:
\begin{align*}
]-a,b[+c \qquad\text{versus}\qquad \mathopen{]}-a,b\mathclose{[}+c.
\end{align*}
One could use
\begin{verbatim}
\mathopen{]}-a,b\mathclose{[}+c
\end{verbatim}
to solve the problem, but then \cs{left}\dots\cs{right} can no longer
be used to auto scale the fences.
\section{The \cs{interval} command}
\label{sec:csinterval-command}
The following is the result of a discussion on the Danish \TeX\ Users
groups mailing list. Kudos to Martin Heller, for proposing the
original version using \textsf{pgfkeys}.
We provide a macro and a way to globally configure it
\begin{quote}
\cs{interval}\oarg{options}\marg{start}\marg{end}\\
\cs{intervalsetup}\marg{options}
\end{quote}
We note that the interval separator symbol is hidden inside the
\cs{interval} macro and can be changed using an option.
\subsection{Configuration options}
\label{sec:options}
\begin{description}[style=nextline,font=\sffamily\bfseries]
\item[separator symbol]
symbol that separates the start and end of the interval. Default:
\texttt{\{,\}}, note that as comma is the separating character in the
options specification, the symbol is enclosed in braces, these are
automatically removed.
\item[left open fence]
Default: \texttt{]}
\item[left closed fence]
Default: \texttt{[}
\item[right open fence]
Default: \texttt{[}
\item[right closed fence]
Default: \texttt{]}
\item[soft open fences]
This is just a fast way of saying
\begin{quote}
\ttfamily\obeylines
left open fence=(,
right open fence=)
\end{quote}
\end{description}
\subsection{Usage options}
By default \cs{interval}\marg{start}\marg{end} will produce a closed
interval. Other types are provided via options:
\begin{description}[style=nextline,font=\sffamily\bfseries]
\item[open]
an open interval
\item[open left]
interval open on the left side
\item[open right]
interval open on the right side
\item[scaled]
auto scale interval fences
\item[scaled=\meta{scaler}]
scale fences using \meta{scaler}, i.e.\ using \texttt{scaled=\cs{Big}}
\end{description}
\fancybreak{}
As some might be guessed, the \texttt{interval} package depends on the
\textsf{pgfkeys} package to handle its key-value configuration.
\newpage
\section{Examples}
\label{sec:examples}
% used for showexpl
\lstset{
explpreset={
xleftmargin=0em,
columns=fixed,
},
pos=r,
width=-99pt,
overhang=0pt,
hsep=2\columnsep,
vsep=\bigskipamount,
rframe=x,
basicstyle=\footnotesize\ttfamily,
}
\begin{LTXexample}
\begin{align*}
&A\in\interval{a}{b}\\
&A\in\interval[open]{a}{b}\\
&A\in\interval[open left]{a}{b}\\
&A\in\interval[open right,
scaled]{a}{\frac12b}=B\\
&A\in\interval[scaled=\big]{a}{b}
\end{align*}
\end{LTXexample}
And using soft open fences:
\begin{LTXexample}
\intervalconfig{
soft open fences,
separator symbol=;,
}
\begin{align*}
&A\in\interval{a}{b}\\
&A\in\interval[open]{a}{b}\\
&A\in\interval[open left]{a}{b}\\
&A\in\interval[open right,
scaled]{a}{\frac12b}=B\\
&A\in\interval[scaled=\big]{a}{b}
\end{align*}
\end{LTXexample}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
|