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
|
%\iffalse % MetaComment
%%
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
%% | Copyright(C) 1997-2010 by F. Bosisio |
%% | |
%% | This program can be redistributed and/or modified under |
%% | the terms of the LaTeX Project Public License, either |
%% | version 1.3 of this license or (at your option) any later |
%% | version. The latest version of this license is in |
%% | http://www.latex-project.org/lppl.txt |
%% | and version 1.3 or later is part of all LaTeX distributions |
%% | version 2005/12/01 or later. |
%% | |
%% | This work has the LPPL maintenance status `maintained'. |
%% | The Current Maintainer of this work is F. Bosisio. |
%% | |
%% | This work consists of files envmath.dtx and envmath.html |
%% | and of the derived files envmath.sty and envmath.pdf. |
%% | |
%% | E-mail: fbosisio@bigfoot.com |
%% | CTAN location: macros/latex/contrib/bosisio/ |
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
%%
%% If you make any improvment, find any bug or have
%% any suggestion, please let me know about it.
%%
%<*package,driver>
%\fi
%
\def\FileName{envmath}
%\iffalse % MetaComment
%</package,driver>
%<*package>
%\fi
\def\fileversion{2.5}
\def\filedate{2010/02/10}
\def\docdate{2005/04/09}
\def\filedescr{Extended math environments (FB)}
%
%\iffalse % MetaComment
%</package>
%<*dtx>
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% This section is the installation driver
%
\def\batchfile{\FileName.dtx}
%
\input docstrip
%
\keepsilent
% \askforoverwritefalse
%
\generateFile{\FileName.sty}{f}{\from{\FileName.dtx}{package}}
%
\generateFile{\FileName.drv}{f}{\from{\FileName.dtx}{driver}}
%
\Msg{******************************************************}
\Msg{*}
\Msg{* To produce the documentation run the}
\Msg{* file `\FileName.drv' through LaTeX.}
\Msg{*}
\Msg{******************************************************}
%
\endbatchfile
%
% End of the installation driver
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%</dtx>
%
% This section is the documentation driver
%
%<+driver>\documentclass[12pt,a4paper]{ltxdoc}
%<+driver> \EnableCrossrefs
%<+driver> \CodelineIndex
%<+driver> \RecordChanges
%<+driver> %\OnlyDescription % Uncomment not to see the implementation
%<+driver>\begin{document}
%<+driver> \DocInput{\FileName.dtx}
%<+driver> \PrintIndex
%<+driver> \PrintChanges
%<+driver>\end{document}
%
% End of the documentation driver
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%<*package>
%\fi
%
% \changes{v0.1}{20 April 1997}{First release (basic environments)}
% \changes{v0.2}{10 May 1997}{Added the ``*-form'' of environments}
% \changes{v1.0}{24 May 1997}{Documentation added}
% \changes{v1.1}{18 October 1997}{``EQNarray'' and ``EqSystem'' environments}
% \changes{v1.2}{5 November 1997}{Options to behave like ``Standard'' LateX}
% \changes{v1.3}{8 November 1997}{Documentation updated}
% \changes{v2.0}{20 December 1997}{Separated from package ``mathcmd''}
% \changes{v2.1}{4 February 1998}{``MultiLine'' and ``EqSystem'' environments
% reimplemented; ``EQNarray'' environment and
% ``CONTINUE'' command made obsolete}
% \changes{v2.2}{6 February 1998}{``@StandartEquation'' deferred
% ``AtBeginDocument''; some ``def'' replaced
% by ``newcommand*''; documentation updated}
% \changes{v2.3}{5 March 1999}{Added copyright notice and changed addresses}
% \changes{v2.4}{9 April 2005}{Usage of the double-quote character (") avoided}
% \changes{v2.5}{10 February 2010}{Package renamed from ``mathenv'' to
% ``envmath'' to avoid name conflicts}
%\iffalse % MetaComment
% The previous change was requested by Karl Berry (karl@freefriends.org)
%\fi
%
% \MakeShortVerb{\|}
%
% \title{Package \texttt{\FileName}\thanks{This is version \fileversion,
% last revised \filedate; documentation date \docdate}}
% \author{F. Bosisio\\\normalsize E-mail: \texttt{fbosisio@bigfoot.com}}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% Documentation for the package \texttt{\FileName}.
% \end{abstract}
%
% \section{Introduction}
% This package provides some useful math-commands and enviroments,
% which are simpler to use and prettier then their standard \LaTeX{}
% counterpart.
%
% In particular some commands are redefined\footnote{See the options
% in next section if you don't want these comand to be redefined}, so
% care should be taken, expecially when including this package in an
% already existent \LaTeX{} file.
%
% \noindent
% The redefined commands are:\\
% |\(|, |\)|, |\[|, |\]|, |\{| and |\}| \\
% The effect of ``|\(| \dots |\)|'' can still be achieved by the
% \LaTeX{} equivalent commands ``|\begin{math}| \dots |\end{math}|''
% or ``|$| \dots |$|''.
%
% \noindent
% Similarly, the effect of ``|\[| \dots |\]|'' can be achieved by
% the \LaTeX{} equivalent commands
% ``|\begin{displaymath}| \ldots |\end{displaymath}|''
% or ``|$$| \dots |$$|''.
%
% \noindent
% The ``|\{|'' and ``|\}|'' commands are the more error-prone, since
% one may try to use ``|\left\{|'', which now is incorrect, because
% the ``|\{|'' command already contains a ``|\left|'' declaration.
% In the rare occasions where a brace of normal size is needed, one
% can use the \LaTeX{} commands ``|\lbrace|'' and ``|\rbrace|''
%
% \noindent
% Also the ``|equation|'' environment has been changed, but it is
% completly compatible with the original definition, so it should
% be safe, perhaps except when the first character of the equation
% is an open square bracket or it is placed in a moving argument:
% in fact, the new version of this command is fragile, and this is
% true also for most of the commands defined by this package.
%
% \section{Backward compatibility}
% The package has been renamed from ``|mathenv|'' to ``|envmath|'',
% in order to avoid conflicts with another package with the same name:
% if you were using the ``old'' package, you need to change your \LaTeX{}
% files in order to include the new ones.\\
% Alternatively, you can also rename the package to give it the ``old''
% name (you need to change also the ``|\def\FileName{...}|'' line inside
% the ``|sty|''-file), but you must take care not to have another package
% with the same name installed on your system.
%
% \section{The options}
% At now, five options are available with the \texttt{\FileName}
% package.
%
% \noindent
% The ``|RedefEquation|''/``|StdEquation|'' and
% ``|RedefBrackets|''/``|StdBrackets|'' options control
% whether the ``|equation|'' environment and the brace commands
% ``|\(|'', ``|\(|'', ``|\)|'', ``|\[|'', ``|\]|'', ``|\{|'' and ``|\}|
% should be redefined or retain their original \LaTeX{} meaning.
% More precisely, ``|RedefEquation|'' (default) redefines the
% ``equation'' environment to have an optional argument (used as a
% label), while ``|StdEquation|'' leaves it unchanged. In the first
% case, the ``equation'' environment will be equivalent to the
% ``Equation'' environment (capitalized!) described below, whereas in
% the second case they will be different.
% Similarly, the ``|RedefBrackets|'' option (default) makes the
% brackets command to be redefined, whilst ``|StdBrackets|'' leave
% them their original meaning.
% Also a ``|Standard|'' option exists, which amounts to specify both
% the ``|StdEquation|'' and ``|StdBrackets|'' options, thus making the
% package fully standard, which may be useful when sending your
% \LaTeX{} files to someone else.
%
% \section{Math-mode environments}
% This package provides three math-mode environments, each with a
% ``*-form'' which does not generates numbers.
%
% \subsection{The \texttt{Equation} environment}
% The ``|Equation|'' environment has an optional argument
% which is used as a label to reference it.
% \begin{verbatim}
% \begin{Equation}[label]
% ...
% \end{Equation}
% \end{verbatim}
% If the ``|RedefEquation|'' option is in effect (default),
% then the ``|equation|'' environment is redefined to have
% the same optional argument as ``|Equation|''.
%
% There is also a *-form, which does not generate a number
% (so this *-form is really a ``displaymath'' and not an
% equation, but it has been added for simmetry and for making
% it easier to add or remove the number to a formula).
%
% \noindent
% The *-form has an optional argument like the non-* form,
% which is disregarded by the environment and is added only
% for simmetry reasons.
% \begin{verbatim}
% \begin{equation*}[disregarded-label]
% ...
% \end{equation*}
% \end{verbatim}
%
% \subsection{The \texttt{MultiLine} equation environment}
% The ``|MultiLine|'' environment is intended for formulas
% that don't fit on a single line, and so must be broken
% across lines.
%
% \noindent
% As for the |Equation| environment above, it has an optional
% argument which is used as a label.
%
% \noindent
% All the lines but the first are automatically indented by
% the lenght ``|\MultiLineIndent|'', which is rougthly what
% one expects, but can be changed at any time by the user
% with ``|\setlenght{\MultiLineIndent}{...}|''.
% You can also control the alignment of the continuation rows
% by placing an optional |&| in the first row: is such a case
% all the others line will \emph{not} be indented
% by ``|\MultiLineIndent|'' but wil behave \emph{as if} there
% there were an ampersand in front of them (i.e. they will be
% left-aligned at the right of the \& in the first row).
%
% \noindent
% Each line but the last must end with a ``|\\|'' command
% (which can have an optional argument to add some vertical
% space between lines).
% When the line is broken in the middle (e.g. after a ``+''
% sign) and not at the end (i.e. after a ``='' or similar), the
% *-form ``|\\*|'' may be used to indicate the line-break, the
% difference being in an extra space added at the beginning of
% the next line.
% The width of a thise space defaults to 1em and can be changed
% by the user with ``|\setlenght{\MultiLineStarIndent}{...}|''.
%
% \begin{verbatim}
% \begin{MultiLine}[label]
% ... [&]= ... = \\
% = ... + \\*
% + ... = \\
% = ...
% \end{MultiLine}
% \end{verbatim}
%
% Also this environment has a *-form which differs only in that
% it does not generate an equation number.
% \begin{verbatim}
% \begin{MultiLine*}[disregarded-label]
% ... [&]= ... = \\
% = ... + \\*
% + ... = \\
% = ...
% \end{MultiLine*}
% \end{verbatim}
%
% \subsection{The \texttt{System} environment}
% The ``|System|'' environment is used for grouping a set of
% equations together inside a left brace, with one only
% equation number.
%
% \noindent
% Again there is an optional argument to indicate a label and
% each equation is separated by a ``|\\|'' or ``|\\*|'' command,
% as for the ``|MultiLine|'' environment.
%
% \noindent
% The rows (except the ones ended with the *-form ``|\\*|'')
% may optionally contain one ``|&|'', which is usually used
% when some text should be added to the equation.
% \begin{verbatim}
% \begin{System}[label]
% ... = ... [& ...] \\
% ... = ... + \\*
% + ... [& ...] \\
% ... = ... [& ...]
% \end{System}
% \end{verbatim}
%
% A *-form which does not generate any number is also provided.
% \begin{verbatim}
% \begin{System*}[disregarded-label]
% ... = ... [& ...] \\
% ... = ... + \\*
% + ... [& ...] \\
% ... = ... [& ...]
% \end{System*}
% \end{verbatim}
%
% \subsection{The \texttt{EqSystem} environment}
% The ``|EqSystem|'' environment is used for grouping a set of
% equations together inside a left brace, each with its own
% equation number.
%
% \noindent
% Again there is an optional argument to indicate a label and
% each equation is separated by a ``|\\|'' or ``|\\*|'' command.
%
% \noindent
% The rows may optionally contain one ``|&|'', which is
% usually used when some text should be added to the equation.
% \begin{verbatim}
% \begin{EqSystem}[label]
% ... = ... [& ...] \\ % (1.1)
% ... = ... + \\* % (1.2)
% + ... [& ...] \\ % (1.3)
% ... = ... [& ...] % (1.4)
% \end{EqSystem}
% \end{verbatim}
%
% A *-form is also provided: it differs in that each equation
% is numbered with the same number but with a lowercase letter
% added, i.e. like (1.1a), (1.1b), etc. instead of (1.1),
% (1.2) and so on.
% \begin{verbatim}
% \begin{EqSystem*}[label]
% ... = ... [& ...] \\ % (1.5a)
% ... = ... + \\* % (1.5b)
% + ... [& ...] \\ % (1.5c)
% ... = ... [& ...] % (1.5d)
% \end{EqSystem*}
% \end{verbatim}
% In both cases, if the optional argument is present, each
% equation can be referenced by |\ref{<label>:a}|,
% |\ref{<label>:b}|, \dots, where |<label>|, stands for
% the string used as optional argument.
% In the case of the *-form, a reference of the kind
% |\ref{<label>}| will print the equation number without
% any letter, thus referring to the system as a whole,
% whereas such a reference is meaningless (and indeed does
% not exists) when dealing with the non *-form.
%
%
% \section{Math-mode commands}
% In addition to the previously mentioned environments, the
% \texttt{\FileName} package defines also some of math-mode
% commands which considerably simplify the use of adjustable-size
% parentheses.
%
% \noindent
% The ``|\(|'', ``|\[|'', ``|\{|'', ``|\)|'', ``|\]|''
% and ``|\}|'' generates the corresponding parenthesis but
% with a ``|\left|'' or ``|\right|'' declaration
% (respectively) added, so they must come in matched pairs or
% coupled with a ``|\left.|'' or ``|\rigtht.|'' or another
% adjustable-size delimiter.
%
% \StopEventually{}
% \newpage
% \section{Implementation}
%
% \begin{macrocode}
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{\FileName}[\filedate\space v\fileversion\space\filedescr]
%%
\newif\if@Redefine@Equation@
\DeclareOption{RedefEquation}{\@Redefine@Equation@true}
\DeclareOption{StdEquation}{\@Redefine@Equation@false}
%%
\newif\if@Redefine@Brackets@
\DeclareOption{RedefBrackets}{\@Redefine@Brackets@true}
\DeclareOption{StdBrackets}{\@Redefine@Brackets@false}
%%
\DeclareOption{Standard}{\@Redefine@Equation@false\@Redefine@Brackets@false}
%%
\ExecuteOptions{RedefEquation,RedefBrackets}
% \end{macrocode}
%
% The ``|\ProcessOptions*|'' command was used here instead of
% ``|\ProcessOptions*|'' in order to process the options in the
% ``|\usepackage|'' order, rather than in the declaration order
% \begin{macrocode}
%%
\ProcessOptions*
% \end{macrocode}
%
% \begin{macro}{\StartMath@Err}
% The ``|\StartMath@Err|'' prints an error message if used in math-mode
% (saying that you can't use the command passed to it as an argument in
% math-mode); otherwise it just enters math-mode through a |$$|.
% It is used by the *-form of the math-environments to prevent
% their use in math-mode.
% \begin{macrocode}
%%
\newcommand*\StartMath@Err[1]{%
\ifmmode\PackageError{\FileName}{%
You can't use environment ``#1'' in math mode}{%
You probably used ``\string\end{#1}'' without a previous ``\string\begin{#1}''.}%
\else$$\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{Equation}
% The definition of the original ``|equation|'' environment is first saved
% in the ``|\@StandardEquation|'' command.
% Then the ``|\@LabelledEquation|'' command is defined as an |equation|
% with a label.
% The |Equation| command simply calls ``|\@LabelledEquation|'' or
% ``|\@StandardEquation|'', depending on the presence or absence of the
% optional argument (indicated by the square bracket).
% \begin{macrocode}
%%
\AtBeginDocument{%
\let\@StandardEquation=\equation
}
\def\@LabelledEquation[#1]{\@StandardEquation\label{#1}}
\newenvironment{Equation}{%
\@ifnextchar[{\@LabelledEquation}{\@StandardEquation}%
}{%
\endequation%
}
% \end{macrocode}
%
% If the ``|RedefEquation|'' option is in effect, |equation| is defined
% to be the same as |Equation|.
% The actual definition of the |equation| environment is deferred at the
% ``|\begin{document}|'' in order to minimize the possibility of
% conflicts with other packages.
% \begin{macrocode}
\if@Redefine@Equation@
\AtBeginDocument{\let\equation=\Equation}
\fi
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{equation*}
% The command ``|\Equation@Star|'' simply enters math-mode (via the
% ``|\StartMath@Err|'' command).
% The definition of ``|equation*|'' is deferred at the
% ``|\begin{document}|'' so that this definition takes precedence over
% the analogue one from the ``|amsmath|'' package, if both are included.
% The command ``|\global\@ignoretrue|'' in the definition of
% ``|\end{equation*}|'' prevents spurious spaces at the beginning of next
% line.
% \begin{macrocode}
%%
\def\Equation@Star[#1]{\StartMath@Err{equation*}}
\AtBeginDocument{%
\@namedef{equation*}{\@ifnextchar[{\Equation@Star}{\Equation@Star[]}}%
\@namedef{endequation*}{$$\global\@ignoretrue}%
}
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{\ARRAY@CR}
% The original definition of ``|\@arraycr|'' is saved in the command
% ``|\@ArrayCR|''.
% Then ``|\ARRAY@CR|'' is defined to do the same job of ``|\@arraycr|''
% and add a ``|\displaystyle|'' declation at the beginning of next row.
% \begin{macrocode}
%%
\let\@ArrayCR=\@arraycr
\def\@ArrayCR@quadra[#1]{\@ArrayCR[#1]\displaystyle}
\def\@ArrayCR@star@quadra[#1]{%
\@ArrayCR[#1]\displaystyle\mbox{\hspace{\SystemStarIndent}}%
}
\def\@ArrayCR@star*{%
\@ifnextchar[{\@ArrayCR@star@quadra}{%
\@ArrayCR\displaystyle\mbox{\hspace{\SystemStarIndent}}}}%
\newcommand*{\ARRAY@CR}{\@ifnextchar*{\@ArrayCR@star}{%
\@ifnextchar[{\@ArrayCR@quadra}{\@ArrayCR\displaystyle}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MakeAmper@Active}
% Makes ``\&'' active (instead of a tab marker), giving
% it the meaning specified by the argument.
% \begin{macrocode}
%%
\newcommand*\MakeAmper@Active[1]{
\global\def\@AMPERSAND{#1}%
\begingroup%
\catcode`\~\active \lccode`\~`\&%
\lowercase{%
\global\expandafter\let
\csname ac\string\&\endcsname~%
\gdef~{\@AMPERSAND}}%
\endgroup%
\global\catcode`\&\active%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MakeAmper@Tab}
% Restores ``\&'' to its original meaning (a tab marker).
% \begin{macrocode}
%%
\newcommand*\MakeAmper@Tab{\global\catcode`\&=4}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\OneShot@Amper}
% Makes ``\&'' active for one occurrence only: when encountered, the
% code in the first argument is executed, then ``\&'' is restored to
% its original meaning, a tab marker is inserted, and finally the
% code in the second argument is executed.
% \begin{macrocode}
%%
\newcommand*\OneShot@Amper[2]{%
\MakeAmper@Active{#1\expandafter\MakeAmper@Tab}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MultiLineIndent}
% The length ``|\MultiLineIndent|'' represents the amount of spece by
% which each line but the first of a ``|MultiLine|'' environment is
% indented. It defaults to 1.7em, which is roughtly equal to the width
% of a character followed by an equal sign (e.g.: ``|A = |'' ).
% \begin{macrocode}
%%
\newlength\MultiLineIndent
\setlength{\MultiLineIndent}{1.7em}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MultiLineStarIndent}
% The length ``|\MultiLineStarIndent|'' represents the amount of spece by
% which each line following a ``|\\*|'' in a ``|MultiLine|'' environment is
% indented. It defaults to 1em, which is roughtly equal to the width
% of a an equal sign (e.g.: ``|=|'' ).
% \begin{macrocode}
%%
\newlength\MultiLineStarIndent
\setlength\MultiLineStarIndent{1em}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@MultiLineCR}
% The ``|\@MultiLineCR|'' command does the original job of ``|\@arrycr|''
% (saved in ``|\ArrayCR|'') and then executes the ``|\ML@EveryRow|''
% command.
% In the *-form it also adds a space equal to ``|\MultiLineStarIndent|''.
% The splitting in subcommands is required in order to pass the optional
% argument to ``|\@ArrayCR|'' and not to the last executed command.
% \begin{macrocode}
%%
\newcommand*\@MultiLineCR{%
\@ifnextchar*{\MLineCR@star}{%
\@ifnextchar[{\MLineCR@quadra}{\@ArrayCR\ML@EveryRow}}%
}
\def\MLineCR@star*{%
\@ifnextchar[{\MLineCR@star@quadra}{%
\@ArrayCR\ML@EveryRow\hspace{\MultiLineStarIndent}}%
}
\def\MLineCR@star@quadra[#1]{%
\@ArrayCR[#1]%
\ML@EveryRow%
\hspace{\MultiLineStarIndent}%
}
\def\MLineCR@quadra[#1]{\@ArrayCR[#1]\ML@EveryRow}
% \end{macrocode}
%
% The ``|MultiLine|'' environment starts by setting ``|\ML@EveryRow|''
% to be equivalent to ``|\@MultiLINEcr|'', so that this command is
% executed at the end of the first row.
% It checks the |\catcode| of \& and redefines ``|\ML@EveryRow|''
% accordingly: if \& is a tab marker (|\catcode|=4), an ampersand has
% occurred in the first row, so that each row must begin itself with
% an ampersand; otherwise (i.e. if the |\catcode| of \& is \emph{active})
% no ampersand were found in the first row, so that each line must begin
% with a space equal to ``|\MultiLineStarIndent|''.
% \begin{macrocode}
\newcommand*\@MultiLINEcr{%
\ifnum\catcode`\&=4%
\global\def\ML@EveryRow{&\displaystyle\mbox{}}%
\else%
\MakeAmper@Tab%
\global\def\ML@EveryRow{\displaystyle\mbox{\hspace{\MultiLineIndent}}}%
\fi%
\ML@EveryRow%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CONTINUE}
% The command ``|\CONTINUE|'' is obsolete: you should use ``|\\*|'' instead.
% \begin{macrocode}
%%
\newcommand*{\CONTINUE}{%
\PackageError{\FileName}{%
Command ``\string\CONTINUE'' is obsolete: use ``\string\\*'' instead}{%
You'd better correct your input file as stated above,\MessageBreak%
but if you press ENTER everything will work for the moment.}%
\MLineCR@star*%
}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{MultiLine}
% The internal commad ``|\Start@MultiLine|'' is used by the ``|MultiLine|''
% and ``|MultiLine*|'' environments.
% It makes \& add a ``|\displaystyle|'' declaration.
% It also changes the meaning of ``|\\|'' to ``|\@MultiLineCR|'', sets
% ``|\ML@EveryRow|'' to its default value ``|\@MultiLINEcr|'' and then
% starts an ``|array|'' environment (we already are in math-mode
% here) with one only column which is left aligned.
% Finally, if there is an optional argument it is used as a ``|\label|''
% or ignored, depending on the current meaning of ``|\@LABEL|'' (which
% is the same as ``|\label|'' in the standard form and does nothing in
% the *-form).
% \begin{macrocode}
%%
\newcommand*\Start@MultiLine{%
\@ifnextchar[{\Start@MultiLine@quadra}{\Start@MultiLine@no}%
}
%%
\def\Start@MultiLine@quadra[#1]{\@LABEL{#1}\Start@MultiLine@no}
%%
\newcommand*\Start@MultiLine@no{%
\OneShot@Amper{}{\displaystyle}%
\let\@arraycr=\@MultiLineCR%
\let\ML@EveryRow=\@MultiLINEcr%
\begin{array}{l@{\hspace{0.3em}}l}%
\displaystyle%
}
% \end{macrocode}
%
% The internal command ``|\Stop@MultiLine|'' is used by the ``|MultiLine|''
% and ``|MultiLine*|'' environments.
% It simply closes the ``|array|'' environment anr restores ``|\@arrycr|''
% to its original meaning.
% \begin{macrocode}
%%
\newcommand*\Stop@MultiLine{%
\end{array}%
\let\@arraycr=\@ArrayCR%
\MakeAmper@Tab% % For the case no ``\\'' is used
}
% \end{macrocode}
%
% The ``|MultiLine|'' environment invokes ``|\Start@MultiLine|'' and
% ``|\Stop@MultiLine|'' inside an ``|equation|'' environment.
% \begin{macrocode}
%%
\newenvironment{MultiLine}{%
\let\@LABEL=\label%
\@StandardEquation%
\Start@MultiLine%
}{%
\Stop@MultiLine%
\endequation%
\global\@ignoretrue%
}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{MultiLine*}
% The ``|\MultiLine@Star|'' command issues an error message if used inside
% math mode, while when in text mode starts a ``|displaymath|'' environment
% (throught the ``|$$|'' command) in which a ``|\Start@MultiLineEq|'' command
% is issued (so it is the same as ``|\Label@MultiLineEq|'', but with
% ``|\equation|'' substituted by ``|$$|'').
% \begin{macrocode}
%%
\@namedef{MultiLine*}{\ifmmode\Not@MathErr{MultiLine*}\else$$\fi%
\def\@LABEL##1{}%
\Start@MultiLine%
}
\@namedef{endMultiLine*}{\Stop@MultiLine$$\global\@ignoretrue}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{System}
% The ``|\@System@Def|'' command is the kernel of the ``|System|'' and
% ``|System*|'' environments.
% It redefines ``|\@arraycr|'' so that ``|\\|'' not only ends the
% line but also adds a ``|\displaystyle|'' declaration.
% Then it draws an adjustable-size left brace, which will be as big as
% the system requires.
% Finally, a two-column array environment with a ``|\qquad|'' space
% between the columns is started and a ``|\displaystyle|'' declaration
% is added to the first row.
% \begin{macrocode}
%%
\newcommand*\@System@Def{%
\let\@arraycr=\ARRAY@CR%
\left\lbrace%
\begin{array}{l@{\qquad}l@{}}%
\displaystyle%
}
% \end{macrocode}
% The ``|\Label@System|'' commands opens an equation environment, issues
% a ``|\label|'' command for cross-referencing, and then calls the
% command ``|\@System@Def|'' defind above.
% \begin{macrocode}
\def\Label@System[#1]{\@StandardEquation\label{#1}\@System@Def}
% \end{macrocode}
% The ``|\begin{System}|'' command does the same things, skipping the
% ``|\label|'' command if there isn't the optional parameter.
% The ``|\end{System}|'' command closes the array, puts an invisible
% delimiter (``|\right.|'') which pairs with the left brace of the
% ``|\@System@Def|'' command, restores ``|\@arraycr|'' to its original
% meaning, ends the equation, and prevents spurious spaces by issuing
% the command ``|\global\@ignoretrue|''.
% \begin{macrocode}
\newenvironment{System}{%
\@ifnextchar[{\Label@System}{\@StandardEquation\@System@Def}%
}{%
\end{array}%
\right.%
\endequation%
\let\@arraycr=\@ArrayCR%
\global\@ignoretrue%
}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{System*}
% The ``|\System@Star|'' command generates en error message when used in
% math-mode, and calls ``|\@System@Def|'' inside a ``|displaymath|''
% environment (the ``|$$|'') when used in text-mode.
% \begin{macrocode}
%%
\def\System@Star[#1]{\StartMath@Err{System*}\@System@Def}
% \end{macrocode}
% The ``|System*|'' environment is the same as ``|System|'', but with
% ``|\begin{equation}|$\ldots$|\end{equation}|'' substituted by
% ``|$$|\ldots|$$|''.
% \begin{macrocode}
\@namedef{System*}{\@ifnextchar[{\System@Star}{\System@Star[]}}
\@namedef{endSystem*}{\end{array}\right. $$\let\@arraycr=\@ArrayCR \global\@ignoretrue}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{EQNarray}
% The |EQNarray| environment is only for backward compatibility:
% use the |equationarry| environment from package |eqnarray| if
% you need more control than an |eqnarray| environment allows.
% \begin{macrocode}
%%
\newenvironment{EQNarray}{%
\PackageError{\FileName}{Environment ``EQNarray'' is obsolete}{%
Use the ``equationarry'' environment from the ``eqnarray'' package instead!}%
\eqnarray%
}{%
\endeqnarray%
}
% \end{macrocode}
% \end{environment}
% \begin{macro}{\SystemColSep,\SystemBraceSep,\SystemStarIndent}
% \begin{macrocode}
%%
\newlength\SystemColSep
\setlength\SystemColSep{2em}
%%
\newlength\SystemBraceSep
\setlength\SystemBraceSep{3pt}
%%
\newlength\SystemStarIndent
\setlength\SystemStarIndent{2em}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{EqSystem}
% \begin{macrocode}
%%
\newsavebox{\SysRow@Box}
\newlength\ColOne@Width
\newlength\ColTwo@Width
\newlength\SysCol@TmpWidth
%%
\newcommand*\Start@EqSysRow{%
\OneShot@Amper{%
$\end{lrbox}%
\settowidth\SysCol@TmpWidth{\usebox{\SysRow@Box}}%
\ifnum\SysCol@TmpWidth>\ColOne@Width\global\setlength\ColOne@Width\SysCol@TmpWidth\fi%
\usebox{\SysRow@Box}%
}{%
\begin{lrbox}{\SysRow@Box}$\displaystyle%
}%
\begin{lrbox}{\SysRow@Box}$\displaystyle%
}
%%
\newcommand*\Stop@EqSysRow{%
$\end{lrbox}%
\settowidth\SysCol@TmpWidth{\usebox{\SysRow@Box}}%
\ifnum\catcode`\&=4%
\ifnum\SysCol@TmpWidth>\ColTwo@Width\global\setlength\ColTwo@Width\SysCol@TmpWidth\fi%
\else%
\MakeAmper@Tab%
\ifnum\SysCol@TmpWidth>\ColOne@Width\global\setlength\ColOne@Width\SysCol@TmpWidth\fi%
\fi%
\usebox{\SysRow@Box}%
}
%%
\def\@EqSystCR@star@quadra[#1]{%
\Sys@@eqncr%
\noalign{\penalty\@eqpen\vskip #1\relax}%
\Start@EqSysRow%
\mbox{\hspace{\SystemStarIndent}}%
}
%%
\def\@EqSystCR@star*{%
\global\@eqnswfalse%
\@ifnextchar[{\@EqSystCR@star@quadra}{%
\Sys@@eqncr\Start@EqSysRow\mbox{\hspace{\SystemStarIndent}}}%
}
%%
\def\@EqSystCR@quadra[#1]{%
\Sys@@eqncr%
\noalign{\penalty\@eqpen\vskip #1\relax}%
\Start@EqSysRow%
}
%%
\newcommand*\EqSyst@CR{%
\Stop@EqSysRow%
\@ifnextchar*{\@EqSystCR@star}{%
\@ifnextchar[{\@EqSystCR@quadra}{\Sys@@eqncr\Start@EqSysRow}}%
}
%%
\let\Label@EqSystem=\relax
%%
\newcommand*\Sys@@eqncr{%
\let\reserved@a\relax%
\ifcase\@eqcnt\def\reserved@a{& &}% %% \@eqcnt = 0
\or\def\reserved@a{&}% %% \@eqcnt = 1
\else% %% \@eqcnt > 1
\let\reserved@a\@empty%
\PackageError{\FileName}{Too many columns in EqSystem environment}{%
You can use at most one ``&'' in each row of an ``EqSystem'' environment.}%
\fi%
\reserved@a%
\if@eqnsw\Label@EqSystem\@eqnnum\stepcounter{equation}\fi%
\global\@eqnswtrue%
\global\@eqcnt\z@%
\cr%
}
%%
\newenvironment{EqSystem}[1][\relax]{%
\setcounter{EqSys@counter}{0}%
\def\Label@EqSystem{#1}%
\def\@tempa{\relax}%
\ifx\Label@EqSystem\@tempa\else%
\def\Label@EqSystem{\stepcounter{EqSys@counter}\label{#1:\alph{EqSys@counter}}}%
\fi%
\BEGIN@EqSystem%
}{%
\Stop@EqSysRow%
%%%-------------------- \endEQNarr@y ----------------------%
\Sys@@eqncr%
\egroup%
\global\advance\c@equation\m@ne%
$$%
%%%--------------------------------------------------------%
\vspace*{-\belowdisplayskip}%
\end{minipage}%
\advance\ColTwo@Width\ColOne@Width%
\advance\ColTwo@Width\SystemColSep%
\setlength\SysCol@TmpWidth\displaywidth%
\global\advance\SysCol@TmpWidth-\ColTwo@Width%
\global\divide\SysCol@TmpWidth\tw@%
\global\advance\SysCol@TmpWidth\ColTwo@Width%
\global\advance\SysCol@TmpWidth\SystemBraceSep% %% Space around left-brace
\global\advance\SysCol@TmpWidth 1em% %% ~= Left-brace size
\hspace{-\SysCol@TmpWidth}%
\right\lbrace%
\advance\SysCol@TmpWidth-1em% %% ~= Left-brace size
\hspace*{\SysCol@TmpWidth}%
$$\global\@ignoretrue%
}
%%
\newcommand*\BEGIN@EqSystem{%
\setlength\ColOne@Width\z@%
\setlength\ColTwo@Width\z@%
$$\left.%
\begin{minipage}{\displaywidth}%
\vspace*{-\abovedisplayskip}%
%%%-------------------------- \EQNarr@y -------------------%
\stepcounter{equation}%
\let\@currentlabel=\theequation%
\global\@eqnswtrue%
\global\@eqcnt\z@%
\tabskip\@centering%
\let\\=\EqSyst@CR%
$$\halign to \displaywidth\bgroup%
\tabskip\z@{##}\hfil%
&\global\@eqcnt\@ne%
\hspace{\SystemColSep}{##}\hfil%
\tabskip\@centering%
&\llap{##}\tabskip\z@\cr%
%%%--------------------------------------------------------%
\Start@EqSysRow%
}
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{EqSystem*}
% \begin{macrocode}
%%
\newcounter{EqSys@counter}
%%
\newcommand*\EqSystem@Star[1][\relax]{%
\stepcounter{equation}%
\setcounter{EqSys@counter}{\value{equation}}%
\def\Label@EqSystem{#1}%
\def\@tempa{\relax}%
\ifx\Label@EqSystem\@tempa\else%
\let\@currentlabel=\theequation%
\label{#1}%
\def\Label@EqSystem{\label{#1:\alph{equation}}}%
\fi%
\let\INNER@theEQUATION=\theequation%
\xdef\inner@theEQUATION{\theequation}%
\def\theequation{\inner@theEQUATION\alph{equation}}%
\setcounter{equation}{0}%
\BEGIN@EqSystem%
}
%%
\@namedef{EqSystem*}{\EqSystem@Star}
%%
\@namedef{endEqSystem*}{%
\endEqSystem%
\setcounter{equation}{\value{EqSys@counter}}%
\global\let\theequation=\INNER@theEQUATION%
}
% \end{macrocode}
% \end{environment}
%
% The \LaTeX{} environments \texttt{math} and \texttt{displaymath}
% are redefined so that they will not be affected by the subsequent
% redefinition of the brackets commands.
% The redefinition of the brackets commands is deferred at the
% |\begin{document}|, so that other packages may use the original
% definitions and cannot override the new ones.
% It only takes place if the ``|RedefBrackets|'' option is in effect.
% \begin{macrocode}
\if@Redefine@Brackets@
\AtBeginDocument{%
\let\math=\(
\let\endmath=\)
\let\displaymath=\[
\let\enddisplaymath=\]
\renewcommand*{\(}{\left(}%
\renewcommand*{\)}{\right)}%
\renewcommand*{\[}{\left[}%
\renewcommand*{\]}{\right]}%
\renewcommand*{\{}{\left\lbrace}%
\renewcommand*{\}}{\right\rbrace}%
}
\fi
% \end{macrocode}
%
%\iffalse % MetaComment
%<*package>
%\fi
%
% \CheckSum{653}
% \Finale
%
\endinput
|