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