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