| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% |
| 5 |
% The LaTeX Project and any individual authors listed elsewhere |
| 6 |
% in this file. |
| 7 |
% |
| 8 |
% This file is part of the Standard LaTeX `Tools Bundle'. |
| 9 |
% ------------------------------------------------------- |
| 10 |
% |
| 11 |
% It may be distributed and/or modified under the |
| 12 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 13 |
% of this license or (at your option) any later version. |
| 14 |
% The latest version of this license is in |
| 15 |
% https://www.latex-project.org/lppl.txt |
| 16 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 17 |
% version 2005/12/01 or later. |
| 18 |
% |
| 19 |
% The list of all files belonging to the LaTeX `Tools Bundle' is |
| 20 |
% given in the file `manifest.txt'. |
| 21 |
% |
| 22 |
% \fi |
| 23 |
% \iffalse |
| 24 |
%% File: delarray.dtx Copyright (C) 1991-1994 David Carlisle |
| 25 |
% |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 27 |
%<package>\ProvidesPackage{delarray} |
| 28 |
%<package> [2014/10/28 v1.01 array delimiter package (DPC)] |
| 29 |
% |
| 30 |
%<*driver> |
| 31 |
\documentclass{ltxdoc} |
| 32 |
\usepackage{delarray} |
| 33 |
\GetFileInfo{delarray.sty} |
| 34 |
\begin{document} |
| 35 |
\title{The \textsf{delarray} package\thanks{This file |
| 36 |
has version number \fileversion, last |
| 37 |
revised \filedate.}} |
| 38 |
\author{David Carlisle} |
| 39 |
\date{\filedate} |
| 40 |
\MaintainedByLaTeXTeam{tools} |
| 41 |
\maketitle |
| 42 |
\DocInput{delarray.dtx} |
| 43 |
\end{document} |
| 44 |
%</driver> |
| 45 |
% \fi |
| 46 |
% |
| 47 |
% |
| 48 |
% \changes{v1.00}{1992/07/06} |
| 49 |
% {Initial version after merging of newarray.sty to array.sty} |
| 50 |
% |
| 51 |
% \changes{v1.01}{1994/03/14} |
| 52 |
% {Update to LaTeX2e} |
| 53 |
% |
| 54 |
% |
| 55 |
% \section{Examples} |
| 56 |
% |
| 57 |
% |
| 58 |
% The addition to {\tt array.sty} added in {\tt delarray.sty} is |
| 59 |
% a system of implicit |\left| |\right| pairs. If you want an array |
| 60 |
% surrounded by parentheses, you can enter:\\ |
| 61 |
% |\begin{array}({cc})| \ldots |
| 62 |
% \[ \begin{array}({cc})a&b\\c&d\end{array} \] |
| 63 |
% |
| 64 |
% Similarly if an environment equivalent to \PlainTeX's |\cases| could |
| 65 |
% be defined by:\\ |
| 66 |
% |\begin{array}\{{lL}.| \ldots |
| 67 |
% |
| 68 |
% \newcolumntype{L}{>{$}l<{$}} |
| 69 |
% \[ f(x)=\begin{array}\{{lL}. |
| 70 |
% 0 &if $x=0$\\ |
| 71 |
% \sin(x)/x&otherwise |
| 72 |
% \end{array} \] |
| 73 |
% Here |L| is supposed to denote a column of left aligned L-R text. It |
| 74 |
% may be defined via: |\newcolumntype{L}{>{$}l<{$}}|, as discussed in |
| 75 |
% {\tt array.sty}. |
| 76 |
% Note that as the delimiters must always be used in pairs, the `|.|' |
| 77 |
% must be used to denote a `null delimiter'. |
| 78 |
% |
| 79 |
% This feature is especially useful if the |[t]| or |[b]| |
| 80 |
% arguments are also used. In these cases the result is not equivalent |
| 81 |
% to surrounding the environment by |\left|\ldots|\right|, as |
| 82 |
% can be seen from the following example: |
| 83 |
% \[ |
| 84 |
% \begin{array}[t]({c}) 1\\2\\3 \end{array} |
| 85 |
% \begin{array}[c]({c}) 1\\2\\3 \end{array} |
| 86 |
% \begin{array}[b]({c}) 1\\2\\3 \end{array} |
| 87 |
% \quad\mbox{not}\quad |
| 88 |
% \left(\begin{array}[t]{c} 1\\2\\3 \end{array}\right) |
| 89 |
% \left(\begin{array}[c]{c} 1\\2\\3 \end{array}\right) |
| 90 |
% \left(\begin{array}[b]{c} 1\\2\\3 \end{array}\right) |
| 91 |
% \] |
| 92 |
% \begin{verbatim} |
| 93 |
% \begin{array}[t]({c}) 1\\2\\3 \end{array} |
| 94 |
% \begin{array}[c]({c}) 1\\2\\3 \end{array} |
| 95 |
% \begin{array}[b]({c}) 1\\2\\3 \end{array} |
| 96 |
% \quad\mbox{not}\quad |
| 97 |
% \left(\begin{array}[t]{c} 1\\2\\3 \end{array}\right) |
| 98 |
% \left(\begin{array}[c]{c} 1\\2\\3 \end{array}\right) |
| 99 |
% \left(\begin{array}[b]{c} 1\\2\\3 \end{array}\right) |
| 100 |
% \end{verbatim} |
| 101 |
% |
| 102 |
% |
| 103 |
% \MaybeStop{} |
| 104 |
% |
| 105 |
% \section{The Macros} |
| 106 |
% |
| 107 |
% \begin{macrocode} |
| 108 |
%<*package> |
| 109 |
% \end{macrocode} |
| 110 |
% |
| 111 |
% \begin{macrocode} |
| 112 |
\RequirePackage{array}[1994/02/03] |
| 113 |
% \end{macrocode} |
| 114 |
% |
| 115 |
% \begin{macro}{\@tabarray} |
| 116 |
% This macro tests for an optional bracket and then calls up |
| 117 |
% |\@@array| or |\@@array[c]| (as default). |
| 118 |
% \begin{macrocode} |
| 119 |
\def\@tabarray{\@ifnextchar[{\@@array}{\@@array[c]}} |
| 120 |
% \end{macrocode} |
| 121 |
% \end{macro} |
| 122 |
% \begin{macro}{\@@array} |
| 123 |
% This macro tests for an optional delimiter before the left brace |
| 124 |
% of the main preamble argument. If there is no delimiter, |
| 125 |
% |\@arrayleft| and |\@arrayright| are made a no-ops, and |
| 126 |
% |\@array| is called with the positional argument. Otherwise |
| 127 |
% call |\@del@array|. |
| 128 |
% \begin{macrocode} |
| 129 |
\def\@@array[#1]{\@ifnextchar\bgroup |
| 130 |
{\let\@arrayleft\relax\let\@arrayright\relax\@array[#1]}% |
| 131 |
{\@del@array[#1]}} |
| 132 |
% \end{macrocode} |
| 133 |
% \end{macro} |
| 134 |
% \begin{macro}{\@del@array} |
| 135 |
% We now know that we have an {\tt array} (or {\tt tabular}) with |
| 136 |
% delimiters. |
| 137 |
% \begin{macrocode} |
| 138 |
\def\@del@array[#1]#2#3#4{% |
| 139 |
% \end{macrocode} |
| 140 |
% The following line is completely redundant but it does catch errors |
| 141 |
% involving delimiters before the processing of the alignment begins. |
| 142 |
% A common error is likely to be omitting the `.' in a |
| 143 |
% |\cases|-type construction. This causes the first token of the |
| 144 |
% alignment to be gobbled, possibly causing lots of spurious errors |
| 145 |
% before the cause of the error, the missing delimiter, is discovered as |
| 146 |
% |\@arrayright| puts the alignment and the delimiters together. |
| 147 |
% \begin{macrocode} |
| 148 |
\setbox\z@\hbox{$\left#2\right#4$}% |
| 149 |
% \end{macrocode} |
| 150 |
% In the case of a `c' argument we do not need to rebox the alignment, |
| 151 |
% so we can define |\@arrayleft| and |\@arrayright| just to |
| 152 |
% insert the delimiters. |
| 153 |
% \begin{macrocode} |
| 154 |
\if#1c\def\@arrayleft{\left#2}\def\@arrayright{\right#4}% |
| 155 |
% \end{macrocode} |
| 156 |
% Otherwise we (should) have a {\tt[t]} or {\tt[b]} argument, so first we |
| 157 |
% store the alignment, without delimiters in box0. |
| 158 |
% \begin{macrocode} |
| 159 |
\else\def\@arrayleft{\setbox\z@}% |
| 160 |
% \end{macrocode} |
| 161 |
% Then after the alignment is finished: |
| 162 |
% \begin{macrocode} |
| 163 |
\def\@arrayright{% |
| 164 |
% \end{macrocode} |
| 165 |
% Calculate the amount the box needs to be lowered (this will be |
| 166 |
% negative in the case of |[b]|). A little bit of arithmetic cf.\ |
| 167 |
% the \TeX{}Book, Appendix G, rule 8. We calculate the amount this |
| 168 |
% way, rather than just taking the difference between the depth of box0 |
| 169 |
% and the depth of the box defined below, as the depth of that box may |
| 170 |
% be affected by the delimiters if |\delimitershortfall| or |
| 171 |
% |\delimiterfactor| have non-standard values. |
| 172 |
% \begin{macrocode} |
| 173 |
\dimen@=\dp\z@ |
| 174 |
\advance\dimen@-\ht\z@ |
| 175 |
\divide \dimen@ by \tw@ |
| 176 |
\advance\dimen@ by\fontdimen22 \textfont\tw@ |
| 177 |
% \end{macrocode} |
| 178 |
% Now lower the alignment and the delimiters into place. |
| 179 |
% \begin{macrocode} |
| 180 |
\lower\dimen@\hbox{$\left#2\vcenter{\unvbox\z@}\right#4$}}% |
| 181 |
% \end{macrocode} |
| 182 |
% End the |\if#1c| |
| 183 |
% \begin{macrocode} |
| 184 |
\fi |
| 185 |
% \end{macrocode} |
| 186 |
% Now that we have defined |\@arrayleft| and |\@arrayright|, call |
| 187 |
% |\@array|. |
| 188 |
% \begin{macrocode} |
| 189 |
\@array[#1]{#3}} |
| 190 |
% \end{macrocode} |
| 191 |
% \end{macro} |
| 192 |
% |
| 193 |
% \begin{macrocode} |
| 194 |
%</package> |
| 195 |
% \end{macrocode} |
| 196 |
% |
| 197 |
% |
| 198 |
% \subsection{newarray.sty} |
| 199 |
% All the features of the old {\tt newarray} style option have been |
| 200 |
% merged into the {\tt array} or {\tt delarray} options. |
| 201 |
% \changes{v1.00}{1992/07/06} |
| 202 |
% {Stop generating a `shell' newarray.sty} |
| 203 |
% |
| 204 |
% |
| 205 |
% \Finale |
| 206 |
\endinput |