Debian Codegraph @

texmf-dist/source/latex/ncctools/nccmath.dtx

raw
1 % \iffalse
2 %%
3 %% File: nccmath.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko
4 %%
5 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
6 %<package>\ProvidesPackage{nccmath}
7 %<package> [2006/01/20 v1.3 Additional Math Commands (NCC)]
8 %
9 % \changes{v1.01}{2002/01/20}{This version is uploaded to CTAN}
10 % \changes{v1.02}{2002/02/19}{|\Eq|, |\Eqs|, and |\Eqalign| are removed}
11 % \changes{v1.03}{2002/03/16}{|\useshortskip| command added}
12 % \changes{v1.1}{2004/12/08}{Do |fleqn| and |ceqn| working with all display equations}
13 % \changes{v1.1}{2004/12/08}{Documentation was prepared}
14 % \changes{v1.2}{2005/02/13}{Introduce |\medmath|, |\mfrac|, |\mbinom|, |mmatrix|}
15 % \changes{v1.2}{2005/02/14}{Introduce |\medop|, |\medint|, |\medintkern|, |medsize|}
16 % \changes{v1.2}{2005/02/15}{Introduce |mediummath|}
17 % \changes{v1.2}{2005/02/16}{Remove redefinition of equations tag}
18 % \changes{v1.2}{2005/02/21}{Avoid conflicts with the |array| package}
19 % \changes{v1.3}{2006/01/20}{Introduce |\dmulticolumn| to use within |darray|}
20 %
21 %<*driver>
22 \let\makeindex\relax
23 \documentclass{ltxdoc}
24 \usepackage{nccmath,desclist}
25 \GetFileInfo{nccmath.sty}
26 \newcommand*\com[1]{{\tt\symbol{"5C}#1}}
27
28 \begin{document}
29 \title{The \textsf{nccmath} package\thanks{This file
30 has version number \fileversion, last
31 revised \filedate.}}
32 \author{Alexander I. Rozhenko\\[email protected]}
33 \date{\filedate}
34 \maketitle
35 \DocInput{nccmath.dtx}
36 \end{document}
37 %</driver>
38 % \fi
39 % The package extends the |amsmath| package adding some math
40 % commands from NCC-\LaTeX. It also improves spacing control
41 % before display equations and fixes a bug of ignoring
42 % the |\displaybreak| in the |amsmath| version of the
43 % |equation| environment. All options are passed
44 % to the |amsmath| package.
45 %
46 % \tableofcontents
47 %
48 % \section{Improvement to the amsmath}
49 %
50 % \DescribeMacro{eqnarray}
51 % In the |amsmath| package, the |eqnarray| environment leaves
52 % unchanged because alternative \AmS\ environments exist. We
53 % redefine the |eqnarray| to work in the \AmS\ style. The
54 % following improvements are done in it: an equation tag is
55 % prepared by the same manner as in \AmS\ display formulas
56 % (|\tag| and |\tag*| are allowed); the |\displaybreak|
57 % command is allowed; the intercolumn distance is reduced to the
58 % distance between ordinary and relational math symbols; and the
59 % center field is prepared in the |\displaystyle| (the original
60 % version uses |\textstyle| here).
61 %
62 % \DescribeMacro{\intertext}
63 % The |\intertext| command is improved here. It now has an optional
64 % parameter:
65 % \begin{quote}
66 % |\intertext|\oarg{distance}\marg{text}
67 % \end{quote}
68 % The \meta{distance} parameter specifies a vertical space inserted
69 % before and after the text. If it is omitted, standard \TeX's
70 % skips are inserted.
71 %
72 % The following changes are made in display equations:
73 % \begin{itemize}
74 % \item The |\displaybreak| command now works within the |equation|
75 % environment (it is ignored in the |amsmath|);
76 % \item The \AmS\ and \LaTeX\ display equations prepared in the
77 % vertical mode do not produce now an empty extra line before.
78 % Moreover, if a minipage starts from a display formula,
79 % the vertical skip before is suppressed.
80 % \end{itemize}
81 %
82 % \section{Extra Macros}
83 %
84 % \DescribeMacro{fleqn}
85 % \DescribeMacro{ceqn}
86 % The following environments allow change the horizontal alignment
87 % of formulas inside them:
88 % \begin{quote}
89 % |\begin{fleqn}|\oarg{margin} \ldots\ |\end{fleqn}|\\
90 % |\begin{ceqn}| \ldots\ |\end{ceqn}|
91 % \end{quote}
92 % The |fleqn| environment prepares inner display equations in
93 % the flush left style. The \meta{margin} parameter specifies
94 % the left margin value. If it is omitted, zero value is used.
95 % The |ceqn| environment prepares inner display equations in the
96 % centered style. They have no effect on formulas prepared with the
97 % low-level \TeX\ command~|$$|.
98 %
99 % \DescribeMacro{darray}
100 % The |darray| environment produces an array of formulas in the
101 % |\displaystyle|. The distance between formulas is enlarged in
102 % just the same manner as in other multiline display equations. The
103 % |darray| environment has the same syntax as the |array|:
104 % \begin{quote}
105 % |\begin{darray}|\oarg{pos}\marg{columns}\\
106 % \meta{body}\\
107 % |\end{darray}|
108 % \end{quote}
109 % The \meta{pos} argument describes the vertical alignment of
110 % the array box (|t|, |b|, or |c|; default is |c|). The
111 % use of column specifications in the \meta{columns} argument
112 % is restricted in comparison with |array|: it can contain
113 % the |l|, |c|, and |r| specifiers, |*| and |@| commands.
114 % The intercolumn separation is smaller than in the |array|:
115 % it is reduced to the distance between ordinary and relational
116 % math symbols. As in the |amsmath| package, the thin skip is
117 % inserted before |darray|. Skips before the first and after
118 % the last column of |darray| are not inserted.
119 % To insert them manually, use |@{...}| in the \meta{columns}
120 % argument.
121 %
122 % The |darray| environment is implemented independently on the
123 % |array| environment to avoid conflicts with the |array| package.
124 %
125 % \DescribeMacro{\dmulticolumn}
126 % |\dmulticolumn|\marg{count}\marg{preamble}\marg{formula}
127 % is used in |darray| instead of |\multicolumn|.
128 %
129 % \DescribeMacro{\useshortskip}
130 % In \TeX, two types of skips above display formulas are used: the
131 % normal skip defined in the |\abovedisplayskip| register and the
132 % short skip defined in the |\abovedisplayshortskip| register.
133 % When a display formula is typed out, \TeX\ decides what skip to
134 % insert depending on the width of formula, its style (centered or
135 % flushed left, numbered left or right), and the width of the rest
136 % of text in the last line of the previous paragraph. But this
137 % algorithm works for ordinary formulas only. It does not work in
138 % multiline formulas prepared with |\halign| command. So, a
139 % manual replacement of the normal skip to the short skip is required
140 % in some cases. To provides this, the |\useshortskip| command is
141 % introduced. It forces the use of short skip in the next
142 % display formula but it has no effect on formulas prepared with the
143 % low-level \TeX\ command |$$|.
144 %
145 % \DescribeMacro{\nr}
146 % The vertical distance between lines of miltiline equations
147 % is frequently smaller than necessary. To increase it, the
148 % extra distance can be used as the optional parameter of the
149 % |\\|\oarg{dist} command.
150 % In most cases, it is enough to increase the distance on |0.5ex|.
151 % We introduce the |\nr| command here that is equivalent to the
152 % |\\[0.5ex]|. Its full sintax is just the same as for the |\\| command:
153 % \begin{quote}
154 % |\nr*|\oarg{dist}
155 % \end{quote}
156 % This command can be used everywhere the command |\\| is allowed.
157 %
158 % \DescribeMacro{\mrel}
159 % The |\mrel|\marg{column} command composes a new math relation symbol
160 % from a one-column stack of math formulas described in the \meta{column}
161 % parameter. For example, the command |$\mrel{<\\[-.7ex]>}$| produces
162 % $\mrel{<\\[-.7ex]>}$.
163 %
164 % \DescribeMacro{\underrel}
165 % The |\underrel|\marg{base}\marg{bottom} command is a twin to
166 % the |\overrel| command. For example, the command
167 % |$A\underrel{\longrightarrow}{x\to 0}B$| produces
168 % $A\underrel{\longrightarrow}{x\to 0}B$.
169 %
170 % \section{Medium-Size Math Commands}
171 %
172 % Since version 1.2, a collection of medium-size math commands is
173 % introduced.
174 %
175 % \DescribeMacro{\medmath}
176 % The |\medmath|\marg{formula} command decreases a size of formula
177 % in 1.2 times and prepares it in the display style. An example:
178 % \begin{quote}
179 % |$\medmath{\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}}$|\\
180 % |\quad $\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}$|
181 % \end{quote}
182 % It produces:
183 % \begin{quote}
184 % $\medmath{\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}}$
185 % \quad $\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}$
186 % \end{quote}
187 %
188 % \DescribeMacro{\medop}
189 % The |\medop|\marg{operator} command prepares a medium-size operator
190 % with the required preference for limits. It can be use with |\sum| and
191 % others variable-size commands except integrals. An example:
192 % \begin{quote}
193 % |$\sum_{i=1}^n \medop\sum_{i=1}^n \displaystyle|\\
194 % |\sum\nolimits_{i=1}^n$\quad $\sum\limits_{i=1}^n|\\
195 % |\displaystyle \medop\sum_{i=1}^n \sum_{i=1}^n$|
196 % \end{quote}
197 % It produces:
198 % \begin{quote}
199 % $\sum_{i=1}^n \medop\sum_{i=1}^n \displaystyle \sum\nolimits_{i=1}^n$
200 % \quad$\sum\limits_{i=1}^n \displaystyle \medop\sum_{i=1}^n \sum_{i=1}^n$
201 % \end{quote}
202 %
203 % \DescribeMacro{\medint}
204 % The |\medint|\marg{operator} command prepares a medium-size integral
205 % with required preference for limits. It can be use with |\int|-family
206 % of commands and |\oint| command. An example:
207 % \begin{quote}
208 % |$\int_a^b \medint\int_a^b \displaystyle\int_a^b$\quad|\\
209 % |$\int\limits_a^b \medint\int_a^b\limits \displaystyle|\\
210 % |\int_a\limits^b$\quad $\iint_a^b \medint\iiint_a^b|\\
211 % |\displaystyle\iiiint_a^b$\quad $\iint\limits_X^Y|\\
212 % |\medint\iiint_X\limits^Y \displaystyle \iiiint_X^Y\limits$|\\
213 % |\quad $\medint\idotsint_X\limits \medint\oint_X^Y$|
214 % \end{quote}
215 % It produces:
216 % \begin{quote}
217 % $\int_a^b \medint\int_a^b \displaystyle\int_a^b$\quad
218 % $\int\limits_a^b \medint\int_a^b\limits \displaystyle
219 % \int_a\limits^b$\quad $\iint_a^b \medint\iiint_a^b
220 % \displaystyle\iiiint_a^b$\quad $\iint\limits_X^Y
221 % \medint\iiint_X\limits^Y \displaystyle \iiiint_X^Y\limits$
222 % \quad $\medint\idotsint_X\limits \medint\oint_X^Y$
223 % \end{quote}
224 % By the way, the original limits recognizing in |amsmath|
225 % multi-integrals is very restrictive: it allows only one |\limits|-like
226 % command right after the multi-integral. In this package, the
227 % recognizing is improved to work as \TeX's one.
228 %
229 % \DescribeMacro{\medintcorr}
230 % The |\medintcorr|\marg{length} command specifies the value of
231 % italic correction for medium integrals. It controls a positioning indices
232 % in medium integrals and in multi-integrals. Its default value is |0.5em|.
233 %
234 % \DescribeMacro{\mfrac}
235 % \DescribeMacro{\mbinom}
236 % Based on the medium size formulas, the |\mfrac| and |\mbinom| commands
237 % are introduced. They are similar to |\frac| and |\binom|. An example:
238 % \begin{quote}
239 % |$\frac {x+y}{a-b} \mfrac {x+y}{a-b} \dfrac {x+y}{a-b}$\quad|\\
240 % |$\binom {n}{k} \mbinom {n}{k} \dbinom {n}{k}$|
241 % \end{quote}
242 % It produces:
243 % \begin{quote}
244 % $\frac {x+y}{a-b} \mfrac {x+y}{a-b} \dfrac {x+y}{a-b}$\quad
245 % $\binom {n}{k} \mbinom {n}{k} \dbinom {n}{k}$
246 % \end{quote}
247 %
248 % \DescribeMacro{medsize}
249 % \DescribeMacro{mmatrix}
250 % The |medsize| environment is introduced to prepare formulas and arrays
251 % in the medium size. It reduces the |\arraycolsep| value by 0.8~times. Basing
252 % on it, the |mmatrix| environment is introduced. It is specified as
253 % follows:
254 % \begin{quote}
255 % |\begin{mmatrix} ... \end{mmatrix}|\quad $\equiv$\quad\\
256 % |\begin{medsize}\begin{matrix} ... \end{matrix}\end{medsize}|
257 % \end{quote}
258 % An example:
259 % \begin{quote}
260 % |$\bigl(\begin{smallmatrix} a&b\\c&d\end{smallmatrix}\bigr)$|\\
261 % |$\Bigl(\begin{mmatrix} a&b\\c&d\end{mmatrix}\Bigr)$|\\
262 % |$\begin{pmatrix}a&b\\c&d\end{pmatrix}$|
263 % \end{quote}
264 % It produces:
265 % \begin{quote}
266 % $\bigl(\begin{smallmatrix} a&b\\c&d\end{smallmatrix}\bigr)$
267 % $\Bigl(\begin{mmatrix} a&b\\c&d\end{mmatrix}\Bigr)$
268 % $\begin{pmatrix}a&b\\c&d\end{pmatrix}$
269 % \end{quote}
270 %
271 % \DescribeMacro{mediummath}
272 % Finally, the |mediummath| option allows prepare all variable-size
273 % math elements in medium size. It redefines |\frac|, |\binom| and
274 % all math operators to the medium size. For |\frac| and |\binom|,
275 % the medium size is applied in the display and text styles.
276 % The |\dfrac|, |\tfrac|, |\dbinom|, and |\tbinom| commands have
277 % the old meaning.
278 %
279 % \section{NCC-\LaTeX\ Equivalents to Display Formulas}
280 %
281 % The following NCC-\LaTeX\ equivalents are provided with
282 % this package:
283 % \begin{desclist}{}{\hfill\enskip=}[\com{eqalign*}\marg{formulas}]
284 % \raggedright
285 % \item[\com{eq}\marg{formula}]
286 % |\begin{equation}| \meta{formula} |\end{equation}|.
287 %
288 % \item[\com{eq*}\marg{formula}]
289 % |\begin{equation*}| \meta{formula} |\end{equation*}|.
290 %
291 % \item[\com{eqs}\marg{formulas}]
292 % |\begin{eqnarray}| \meta{formulas} |\end{eqnarray}|.
293 %
294 % \item[\com{eqs*}\marg{formulas}]
295 % |\begin{eqnarray*}| \meta{formulas} |\end{eqnarray*}|.
296 %
297 % \item[\com{eqalign}\marg{formulas}]
298 % |\begin{equation} \begin{darray}{rcl}| \meta{formulas}
299 % |\end{darray} \end{equation}|.
300 %
301 % \item[\com{eqalign*}\marg{formulas}]
302 % |\begin{equation*} \begin{darray}{rcl}| \meta{formulas}
303 % |\end{darray} \end{equation*}|.
304 % \end{desclist}
305 %
306 % The |\eqs| and |\eqs*| commands have an optional parameter
307 % specifying a distance between columns. For example, in the command
308 % \begin{quote}
309 % \verb+\eqs[0mm]{&& -\Delta u = f, \\ && u|_\Gamma = 0,}+
310 % \end{quote}
311 % the intercolumn distance is removed because only the 3rd column is
312 % used. The |eqnarray| environment has no optional parameter.
313 %
314 % The |\eqalign| and |\eqalign*| commands also have an optional
315 % parameter. Its meaning is the column specification
316 % parameter: |\eqalign|\marg{formulas} |=|
317 % |\eqalign[rcl]|\marg{formulas}.
318 %
319 % \StopEventually{}
320 %
321 % \section{The Implementation}
322 %
323 % At first we load the |amsmath| package and pass all options to it
324 % except the |mediummath| option.
325 % \begin{macrocode}
326 %<*package>
327 \DeclareOption{mediummath}{\newcommand\NCC@op{}}
328 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}}
329 \ProcessOptions\relax
330 \RequirePackage{amsmath}[2000/07/18]
331 % \end{macrocode}
332 %
333 % \subsection{Kernel}
334 %
335 % \begin{macro}{\NCC@cr}
336 % Simplified version of |\\| used in some commands here.
337 % The low level command |\NCC@cr@@@|\marg{skip} is defined
338 % if necessary to |\NCC@aligncr| or to something else.
339 % The |\new@ifnextchar| commands from the \AmS\ does the
340 % same as |\@ifnextchar|, but disallows spaces before the
341 % tested symbol.
342 % \begin{macrocode}
343 \newif\ifNCC@star
344 \def\NCC@cr{\relax\iffalse{\fi\ifnum0=`}\fi
345 \@ifstar{\global\NCC@startrue\NCC@cr@}{\global\NCC@starfalse\NCC@cr@}%
346 }
347 \def\NCC@cr@{\new@ifnextchar[\NCC@cr@@{\NCC@cr@@[\z@]}}
348 \def\NCC@cr@@[#1]{\ifnum0=`{\fi \iffalse}\fi\NCC@cr@@@{#1}}
349 \def\NCC@aligncr#1{\cr\noalign{\vskip #1\relax}}
350 % \end{macrocode}
351 % \end{macro}
352 %
353 % \begin{macro}{\NCC@default@cr}
354 % This command sets defaults for the |\\| command.
355 % \begin{macrocode}
356 \def\NCC@default@cr{\let\\\NCC@cr \let\NCC@cr@@@\NCC@aligncr}
357 % \end{macrocode}
358 % \end{macro}
359 %
360 % \begin{macro}{\nr}
361 % The |\nr| command has just the same syntax as |\\|
362 % but adds 0.5ex extra vertical space between lines.
363 % It can work anywhere the |\\| command is allowed.
364 % We temporary change in it the value of |\NCC@cr@@@| to
365 % |\NCC@nr| and restore it later.
366 % \begin{macrocode}
367 \newcommand{\nr}{%
368 \let\NCC@temp\NCC@cr@@@
369 \let\NCC@cr@@@\NCC@nr
370 \NCC@cr
371 }
372 \def\NCC@nr#1{%
373 \let\NCC@cr@@@\NCC@temp
374 \setlength\@tempskipa{#1}\advance\@tempskipa .5ex
375 \ifNCC@star
376 \edef\@tempa{\noexpand\\*[\the\@tempskipa]}%
377 \else
378 \edef\@tempa{\noexpand\\[\the\@tempskipa]}%
379 \fi
380 \@tempa
381 }
382 % \end{macrocode}
383 % \end{macro}
384 %
385 % \subsection{Additional Math Commands}
386 %
387 % \begin{macro}{\mrel}
388 % The |\mrel|\marg{column} command composes a new math relation and
389 % vertically centers it with respect to the math line.
390 % \begin{macrocode}
391 \newcommand{\mrel}{\mathpalette\NCC@rel}
392 \def\NCC@rel#1#2{\mathrel{\vcenter{\NCC@default@cr
393 \offinterlineskip \ialign{\hfil$\m@th#1##$\hfil\cr#2\crcr}}}}
394 % \end{macrocode}
395 % \end{macro}
396 %
397 % \begin{macro}{\underrel}
398 % The |\underrel|\marg{base}\marg{bottom} command is a twin to
399 % |\overrel|.
400 % \begin{macrocode}
401 \newcommand{\underrel}[2]{\mathrel{\mathop{#1}\limits_{#2}}}
402 % \end{macrocode}
403 % \end{macro}
404 %
405 % \subsection{Medium-Size Math Commands}
406 %
407 % \begin{macro}{\NCC@select@msize}
408 % The |\NCC@select@msize| command prepares dimensions for medium-size math:
409 % \begin{itemize}
410 % \item In |\NCC@fracrulewidth| --- a rule width in fractions;
411 % \item In |@tempdima| --- a raising value; and
412 % \item In |@tempdimb| --- a font size to be used in medium fractions
413 % and matrices.
414 % \end{itemize}
415 % \begin{macrocode}
416 \newdimen\NCC@fracrulewidth
417 \def\NCC@select@msize{\relax
418 % \end{macrocode}
419 % |\@tempdima| contains the current font size
420 % \begin{macrocode}
421 \@tempdima \f@size\p@
422 % \end{macrocode}
423 % Calculate in |\@tempdimb| a text font size in medium fraction
424 % \begin{macrocode}
425 \ifdim\@tempdima>11.5\p@
426 \@tempdimb .83\@tempdima
427 \else
428 \@tempdimb .8\@tempdima
429 \ifdim\@tempdimb<5\p@ \@tempdimb 5\p@\fi
430 \fi
431 % \end{macrocode}
432 % Calculate in |\NCC@fracrulewidth| the rule width and in
433 % |\@tempdima| --- the raising value
434 % \begin{macrocode}
435 \NCC@fracrulewidth .04\@tempdima
436 \@tempdima 1.25\NCC@fracrulewidth
437 \ifdim\NCC@fracrulewidth>.45\p@ \else
438 \ifdim\NCC@fracrulewidth>.34\p@ \NCC@fracrulewidth .4\p@
439 \else \NCC@fracrulewidth .3\p@
440 \fi
441 \fi
442 }
443 % \end{macrocode}
444 % \end{macro}
445 %
446 % \begin{macro}{\NCC@innerfrac}
447 % \begin{macro}{\NCC@innerbinom}
448 % The |\NCC@innerfrac|\marg{style} prepares a fraction with a
449 % special width in the given style:
450 % \begin{macrocode}
451 \def\NCC@innerfrac#1{\genfrac{}{}\NCC@fracrulewidth{#1}}
452 % \end{macrocode}
453 % \end{macro}
454 % \end{macro}
455 %
456 % \begin{macro}{\NCC@prepare@msize}
457 % Select a font by rounding its pt-size to the nearest integer
458 % and redefine fractions to have the given rule width. The |\binom|
459 % command is redefined also to its original value because it can be
460 % changed when the |mediummath| option is applied.
461 % \begin{macrocode}
462 \def\NCC@prepare@msize{%
463 \@tempdima 1.2\@tempdimb
464 \advance\@tempdimb .5\p@
465 \edef\@tempa{\strip@pt\@tempdimb}%
466 \expandafter\NCC@floor\expandafter\@tempa\@tempa.\@nil
467 \fontsize\@tempa\@tempdima\selectfont
468 \def\frac{\protect\NCC@innerfrac{}}%
469 \def\dfrac{\NCC@innerfrac\z@}%
470 \def\tfrac{\NCC@innerfrac\@ne}%
471 \def\binom{\protect\genfrac()\z@{}}%
472 }
473 \def\NCC@floor#1#2.#3\@nil{\def#1{#2}}
474 % \end{macrocode}
475 % \end{macro}
476 %
477 % \begin{macro}{\NCC@op@prepare}
478 % |\NCC@op@prepare|\marg{integral}
479 % command prepares an integral. It looks forward, extracts indices
480 % and limits-change commands, and puts the integral with required kerning
481 % of indices. The |\NCC@op@print| driver is a command to print the integral.
482 % Its default value is |\NCC@op@printm|. The driver uses the following hooks:
483 % |\NCC@op| contains an integral command, |\NCC@op@lim| contains
484 % the selected limits-style, |\NCC@op@sb| contains a subscript,
485 % |\NCC@op@sp| contains a superscript, |NCC@op@kern| contains the
486 % kerning value for medium-size integrals. If subscript or superscript
487 % is omitted, the corresponding hook is equal to |\relax|.
488 % \begin{macrocode}
489 \DeclareRobustCommand*\NCC@op@prepare[1]{%
490 \def\NCC@op{#1}%
491 \let\NCC@op@print\NCC@op@printm
492 \NCC@op@prepare@
493 }
494 \def\NCC@op@prepare@{%
495 \let\NCC@op@lim\ilimits@
496 \let\NCC@op@sp\relax
497 \let\NCC@op@sb\relax
498 \NCC@op@next
499 }
500 \def\NCC@op@next{\futurelet\@let@token\NCC@op@getnext}
501 % \end{macrocode}
502 % Test the next token and get it if necessary:
503 % \begin{macrocode}
504 \def\NCC@op@getnext{%
505 \let\@tempa\NCC@op@skip
506 \ifx\@let@token\limits
507 \let\NCC@op@lim\limits \else
508 \ifx\@let@token\nolimits
509 \let\NCC@op@lim\nolimits \else
510 \ifx\@let@token\displaylimits
511 \let\NCC@op@lim\displaylimits \else
512 \ifx\@let@token\sp
513 \NCC@op@test\NCC@op@sp
514 \def\@tempa{\NCC@op@get\NCC@op@sp}\else
515 \ifx\@let@token\sb
516 \NCC@op@test\NCC@op@sb
517 \def\@tempa{\NCC@op@get\NCC@op@sb}\else
518 \ifx\@let@token\@sptoken
519 \let\@tempa\NCC@op@skipsp \else
520 \let\@tempa\NCC@op@print
521 \fi
522 \fi
523 \fi
524 \fi
525 \fi
526 \fi
527 \@tempa
528 }
529 % \end{macrocode}
530 % Skip |\limits|-like token:
531 % \begin{macrocode}
532 \def\NCC@op@skip#1{\NCC@op@next}
533 % \end{macrocode}
534 % Skip a space token. A space token is skipped within |\@ifnextchar|
535 % before comparing it with the first parameter. So, it does not important
536 % what char to test for:
537 % \begin{macrocode}
538 \def\NCC@op@skipsp{%
539 \@ifnextchar0{\NCC@op@next}{\NCC@op@next}%
540 }
541 % \end{macrocode}
542 % Test subscript or superscript to be already defined:
543 % \begin{macrocode}
544 \def\NCC@op@test#1{%
545 \ifx#1\relax \else
546 \PackageError{nccmath}{Double index in math operator}{}
547 \fi
548 }
549 % \end{macrocode}
550 % Get a subscript or superscript:
551 % \begin{macrocode}
552 \def\NCC@op@get#1#2#3{\def#1{#3}\NCC@op@next}
553 % \end{macrocode}
554 % \end{macro}
555 %
556 % \begin{macro}{\NCC@op@printm}
557 % Driver for printing the medium-size integral with indices:
558 % \begin{macrocode}
559 \def\NCC@op@printm{%
560 \ifx\NCC@op@lim\nolimits \NCC@op@printm@\@ne \else
561 \ifx\NCC@op@lim\limits \NCC@op@printm@\z@ \else
562 \mathchoice{\displaystyle\NCC@op@printm@\z@}%
563 {\textstyle\NCC@op@printm@\@ne}%
564 {\scriptstyle\NCC@op@printm@\@ne}%
565 {\scriptscriptstyle\NCC@op@printm@\@ne}%
566 \fi
567 \fi
568 }
569 \def\NCC@op@printm@{\NCC@op@print@\NCC@op\NCC@op@kern}
570 % \end{macrocode}
571 % \end{macro}
572 %
573 % \begin{macro}{\NCC@op@print@}
574 % |\NCC@op@print@|\marg{integral}\marg{kern}\marg{level} command
575 % prints an \meta{integral} using the specified \meta{kern} in indices.
576 % If \meta{level} = 0 use |\limits| else use |\nolimits|.
577 % \begin{macrocode}
578 \def\NCC@op@print@#1#2#3{\mathop{#1}%
579 \setlength\@tempdima{#2}%
580 \@tempswatrue
581 \ifx\NCC@op@sb\relax \else \ifnum#3>\z@ \@tempswafalse \fi \fi
582 \ifx\NCC@op@sp\relax \else \ifnum#3>\z@ \@tempswafalse \fi \fi
583 \edef\@tempa{%
584 \ifnum#3=\z@ \noexpand\limits \else \noexpand\nolimits \fi
585 \ifx\NCC@op@sb\relax \else
586 \noexpand\sb{%
587 \ifnum#3=\z@ \kern -\@tempdima\else \kern -.8\@tempdima \fi
588 \noexpand\NCC@op@sb}%
589 \fi
590 \ifx\NCC@op@sp\relax \else
591 \noexpand\sp{\ifnum#3=\z@ \kern \@tempdima\fi
592 \noexpand\NCC@op@sp}%
593 \fi
594 \if@tempswa \kern -.2\@tempdima \fi
595 }%
596 \@tempa
597 }
598 % \end{macrocode}
599 % \end{macro}
600 %
601 % \begin{macro}{\medmath}
602 % The |\medmath|\marg{formula} prepares a medium-size formula
603 % in display style:
604 % \begin{macrocode}
605 \DeclareRobustCommand*\medmath[1]{\NCC@select@msize
606 \mathord{\raise\@tempdima\hbox{\NCC@prepare@msize
607 $\displaystyle#1$}}%
608 }
609 % \end{macrocode}
610 % \end{macro}
611 %
612 % \begin{macro}{\medop}
613 % The |\medop|\marg{operator} prepares an operator in the medium size:
614 % \begin{macrocode}
615 \newcommand*\medop[1]{\DOTSB\mathop{\medmath{#1}}\slimits@}
616 % \end{macrocode}
617 % \end{macro}
618 %
619 % \begin{macro}{\medintcorr}
620 % The |\medintcorr|\marg{length} specifies an italic correction
621 % for a medium integral:
622 % \begin{macrocode}
623 \newcommand*\medintcorr[1]{\def\NCC@op@kern{#1}}
624 \medintcorr{.5em}
625 % \end{macrocode}
626 % \end{macro}
627 %
628 % \begin{macro}{\medint}
629 % The |\medint|\marg{integral} command prepares a medium integral:
630 % \begin{macrocode}
631 \newcommand*\medint[1]{\DOTSI\NCC@op@prepare{\medmath{#1}}}
632 % \end{macrocode}
633 % \end{macro}
634 %
635 % \begin{macro}{\mfac}
636 % The |\mfrac|\marg{numerator}\marg{denominator} prepares
637 % a medium-size fraction:
638 % \begin{macrocode}
639 \DeclareRobustCommand*\mfrac[2]{\medmath{\frac{#1}{#2}}}
640 % \end{macrocode}
641 % \end{macro}
642 %
643 % \begin{macro}{\mbinom}
644 % The |\mbinom|\marg{numerator}\marg{denominator} prepares
645 % a medium-size binomial expression:
646 % \begin{macrocode}
647 \DeclareRobustCommand*\mbinom[2]{%
648 \Bigl(\medmath{\genfrac{}{}{\z@}{}{#1}{#2}}\Bigr)%
649 }
650 % \end{macrocode}
651 % \end{macro}
652 %
653 % \begin{macro}{medsize}
654 % The |medsize| environment is useful for preparing medium-size arrays:
655 % \begin{macrocode}
656 \newenvironment{medsize}{\NCC@select@msize
657 \mathord\bgroup
658 \raise\@tempdima\hbox\bgroup\NCC@prepare@msize
659 \arraycolsep .8\arraycolsep $}{$\egroup\egroup}
660 % \end{macrocode}
661 % \end{macro}
662 %
663 % \begin{macro}{mmatrix}
664 % The |mmatrix| environment prepares a medium-size matrix:
665 % \begin{macrocode}
666 \newenvironment{mmatrix}{\medsize\begin{matrix}}{\end{matrix}\endmedsize}
667 % \end{macrocode}
668 % \end{macro}
669 %
670 % \subsection{Patches to amsmath}
671 %
672 % \begin{macro}{\MultiIntegral}
673 % Improve the |\MultiIntegral| kerning method on the base of
674 % |\NCC@op@prepare@| hook. The original method from |amsmath| works
675 % bad if a multi-integral is an argument of the |\medint| command.
676 % \begin{macrocode}
677 \renewcommand*{\MultiIntegral}[1]{%
678 \edef\NCC@op{\noexpand\intop
679 \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
680 \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
681 \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
682 \noexpand\intop
683 }%
684 \let\NCC@op@print\NCC@op@printd
685 \NCC@op@prepare@
686 }
687 \def\NCC@op@printd{%
688 \setlength\@tempdima{\NCC@op@kern}%
689 \ifx\NCC@op@lim\nolimits \@tempcnta\@ne \else
690 \ifx\NCC@op@lim\limits \@tempcnta\z@ \else
691 \@tempcnta\m@ne
692 \fi
693 \fi
694 \mathchoice{\NCC@op@printd@{\displaystyle}{1.2\@tempdima}}%
695 {\NCC@op@printd@{\textstyle}{.8\@tempdima}}%
696 {\NCC@op@printd@{\scriptstyle}{.8\@tempdima}}%
697 {\NCC@op@printd@{\scriptscriptstyle}{.8\@tempdima}}%
698 }
699 \def\NCC@op@printd@#1#2{#1%
700 \ifnum\@tempcnta>\m@ne
701 \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\@tempcnta
702 \else
703 \ifx#1\displaystyle
704 \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\z@
705 \else
706 \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\@ne
707 \fi
708 \fi
709 }
710 % \end{macrocode}
711 % \end{macro}
712 %
713 % \begin{macro}{\endmathdisplay@a}
714 % Fix the bug in the |\endmathdisplay@a| command
715 % from the |amsmath| package. The |\displaybreak| has no effect in
716 % it if a tag is specified. This is because the change
717 % of |\postdisplaypenalty| is done after the |\eqno| command.
718 % But the rest of display formula after |\eqno| up to the |$$|
719 % command belongs to the tag. It is prepared in the horizontal mode
720 % and the mentioned penalty is ignored. Fixed version of
721 % this command at first changes the |\postdisplaypenalty| and
722 % after that prints a tag.
723 %
724 % To be sure, that the required command does not fixed yet,
725 % we prepare its bug version in the |\@tempa| command
726 % \begin{macrocode}
727 \def\@tempa{%
728 \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
729 \if@fleqn \@xp\endmathdisplay@fleqn
730 \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
731 \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi
732 \fi
733 \ifnum\dspbrk@lvl>\m@ne
734 \postdisplaypenalty -\@getpen\dspbrk@lvl
735 \global\dspbrk@lvl\m@ne
736 \fi
737 }
738 % \end{macrocode}
739 % and compare it with the current value of |\endmathdisplay@a|.
740 % If they are identic, we fix the last command. Otherwise,
741 % print a warning and do nothing.
742 % \begin{macrocode}
743 \ifx\@tempa\endmathdisplay@a
744 \def\endmathdisplay@a{%
745 \ifnum\dspbrk@lvl>\m@ne
746 \postdisplaypenalty -\@getpen\dspbrk@lvl
747 \global\dspbrk@lvl\m@ne
748 \fi
749 \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
750 \if@fleqn \@xp\endmathdisplay@fleqn
751 \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
752 \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi
753 \fi
754 }
755 \else
756 \PackageWarning{nccmath}%
757 {The \string\endmathdisplay@a\ command differs from\MessageBreak
758 waited value in this version of amsmath package.\MessageBreak
759 We don't fix it!}
760 \fi
761 % \end{macrocode}
762 % \end{macro}
763 %
764 % \begin{macro}{\intertext}
765 % Redefine \AmS's |\intertext|\marg{text} to
766 % |\intertext|\oarg{skip}\marg{text}. Optional \meta{skip} means
767 % the vertical space inserted below and after the text. If it is
768 % omitted, the default |\belowdisplayskip| and |\abovedisplayskip|
769 % spaces are inserted.
770 %
771 % We need to redefine its default value used out of display
772 % equations:
773 % \begin{macrocode}
774 \renewcommand*{\intertext}[1][]{\@amsmath@err{\Invalid@@\intertext}\@eha}
775 % \end{macrocode}
776 % and also must redefine the |\intertext@| hook that changes the
777 % value of |\intertext| within display equations. Its new
778 % definition differs from the original one in the conditional
779 % inserting of skips before and after the text.
780 % The optional parameter is scanned inside the |\noalign|
781 % command. We use the ordinary trick with the |\ifnum0| to
782 % close the open brace in the next macro.
783 % \begin{macrocode}
784 \def\intertext@{%
785 \def\intertext{%
786 \ifvmode\else\\\@empty\fi
787 \noalign{\ifnum0=`}\fi
788 \@ifnextchar[{\NCC@intertext}{\NCC@intertext[]}%
789 }%
790 }
791 \def\NCC@intertext[#1]#2{%
792 \penalty\postdisplaypenalty
793 \@ifempty{#1}{\vskip\belowdisplayskip}{\vskip#1\relax}%
794 \vbox{\normalbaselines
795 \ifdim\linewidth=\columnwidth
796 \else \parshape\@ne \@totalleftmargin \linewidth
797 \fi
798 \noindent#2\par}%
799 \penalty\predisplaypenalty
800 \@ifempty{#1}{\vskip\abovedisplayskip}{\vskip#1\relax}%
801 \ifnum0=`{\fi}%
802 }
803 % \end{macrocode}
804 % \end{macro}
805 %
806 % \begin{macro}{\useshortskip}
807 % The |\useshortskip| command changes an above skip for nearest
808 % display formula to |\abovedisplayshortskip|. Really, it
809 % sets the value of inner if-macro to true and the
810 % actual changes are applied in the |\NCC@ignorepar| hook.
811 % \begin{macrocode}
812 \newif\ifNCC@shortskip \NCC@shortskipfalse
813 \newcommand{\useshortskip}{\global\NCC@shortskiptrue}
814 % \end{macrocode}
815 % \end{macro}
816 %
817 % \begin{macro}{\NCC@ignorepar}
818 % This command removes extra vertical space before display formula
819 % if it starts from a new paragraph and changes the before-skip
820 % to |\abovedisplayshortskip| if the |\useshortskip|
821 % command was applied.
822 % \begin{macrocode}
823 \def\NCC@ignorepar{\relax
824 \ifNCC@shortskip
825 \abovedisplayskip\abovedisplayshortskip
826 \global\NCC@shortskipfalse
827 \fi
828 \ifmmode \else \ifvmode
829 % \end{macrocode}
830 % If a display equation starts in the vertical mode, we
831 % insert the vertical space with the |\addvspace| (this
832 % space will be ignored at the beginning of minipage)
833 % and set above display skips to zero. The below display
834 % skips are made equal. Then we put the |\noindent|
835 % command that prevents insertion an empty paragraph.
836 % \begin{macrocode}
837 \addvspace{\abovedisplayskip}%
838 \abovedisplayskip\z@skip
839 \abovedisplayshortskip\z@skip
840 \belowdisplayshortskip\belowdisplayskip
841 \noindent
842 \fi\fi
843 }
844 % \end{macrocode}
845 % \end{macro}
846 %
847 % Now we insert the |\NCC@ignorepar| command at the
848 % beginning of all \LaTeX\ and \AmS-\LaTeX\ display equations
849 % except |eqnarray|. We need to correct four \AmS\ commands only:
850 % \begin{macrocode}
851 \let\NCC@startgather\start@gather
852 \let\NCC@startalign\start@align
853 \let\NCC@startmultline\start@multline
854 \let\NCC@startdisplay\mathdisplay
855 \def\start@gather{\NCC@ignorepar\NCC@startgather}
856 \def\start@align{\ifingather@\else\NCC@ignorepar\fi\NCC@startalign}
857 \def\start@multline{\NCC@ignorepar\NCC@startmultline}
858 \def\mathdisplay{\NCC@ignorepar\NCC@startdisplay}
859 % \end{macrocode}
860 %
861 % \subsection{The darray Environment}
862 %
863 % \begin{macro}{darray}
864 % The implementation of |darray| is a hybrid of the
865 % |\start@aligned| command from the |amsmath| package
866 % and the |\array| command.
867 % \begin{macrocode}
868 \newenvironment{darray}[2][c]{%
869 \null\,%
870 \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi
871 \bgroup
872 \NCC@default@cr
873 \spread@equation
874 \NCC@mkpream{#2}%
875 \edef\@preamble{\ialign \bgroup \strut@ \@preamble \tabskip\z@skip \cr}%
876 \let\par\@empty \let\@sharp##%
877 \set@typeset@protect
878 \tabskip\z@skip
879 \@preamble
880 }{%
881 \crcr\egroup\egroup
882 }
883 % \end{macrocode}
884 % \end{macro}
885 %
886 % \begin{macro}{\dmulticolumn}
887 % To produce multi-columns in |darray|, the |\dmulticolumn|
888 % command is used.
889 % \begin{macrocode}
890 \newcommand\dmulticolumn[3]{\multispan{#1}%
891 \begingroup
892 \NCC@mkpream{#2}%
893 \def\@sharp{#3}\set@typeset@protect
894 \@preamble
895 \endgroup
896 \ignorespaces
897 }
898 % \end{macrocode}
899 % \end{macro}
900 %
901 % \begin{macro}{\NCC@mkpream}
902 % The |darray| environment
903 % is independent from |array| to avoid conflicts with
904 % packages customizing the |array| environment. So,
905 % we need to implement an independent preamble maker.
906 %
907 % The following classes can appear in the preamble:
908 % \begin{quote}
909 % 0\enskip |lcr|\\
910 % 1\enskip |@|-argument\\
911 % 2\enskip |@|
912 % \end{quote}
913 % The implementation of preamble maker is very similar to the
914 % \LaTeX's version.
915 % \begin{macrocode}
916 \def\NCC@mkpream#1{%
917 \@lastchclass\@ne \@firstamptrue
918 % \end{macrocode}
919 % Specify the default distance between columns in
920 % the |\alignsep@| register from |amsmath|.
921 % \begin{macrocode}
922 \settowidth\alignsep@{$\m@th\mskip\thickmuskip$}%
923 \let\@sharp\relax
924 \let\@preamble\@empty
925 % \end{macrocode}
926 % The |\@xexpast| command expands the argument replacing
927 % all instances of\linebreak |*|\marg{N}\marg{string}
928 % by \meta{N} copies of \meta{string}. The result is saved in
929 % the |\reserved@a| macro. But this command is let to |\relax|
930 % in the |array| package. So, we use its original definition prepared
931 % in the |\NCC@xexpast| macro to avoid conflicts with other
932 % packages.
933 % \begin{macrocode}
934 \let\protect\@unexpandable@protect
935 \NCC@xexpast #1*0x\@@
936 % \end{macrocode}
937 % Now we make the preamble collecting it in the |\@preamble| hook.
938 % The code is very similar to the \LaTeX's |\@mkpream| command.
939 % \begin{macrocode}
940 \expandafter \@tfor \expandafter \@nextchar
941 \expandafter :\expandafter =\reserved@a \do
942 {\@chclass
943 \ifnum \@lastchclass=\tw@ \@ne \else
944 \z@
945 \edef\@nextchar{\expandafter\string\@nextchar}%
946 \if \@nextchar @\@chclass \tw@ \else
947 \@chnum
948 \if \@nextchar c\z@ \else
949 \if \@nextchar l\@ne \else
950 \if \@nextchar r\tw@ \else
951 \z@ \@preamerr \z@
952 \fi
953 \fi
954 \fi
955 \fi
956 \fi
957 \ifcase \@chclass
958 \ifnum \@lastchclass=\z@ \@addtopreamble{\hskip \alignsep@}\fi
959 \@addamp
960 \@addtopreamble{%
961 \ifcase \@chnum \hfil$\displaystyle{\@sharp}$\hfil
962 \or $\displaystyle{\@sharp}$\hfil
963 \or \hfil$\displaystyle{\@sharp}$%
964 \fi
965 }%
966 \or
967 \@addtopreamble{$\@nextchar$}%
968 \fi
969 \@lastchclass\@chclass
970 }%
971 \ifnum\@lastchclass=\tw@ \@preamerr\@ne \fi
972 }
973 % \end{macrocode}
974 % \end{macro}
975 %
976 % \begin{macro}{\NCC@xexpast}
977 % The standard \LaTeX's |\@xexpast| macro is saved here:
978 % \begin{macrocode}
979 \def\NCC@xexpast#1*#2#3#4\@@{%
980 \edef\reserved@a{#1}%
981 \@tempcnta#2\relax
982 \ifnum\@tempcnta>\z@
983 \@whilenum\@tempcnta>\z@\do
984 {\edef\reserved@a{\reserved@a#3}\advance\@tempcnta \m@ne}%
985 \let\reserved@b\NCC@xexpast
986 \else
987 \let\reserved@b\NCC@xexnoop
988 \fi
989 \expandafter\reserved@b\reserved@a #4\@@
990 }
991 \def\NCC@xexnoop #1\@@{}
992 % \end{macrocode}
993 % \end{macro}
994 %
995 % \subsection{NCC Equations}
996 %
997 % \begin{macro}{fleqn}
998 % \begin{macro}{ceqn}
999 % The implementation of these environments is streightforward:
1000 % change the |\if@fleqn| flag and the |\@mathmargin| value:
1001 % \begin{macrocode}
1002 \newenvironment*{fleqn}[1][\z@]{\@fleqntrue
1003 \setlength\@mathmargin{#1}\ignorespaces
1004 }{%
1005 \ignorespacesafterend
1006 }
1007 \newenvironment{ceqn}{\@fleqnfalse
1008 \@mathmargin\@centering \ignorespaces
1009 }{%
1010 \ignorespacesafterend
1011 }
1012 % \end{macrocode}
1013 % \end{macro}
1014 % \end{macro}
1015 %
1016 % \begin{macro}{\eq}
1017 % The implementation of the NCC-\LaTeX's |\eq| command
1018 % is quite simple:
1019 % \begin{macrocode}
1020 \newcommand{\eq}{\@ifstar{\NCC@eqx}{\NCC@eq}}
1021 \def\NCC@eqx#1{\begin{equation*}#1\end{equation*}}
1022 \def\NCC@eq#1{\begin{equation}#1\end{equation}}
1023 % \end{macrocode}
1024 % \end{macro}
1025 %
1026 % \begin{macro}{\eqalign}
1027 % The |\eqalign| command is based on the |equation|
1028 % and |darray| environments:
1029 % \begin{macrocode}
1030 \newcommand{\eqalign}{%
1031 \@ifstar{\let\@tempa\NCC@eqx \NCC@eqa}%
1032 {\let\@tempa\NCC@eq \NCC@eqa}%
1033 }
1034 \newcommand*{\NCC@eqa}[2][rcl]{%
1035 \@tempa{\begin{darray}{#1}#2\end{darray}}%
1036 }
1037 % \end{macrocode}
1038 % \end{macro}
1039 %
1040 % \begin{macro}{\eqs}
1041 % \begin{macro}{eqnarray}
1042 % The difference between the |\eqs| command and the |eqnarray|
1043 % environment consists in optional length parameters allowed
1044 % in |\eqs|. All these commands are based on |\NCC@beqs| and
1045 % |\NCC@eeqs| macros.
1046 % \begin{macrocode}
1047 \newcommand{\eqs}{\@ifstar{\st@rredtrue\NCC@eqs}{\st@rredfalse \NCC@eqs}}
1048 \newcommand*{\NCC@eqs}[2][]{%
1049 \begingroup\NCC@beqs{#1}#2\NCC@eeqs\endgroup\ignorespaces
1050 }
1051 \renewenvironment{eqnarray}{\st@rredfalse\NCC@beqs{}}
1052 {\NCC@eeqs\ignorespacesafterend}
1053 \renewenvironment{eqnarray*}{\st@rredtrue\NCC@beqs{}}
1054 {\NCC@eeqs\ignorespacesafterend}
1055 % \end{macrocode}
1056 % \end{macro}
1057 % \end{macro}
1058 %
1059 % \begin{macro}{\NCC@beqs}
1060 % The |\NCC@beqs|\marg{skip} starts eqnarray-like equations.
1061 % The \meta{skip} parameter specifies a skip inserted
1062 % between columns. If it is empty, the default value of this skip
1063 % is used. It equals to the thick skip appearing in relations.
1064 % The implementation of this macro uses hooks from the
1065 % |amsmath| package.
1066 % \begin{macrocode}
1067 \def\NCC@beqs#1{%
1068 \NCC@ignorepar$$
1069 \inalign@true \intertext@ \displ@y@ \Let@
1070 \chardef\dspbrk@context\z@
1071 \let\math@cr@@@\NCC@eqcr \let\tag\tag@in@align
1072 \let\label\label@in@display \let\split\insplit@
1073 \ifst@rred\else \global\@eqnswtrue \fi
1074 \tabskip\@mathmargin
1075 \@ifempty{#1}{\settowidth\alignsep@{$\m@th\mskip\thickmuskip$}}%
1076 {\setlength\alignsep@{#1}}%
1077 \halign to \displaywidth\bgroup
1078 \strut@ \global\column@\z@ \hfil$\displaystyle{##}$\tabskip\z@skip
1079 &\column@plus \hskip\alignsep@ \hfil$\displaystyle{##}$\hfil
1080 &\column@plus \hskip\alignsep@ $\displaystyle{##{}}$\hfil
1081 \tabskip\@centering
1082 &\column@plus \llap{##}\tabskip\z@skip\cr
1083 }
1084 % \end{macrocode}
1085 % \end{macro}
1086 %
1087 % \begin{macro}{\NCC@eqcr}
1088 % The |\NCC@eqcr| hook is called at the end of line of the
1089 % |eqnarray|. It is originated on \LaTeX's |\@eqncr| command, but
1090 % uses commands from |amsmath| to prepare a tag in the \AmS\ style.
1091 % \begin{macrocode}
1092 \def\NCC@eqcr{%
1093 \let\@tempa\relax
1094 \ifcase\column@ \def\@tempa{&&&}\or \def\@tempa{&&}\or\def\@tempa{&}%
1095 \else
1096 \let\@tempa\@empty
1097 \@latex@error{Too many columns in eqnarray environment}\@ehc
1098 \fi
1099 \@tempa
1100 \ifst@rred\nonumber\fi
1101 \if@eqnsw \global\tag@true \fi
1102 \iftag@ \@lign\strut@
1103 \iftagsleft@ \rlap{\hskip -\displaywidth\make@display@tag}%
1104 \else \make@display@tag \fi
1105 \fi
1106 \ifst@rred\else\global\@eqnswtrue\fi
1107 \cr
1108 }
1109 % \end{macrocode}
1110 % \end{macro}
1111 %
1112 % \begin{macro}{\NCC@eeqs}
1113 % This macro finishes eqnarray-like equations.
1114 % \begin{macrocode}
1115 \def\NCC@eeqs{\math@cr\egroup$$}
1116 % \end{macrocode}
1117 % \end{macro}
1118 %
1119 % \subsection{Math with medium fractions and operators}
1120 %
1121 % Finally, we process the |mediummath| option. It is recognized by
1122 % the |\NCC@op| command to be specified.
1123 % \begin{macrocode}
1124 \@ifundefined{NCC@op}{\endinput}{}
1125 % \end{macrocode}
1126 %
1127 % Redifine fractions and binoms.
1128 % \begin{macrocode}
1129 \DeclareRobustCommand\frac{\NCC@op@select\mfrac{\genfrac{}{}{}{}}}
1130 \DeclareRobustCommand\binom{\NCC@op@select\mbinom{\genfrac()\z@{}}}
1131 \def\NCC@op@select#1#2#3#4{%
1132 \mathchoice{#1{#3}{#4}}{#1{#3}{#4}}%
1133 {\scriptstyle#2{#3}{#4}}{\scriptscriptstyle#2{#3}{#4}}%
1134 }
1135 % \end{macrocode}
1136 %
1137 % Redefine all math operators except integrals:
1138 % \begin{macrocode}
1139 \def\@tempa#1#2{%
1140 \ifx#2\@undefined \let#2#1\fi
1141 \def#1{\DOTSB\medop{#2}}%
1142 }
1143 \@tempa \coprod \coprod@
1144 \@tempa \bigvee \bigvee@
1145 \@tempa \bigwedge \bigwedge@
1146 \@tempa \biguplus \biguplus@
1147 \@tempa \bigcap \bigcap@
1148 \@tempa \bigcup \bigcup@
1149 \@tempa \prod \prod@
1150 \@tempa \sum \sum@
1151 \@tempa \bigotimes \bigotimes@
1152 \@tempa \bigoplus \bigoplus@
1153 \@tempa \bigodot \bigodot@
1154 \@tempa \bigsqcup \bigsqcup@
1155 % \end{macrocode}
1156 %
1157 % Redefine integrals:
1158 % \begin{macrocode}
1159 \def\@tempa#1#2#3{\let#3#2%
1160 \DeclareRobustCommand#2{\mathop{\medmath{#3}}}%
1161 \def#1{\DOTSI\NCC@op@prepare{#2}}%
1162 }
1163 \@tempa\int \intop \NCC@op@int
1164 \@tempa\oint \ointop \NCC@op@oint
1165 \let\@tempa\relax
1166 % \end{macrocode}
1167 %
1168 % Redefine multiple integrals:
1169 % \begin{macrocode}
1170 \renewcommand*{\MultiIntegral}[1]{%
1171 \edef\NCC@op{\noexpand\intop
1172 \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
1173 \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
1174 \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
1175 \noexpand\intop
1176 }%
1177 \let\NCC@op@print\NCC@op@printm
1178 \NCC@op@prepare@
1179 }
1180 \def\intkern@{\kern-\NCC@op@kern}
1181 \def\intdots@{\setlength\@tempdima{\NCC@op@kern}%
1182 \kern-.4\@tempdima{\cdotp}\mkern1.5mu{\cdotp}%
1183 \mkern1.5mu{\cdotp}\kern-.4\@tempdima}
1184 %</package>
1185 % \end{macrocode}
1186 \endinput