summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mh/empheq07.dtx
blob: a8921940f1a562009664847eb350eaa55572dd62 (plain)
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
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
% \iffalse meta-comment
%
% Copyright (C) 2002-2007 by Morten Hoegholm <mh.ctan@gmail.com>
%
% This work may be distributed and/or modified under the
% conditions 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 distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainer of this work is Morten Hoegholm.
%
% This work consists of the main source file empheq07.dtx
% and the derived files
%    empheq07.sty, empheq07.pdf, empheq07.ins, empheq07.drv.
%
% Distribution:
%    CTAN:macros/latex/contrib/mh/empheq07.dtx
%    CTAN:macros/latex/contrib/mh/empheq07.pdf
%
% Unpacking:
%    (a) If empheq07.ins is present:
%           tex empheq07.ins
%    (b) Without empheq07.ins:
%           tex empheq07.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{empheq07.dtx}
%        (quote the arguments according to the demands of your shell)
%
% Documentation:
%    (a) If empheq07.drv is present:
%           latex empheq07.drv
%    (b) Without empheq07.drv:
%           latex empheq07.dtx; ...
%    The class ltxdoc loads the configuration file ltxdoc.cfg
%    if available. Here you can specify further options, e.g.
%    use A4 as paper format:
%       \PassOptionsToClass{a4paper}{article}
%
%    Programm calls to get the documentation (example):
%       pdflatex empheq07.dtx
%       makeindex -s gind.ist empheq07.idx
%       pdflatex empheq07.dtx
%       makeindex -s gind.ist empheq07.idx
%       pdflatex empheq07.dtx
%
% Installation:
%    TDS:tex/latex/mh/empheq07.sty
%    TDS:doc/latex/mh/empheq07.pdf
%    TDS:source/latex/mh/empheq07.dtx
%
%<*ignore>
\begingroup
  \def\x{LaTeX2e}
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: empheq07 2007/12/03 v0.7e empheq07 (MH)}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\preamble

This is a generated file.

Copyright (C) 2002-2007 by Morten Hoegholm <mh.ctan@gmail.com>

This work may be distributed and/or modified under the
conditions 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 distributions of
LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status "maintained".

This Current Maintainer of this work is Morten Hoegholm.

This work consists of the main source file empheq07.dtx
and the derived files
   empheq07.sty, empheq07.pdf, empheq07.ins, empheq07.drv.

\endpreamble

\generate{%
  \file{empheq07.ins}{\from{empheq07.dtx}{install}}%
  \file{empheq07.drv}{\from{empheq07.dtx}{driver}}%
  \usedir{tex/latex/mh}%
  \file{empheq07.sty}{\from{empheq07.dtx}{package}}%
}

\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*     empheq07.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `empheq07.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{empheq07.drv}%
  [2007/12/03 v0.7e Emphasizing equations (MH)]
\documentclass{ltxdoc}
\usepackage{empheq07}
\usepackage{color,fancybox,ifpdf}
\ifpdf\else
  \usepackage{pstricks}
\fi
\definecolor{lightblue}{rgb}{.8, .8, 1}
\OnlyDescription
\begin{document}
\DocInput{empheq07.dtx}
\end{document}
%</driver>
% \fi
% \DeclareRobustCommand{\mode}[1]{\texttt{#1}}
% \DeclareRobustCommand{\env}[1]{\textsf{#1}}
% \DeclareRobustCommand{\pkg}[1]{\texttt{#1}}
% \DeclareRobustCommand{\EQ}{\pkg{empheq07}}
%
%  \changes{v0.7d}{2004/07/27}{Changed name to \pkg{empheq07} by request
%  of Robin Fairbairns}
%
%  \changes{v0.7c}{2004/04/01}{Separated \pkg{empheq} and
%  \pkg{empheq-obsolete}}
%
%  \changes{v0.7b}{2004/03/13}{Upgraded license to LPPL version 1.3.
%  The package is still obsolete}
%
%  \changes{v0.7a}{2004/02/15}{This package is now obsolete and has
%  changed its name to \pkg{empheq-obsolete}}
%
% \changes{v0.6a}{2003/01/28}{Minor updates to documentation.}
%
% \changes{v0.5}{2002/12/30}{First experimental and very limited release}
% \newif\ifBonusExample
% \ifpdf\else
% \BonusExampletrue
% \fi
% \GetFileInfo{empheq07.drv}
% \CheckSum{1273}
% \title{The \EQ\ package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}\\Emphasizing equations in \LaTeXe
% \thanks{Thanks to Lars Madsen for asking for the subtle feature
% that evolved into this package.}}
% \author{Morten H\o gholm}
% \date{\filedate}
%
% \maketitle
%
%
% \begin{abstract}
% \noindent The \EQ\ package automatically detects several \pkg{amsmath}
% environments and the size of the displayed math material. The user
% interface makes it easy to add various kinds of visual markup to
% these equations.
% \end{abstract}
% \tableofcontents
%  \section{Important Notice}
%
%  This package (\EQ\ \fileversion) is no longer supported. See the
%  documentation of \pkg{empheq} for more details.
%
%
% \section{Introduction}
% Users who have wanted to put a system of equations inside boxes has
% hitherto been forced to use the features of \pkg{fancybox} or the \cmd{\boxed} command
% of \pkg{amsmath}. Both alternatives have serious limitations though.
% \pkg{fancybox} allows only \env{eqnarray}-style equations and at
% the end of the day they aren't all that pretty. Most mathematical
% typesetting in \LaTeX\ is done with the aid of \pkg{amsmath}
% anyway, but it only offers the single line quick-fix \cmd{\boxed}.
% What we really want is something that will enable us to do
% something along the likes of this:
% \begin{subequations}\label{eq:1}
% \begin{empheq}[boxtype=\fbox,Left= {\tilde{S}=1 \Rightarrow\empheqlbrace}]
% \begin{align}
% a&=\int_{-2}^3{t}b^t \, dt \quad\text{and} \label{eq:1a}\\
% c&=d-a \label{eq:1b}
% \end{align}
% \end{empheq}
% \end{subequations}
% As you can see, \EQ\ can do all the tricks the \pkg{cases} package
% by Donald Arseneau can do and more. It even supports
% \env{subequations}---as shown in equations \eqref{eq:1a} and
% \eqref{eq:1b}---from \pkg{amsmath} without complaining.
%
% In order to combine the best of two worlds the \EQ\ package
% tries to take advantage of the widespread features of \pkg{amsmath}.
% As it should be well known if you read this, \pkg{amsmath} has
% amongst its arsenal of structures \env{align}, \env{gather}, \env{alignat} and \env{multline}.
% \EQ\ works with these as well as their starred
% variants.
%
% ``But what about \env{equation}?'' you say.  \env{equation} is (in
% my opinion) merely a poor man's \env{gather}. If you really want
% to use \EQ's features on a one-liner (no pun intended) go with
% \env{gather}. Anyway the real goal of this package is to do nifty
% tricks with multi line equations \ldots
%
%
% \section{Examples}
% \changes{v0.7}{2003/05/11}{Added further examples and changed existing ones}
% Any options given to \EQ\ is passed on to \pkg{amsmath}, thus the
% line\par
% \cmd{\usepackage}\oarg{options}|{empheq07}|\\
% will load \pkg{amsmath} with exactly those options. \EQ\ doesn't
% redefine anything so to use it in an existing document you need
% only replace \pkg{amsmath} with \EQ---no harm done.
%
%
% \EQ\ is \emph{really} easy to use; you simply put an \env{empheq}
% environment around your \pkg{amsmath} environment:
% \begin{verbatim}
% \begin{empheq}
%   \begin{align}
%     E&=mc^2 \\
%     Y&= \sum_{n=1}^\infty \frac{1}{n^2}
%   \end{align}
% \end{empheq}
% \end{verbatim}
% \begin{empheq}
%   \begin{align}
%     E&=mc^2 \\
%     Y&= \sum_{n=1}^\infty \frac{1}{n^2}
%   \end{align}
% \end{empheq}
% Impressed? No? Well then I guess it's about time I told you about
% the \emph{optional} argument of the \env{empheq} environment. It allows
% you control what material to put on either side of the math and
% the sort of box to go around it all. That means that we can say
% \begin{verbatim}
% \begin{empheq}[boxtype=\fbox]
%   \begin{align}
%     E&=mc^2 \\
%     Y&= \sum_{n=1}^\infty \frac{1}{n^2}
%   \end{align}
% \end{empheq}
% \end{verbatim}
% to obtain the display
% \begin{empheq}[boxtype=\fbox]
%   \begin{align}
%     E&=mc^2 \\
%     Y&= \sum_{n=1}^\infty \frac{1}{n^2}
%   \end{align}
% \end{empheq}
% This requires the use of the \pkg{keyval} package from the tools
% bundle, which is undoubtedly installed on your system. When using
% the \pkg{keyval} package there are a few things we need to keep in
% mind. In mathematical typesetting `|=|' and `|,|' are quite
% frequently used, thus requiring the user to enclose them in
% braces:
% \begin{verbatim}
% \begin{empheq}[boxtype=\fbox,
%                Left={(a,b)=(c,i) \Rightarrow\empheqlbrace}]
% \begin{alignat}{2}
% (a,b)&= (\cos^a c, \tan^b i)&& \quad\text{for $i>1$}\\
% (a,b)&= (\arccos x^a, \arctan i^b)&& \quad\text{for $i\leq1$}
% \end{alignat}
% \end{empheq}
% \end{verbatim}
% \begin{empheq}[boxtype=\fbox,
%                Left={(a,b)=(c,i) \Rightarrow\empheqlbrace}]
% \begin{alignat}{2}
% (a,b)&= (\cos^a c, \tan^b i)&& \quad\text{for $i>1$}\\
% (a,b)&= (\arccos c^a, \arctan i^b)&& \quad\text{for $i\leq1$}
% \end{alignat}
% \end{empheq}
% The same with \env{cases} from \pkg{amsmath} for comparison:
% \[
% \boxed{(a,b)=(c,i) \Rightarrow
% \begin{cases} (a,b)= (\cos^a c, \tan^b i)& \text{for $i>1$}\\
% (a,b)= (\arccos x^a, \arctan i^b)& \text{for $i\leq1$}
% \end{cases}}
% \]
% Notice that \env{cases} uses an array for the conditions, so you
% have to force \cmd{\displaystyle} yourself. This is not needed with
% \EQ\ as you're already using a \cmd{\displaystyle} environment such as
% \env{gather} etc.
%
% \changes{v0.6b}{2003/03/04}{Added example for changing margins inside the boxtype.}
% Observe what can be done if we replace
% |\fbox| with another framed box and add some space on all sides:
% \begin{verbatim}
% \definecolor{lightblue}{rgb}{.8, .8, 1}
% \begin{empheq}[boxtype={\setlength{\fboxsep}{10pt}%
%                         \colorbox{lightblue}},
%                Right={\empheqrbrace \beta}]
%      .
%      .
%      .
% \end{empheq}
% \end{verbatim}
% \begin{empheq}[boxtype={\setlength{\fboxsep}{10pt}%
%                         \colorbox{lightblue}},Right={\empheqrbrace \beta}]
% \begin{align}
% a&=\int_{-2}^3{t}b^t \, dt \quad\text{and}\\
% c&=d-a
% \end{align}
% \end{empheq}
%
% As a convenience for the user, it is also possible to declare
% delimiters with the commands
% \cmd{\DeclareRightDelimiter}\marg{delimiter} and its companion
% \cmd{\DeclareLeftDelimiter}\marg{delimiter}. For instance the commands
%  \begin{quote}
% |\DeclareRightDelimiter{\rangle}| defines  \cmd{\empheqrangle}
%  \end{quote}
%  and
%  \begin{quote}
%  |\DeclareLeftDelimiter{\langle}| defines \cmd{\empheqlangle}.
%  \end{quote}
% The usage is simple.  \DeclareRightDelimiter{\rangle} \DeclareLeftDelimiter{\langle}
% \begin{verbatim}
% \begin{empheq}[Right=\empheqrangle,
%                Left=\empheqlangle]
%  \begin{gather}
%    a=b \\
%    c=d
%  \end{gather}
% \end{empheq}
% \end{verbatim}
% \begin{empheq}[Right=\empheqrangle,Left=\empheqlangle]
%  \begin{gather}
%    a=b \\
%    c=d
%  \end{gather}
% \end{empheq}
% \cmd{\DeclareRightDelimiter} and its companion have an optional
% argument which controls spacing (default is a negative thinspace),
% but beware: It will simply overwrite the original definition and
% it might not look all that pretty as the following example shows:
% \DeclareRightDelimiter[\>]{\rangle}
% \DeclareLeftDelimiter[\mkern-10mu]{\langle}
% \begin{verbatim}
% \DeclareRightDelimiter[\>]{\rangle}
% \DeclareLeftDelimiter[\mkern-10mu]{\langle}
% \end{verbatim}
% \begin{empheq}[Right=\empheqrangle,Left=\empheqlangle]
%  \begin{gather}
%    a=b \\
%    c=d
%  \end{gather}
% \end{empheq}
%
% These examples will have given you a glimpse of the possibilities
% \EQ\ offers. In particular the commands \cmd{\empheqlbrace} and
% \cmd{\empheqrbrace} produce braces just tall enough to encompass
% the display. You can of course use \cmd{\big...} delimiters if you
% want.
%
% \ifBonusExample
% If you want you can even create your own box and use it with
% \env{empheq}. In the following silly example I have created
% \cmd{\ErrorBox} with \pkg{PSTricks} to achieve a disturbing
% effect:
% \makeatletter
% \newcommand{\ErrorBox}[1]{%
%    \setlength{\@tempdima}{\heightof{#1}}%
%    \addtolength{\@tempdima}{\depthof{#1}}%
%    \setlength{\@tempdimb}{\widthof{#1}}%
%    \psset{yunit=\@tempdima}%
%    \psset{xunit=\@tempdimb}%
%    \psframebox[fillstyle=vlines,linestyle=none,hatchsep=.2\@tempdimb,hatchcolor=red,hatchangle=-60]{%
%    \rlap{\kern.5\@tempdimb\makebox[0pt]{{\Large\color{gray} \textbf{Error!}}}}#1}%
% }
% \makeatother
% \begin{empheq}[boxtype=\ErrorBox]
% \begin{align*}
%  E&=mc^3 \\
%  F&=G\frac{m+M}{r^2}
% \end{align*}
% \end{empheq}
% Remember one thing when creating your own box: Make it
% symmetrical.
% \fi
%
% \section{Bugs and shortcomings}
%  This package (\EQ) is not supported anymore. Try with the new
%  version and see if it works; if not, then contact me. See how in
%  the manual of \pkg{empheq}.
%
% \StopEventually{}
% \section{Implementation}
% \subsection{Strategy}
%
% Whenever \pkg{amsmath} is typesetting a display environment it
% actually does it twice; the first for the ``measuring'' phase and
% the second for the ``production'' phase. The \EQ\ package uses a
% similar approach:
%  \begin{itemize}
%     \item Collects the input in a token register for later use.
%     \item Typesets the input in the background and checks certain values to determine the kind of math structure you just typed.
%     \item Based on the given information, alterations are made to various lengths.
%     \item Then the equations are typeset again and stored in a box
%     for easy retrieval.
%     \item Finally the saved box is put into a box of the user's liking.
%     Any material to the right or left of the math structure (added with
%     the |Left| and |Right| keys) are put into the box as well.
%  \end{itemize}
%  Assuming we have found out which \pkg{amsmath} structure the
% user typed, there are still a few things we need to sort out
% before we proceed.
%
% First of all the equation number should still be aligned with
% those of the ordinary math structures, which is a problem as soon
% as the additions we make to the left and the right
% differ---presumably they will. And when we are in \mode{fleqn}
% mode, we should make sure that the structure is shifted just
% enough to the right so that all equations still are right
% adjusted. Therefore we need to make clever changes to the
% line width to make sure the margins come out right.
%
% Then assuming we have overcome all of this there's still the final
% step: Placing the math structure in the appropriate box at the
% appropriate position. Once again we need to do some manipulation
% with spacing to make it just right.
%
% \subsection{Preliminary actions}
%
% To avoid clashes with other packages, all private commands will contain the sequence \verb|@emphEQ@|.
%
% We will need \pkg{amsmath} of course and it would be nice if \EQ\
% would recognize all the \pkg{amsmath} options so we make that
% happen. To make sure the user has an updated system the newest
% release of \pkg{amsmath} is required.
%
% \pkg{calc} is used to increase readability of the code
% (thus making it \emph{far} easier to write too) and \pkg{keyval}
% is used for user friendliness. They should all be part of any
% \LaTeX\ system.
%    \begin{macrocode}
%<*package>
\ProvidesPackage{empheq07}%
  [2007/12/03 v0.7e Emphasizing equations (MH)]
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}}
\ProcessOptions\relax
\RequirePackage{amsmath}[2000/07/18]
\RequirePackage{calc,keyval}
%    \end{macrocode}
% \begin{macro}{\if@emphEQ@FLL}\begin{macro}{\if@emphEQ@FLR}\begin{macro}{\if@emphEQ@L}\begin{macro}{\if@emphEQ@R}
%  There are four available layouts for mathematical displays:
% |[fleqn,leqno]| (FLL), |[fleqn,reqno]| (FLR), |[leqno]| (L) and |[reqno]| (R). We create four \TeX\ conditionals
%  to make the algorithm easier to read as well as to speed up things a bit.
%    \begin{macrocode}
\newif\if@emphEQ@FLL
\newif\if@emphEQ@FLR
\newif\if@emphEQ@L
\newif\if@emphEQ@R
%    \end{macrocode}
%\end{macro}\end{macro}\end{macro}\end{macro}
% We then perform a simple test to determine the current mode.
%    \begin{macrocode}
\if@fleqn
    \iftagsleft@
        \@emphEQ@FLLtrue
    \else
        \@emphEQ@FLRtrue
    \fi
\else
    \iftagsleft@
        \@emphEQ@Ltrue
    \else
        \@emphEQ@Rtrue
    \fi
\fi
%    \end{macrocode}
% \begin{macro}{\if@emphEQ@gather}\begin{macro}{\if@emphEQ@align}\begin{macro}{\if@emphEQ@alignat}
% \begin{macro}{\if@emphEQ@multline}\begin{macro}{\if@emphEQ@NoNumEq}
% Since we're going to determinate which math structure the user has
% input, we create some more conditionals to improve speed and
% readability. Furthermore it will show crucial to know whether or
% not the equation counter has been stepped since \env{multline$*$}
% and \env{multline} don't have exactly the same structure.
%    \begin{macrocode}
\newif\if@emphEQ@gather
\newif\if@emphEQ@align
\newif\if@emphEQ@alignat
\newif\if@emphEQ@multline
\newif\if@emphEQ@NoNumEq
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
%
%
%
% \begin{macro}{\@emphEQ@Box}\begin{macro}{\@emphEQ@BoxWidth}
% \begin{macro}{\@emphEQ@displaywidth}\begin{macro}{\@emphEQ@mathbody}
% We need a single box to hold the math structure, a length so we
% can remember the size of the displayed math for later use and a
% token register for the math environment.
%    \begin{macrocode}
\newsavebox{\@emphEQ@Box}
\newlength{\@emphEQ@BoxWidth}
\newlength{\@emphEQ@displaywidth}
\newtoks\@emphEQ@mathbody
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\@emphEQ@Left}\begin{macro}{\@emphEQ@Right}\begin{macro}{\@emphEQ@lwd}\begin{macro}{\@emphEQ@rwd}
% Here are some vital parts: The additional informations the user
% want to display on either side of the math structure are saved by
% \cmd{\@emphEQ@Left} and \cmd{\@emphEQ@Right} and \cmd{\@emphEQ@lwd} and \cmd{\@emphEQ@rwd}
% measure the width of them for later use.
%    \begin{macrocode}
\newcommand{\@emphEQ@Left}{}
\newcommand{\@emphEQ@Right}{}
\newlength{\@emphEQ@lwd}
\newlength{\@emphEQ@rwd}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\@emphEQ@boxtype}\begin{macro}{\@emphEQ@boxtypelength}
% \begin{macro}{\@emphEQ@shadowbox}\begin{macro}{\if@emphEQ@shadowbox}
% To make sure spacing is right when putting the math structure into
% a box, we need to know what kind of box it is: The width is
% extremely important. Often we will have to subtract or add half of
% an empty (but \emph{not} zero-width) box' width to certain
% lengths. When using an \cmd{\fbox} or \cmd{\colorbox} this is just
% \cmd{\fboxrule}+\cmd{\fboxsep}, but when using say,
% \cmd{\doublebox} of \pkg{fancybox} fame the necessity arises.
% \pkg{fancybox} also defines \cmd{\shadowbox} which needs extra
% taking care of, since it's asymmetrical unlike most other framed
% boxes.
%
% Thus we test whether or not \pkg{fancybox} has been loaded at the
% beginning of the document. If it has, we don't lift a finger; if
% it hasn't, we let \cmd{\fbox} be an alias for \cmd{\shadowbox}.
% Then we create a private version of \cmd{\shadowbox} for
% testing purposes and a conditional for the algorithm.
%    \begin{macrocode}
\newcommand{\@emphEQ@boxtype}{}
\newlength{\@emphEQ@boxtypelength}
\AtBeginDocument{%
    \@ifpackageloaded{fancybox}{}{%
        \let\shadowbox=\fbox}}
\newcommand{\@emphEQ@shadowbox}{\shadowbox}
\newif\if@emphEQ@shadowbox
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\@emphEQ@templength}\begin{macro}{@emphEQ@EqCtr}
% We are almost ready to go. We only need two temporary little
% helpers: one length and one counter.
%    \begin{macrocode}
\newlength{\@emphEQ@templength}
\newcounter{@emphEQ@EqCtr}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \subsubsection{Faraway, so close}\label{sec:CloseEnough}
% \begin{macro}{\@emphEQ@CloseEnough}
% \changes{v0.6}{2003/01/10}{Added a test for lengths being almost identical}
% When determining the display type we will occasionally have to check if an equation of the
% form
%  \[
%  \cmd{\totwidth@}-\cmd{\tagshift@}=\cmd{\linewidth}
%  \]
% is true. However small rounding errors \emph{can} occur in
% \env{alignat} so we would rather see if the equation
%  \[
%  -\delta<\cmd{\totwidth@}-\cmd{\tagshift@}-\cmd{\linewidth}<\delta
%  \]
% holds for some sufficiently small $\delta>\text{$0$ pt}$. I have used $\delta=\text{$5$ sp}$.
%    \begin{macrocode}
\newcommand{\@emphEQ@CloseEnough}[4]{%
    \setlength{\@tempdima}{#1-#2}%
    \ifdim\@tempdima>-5sp
        \ifdim\@tempdima<5sp
            #3
        \else
            #4
        \fi
    \else
        #4
    \fi
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Saving the input}
% \begin{macro}{\@emphEQ@MainEnv}
% \changes{v0.7}{2003/05/11}{Added use of token register to remove the
% need for an extra \cmd{\write} and \pkg{verbatim}}
% \begin{macro}{\end@emphEQ@MainEnv}
% \begin{macro}{\@emphEQ@get@body}\begin{macro}{\@emphEQ@findend}
% \begin{macro}{\@emphEQ@EnvName}
% We start out by saving the input in the token register
% \cmd{\@emphEQ@mathbody}. The method is heavily inspired by
% \pkg{tabularx} \dots\@ No need to copy the words of David Carlisle here---his code will do!
%    \begin{macrocode}
\def\@emphEQ@MainEnv{%
    \edef\@emphEQ@EnvName{\@currenvir}%
    {\ifnum0=`}\fi
    \@emphEQ@mathbody{}\@emphEQ@get@body
}
\let\end@emphEQ@MainEnv\relax
\long\def\@emphEQ@get@body#1\end{%
    \@emphEQ@mathbody\expandafter{\the\@emphEQ@mathbody #1}%
    \@emphEQ@findend
}
\def\@emphEQ@findend#1{%
    \def\@tempa{#1}%
    \ifx\@tempa\@emphEQ@EnvName
        \expandafter\@emphEQ@PostProcess
    \else
        \@emphEQ@mathbody\expandafter{\the\@emphEQ@mathbody\end{#1}}%
        \expandafter\@emphEQ@get@body
    \fi
}
\def\@emphEQ@EnvName{@emphEQ@MainEnv}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{@emphEQ@PostProcess}
% Now we can go on with the post processing, which is the real
% workhorse in this package.  The first job is to test if we're
% using a \cmd{\shadowbox} and then we set some \pkg{amsmath}
% dimensions to zero---\pkg{amsmath} doesn't do this by itself, and
% for that we can be thankful. Otherwise you wouldn't be reading
% this now~;-)
%    \begin{macrocode}
\newcommand*{\@emphEQ@PostProcess}{%
    \ifx\@emphEQ@boxtype\@emphEQ@shadowbox
        \@emphEQ@shadowboxtrue
    \else
        \@emphEQ@shadowboxfalse
    \fi
    \tagshift@=0pt \tagwidth@=0pt \totwidth@=0pt
    \eqnshift@=0pt \alignsep@=0pt
%    \end{macrocode}
% \subsection{The first pass}
% We then run the first pass to find out which environment we've
% got. However we have to store the equation counter because it is
% stepped in this pass, and we certainly don't want that to happen.
% As a side effect this will also tell us if the equations are
% numbered.
%
% If we are to put a brace to the left of the display, it would be
% rather pleasant to know just how high the structure is, since this
% will affect the height and more importantly the width the brace:
% we will need to know the \emph{exact} width of such material.
% Hence we put it in a box which is easy to measure and fiddle
% around with. To achieve this we put the contents of the token register
% \cmd{\@emphEQ@mathbody} in a \env{minipage} inside a \env{lrbox}. Alas,
% \env{lrbox} won't let us escape into display math mode, so we play
% a dirty trick on it and use a \env{minipage}, which will let us
% have our way with it.
%
% The \env{minipage} starts in horizontal mode and then goes
% straight to display math mode, thus adding some space before the
% display math. However there was nothing on the first line in the
% \env{minipage} thus leading \TeX\ to add a \cmd{\abovedisplayskip}
% before the display. We subtract this as fast as we can!
% Furthermore it showed in test runs, that an additional~1~pt had to
% be subtracted in the top---but not in the bottom. It has nothing
% to do with any of the standard page dimensions or parameters.
% Strange indeed.
%    \begin{macrocode}
    \setcounter{@emphEQ@EqCtr}{\value{equation}}%
    \begin{lrbox}{\@emphEQ@Box}%
        \begin{minipage}{\linewidth}%
        \vskip-\abovedisplayskip\relax\vskip-1pt\relax
        \the\@emphEQ@mathbody
        \end{minipage}%
    \end{lrbox}%
%    \end{macrocode}
% We then look at the equation counter to see if we had any numbered
% equations and reset it if that was the case. If we used a
% \env{multline$*$} we can detect this by measuring |\tagwidth@|.
%    \begin{macrocode}
    \ifnum\value{equation}=\value{@emphEQ@EqCtr}%
        \ifdim\tagwidth@>0pt
        \else
            \@emphEQ@NoNumEqtrue
        \fi
    \else
        \setcounter{equation}{\value{@emphEQ@EqCtr}}%
    \fi
%    \end{macrocode}
% Now we can determine the various math environments. Firstly we
% measure an empty \cmd{\@emphEQ@boxtype}---we will need this
% information when the math structure is finally put into a box of
% this type, but we have to take it into account when calculating
% the allowable width of \env{multline} displays because we want to
% use the margins already set for this environment.
%    \begin{macrocode}
    \settowidth{\@emphEQ@boxtypelength}{\@emphEQ@boxtype{}}%
%    \end{macrocode}
% The idea is that each of the \pkg{amsmath} multiple line
% environments can be singled out because it uses a certain
% dimension in a way none of the others use it.
% \begin{list}{}{}
%  \item[\env{align}:] Uses \cmd{\alignsep@} and sets it to something
%  positive. None of the others use it.
%  \item[\env{multline}:] Doesn't use \cmd{\eqnshift@}.
%  \item[\env{gather}:] Doesn't use \cmd{\tagshift@}.
%  \item[\env{alignat}:] Can be determined because some dimensions
%  will have special relations e.g., when in |[fleqn,reqno]| mode
%  the equation
%  \[
%  \cmd{\totwidth@}-\cmd{\tagshift@}=\cmd{\linewidth}
%  \]
%  holds\footnote{Well almost---they may be off by a few scaled points.
%  See section~\ref{sec:CloseEnough} for further details.}
%  and similarly for the other three display modes. See the
%  code for these equations.
% \end{list}
%
% \subsubsection{\mode{[fleqn,leqno]}}
% ~
%    \begin{macrocode}
    \if@emphEQ@FLL % fleqn and leqno
        \ifdim\alignsep@>0pt % => align
            \@emphEQ@aligntrue
            \setlength{\@emphEQ@displaywidth}{\tagshift@-\@mathmargin}%
        \else
            \ifdim\eqnshift@=0pt % => multline %tagwidth@>
                \@emphEQ@multlinetrue
                \if@emphEQ@NoNumEq
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-\multlinegap-\@mathmargin
                        -\@emphEQ@boxtypelength}%
                \else
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-\tagwidth@-\multlinegap
                        -\multlinetaggap-\@emphEQ@boxtypelength}%
                \fi
            \else
                \ifdim\tagshift@=0pt % => gather
                    \@emphEQ@gathertrue
                    \setlength{\@emphEQ@displaywidth}{%
                        \totwidth@-\@mathmargin}%
                \else
                    \ifdim\tagshift@=\totwidth@ % => alignat
                        \@emphEQ@alignattrue
                        \setlength{\@emphEQ@displaywidth}{%
                            \totwidth@-\@mathmargin}%
                    \else
                        %Nothing thus far...
                    \fi
                \fi
            \fi
        \fi
    \fi
%    \end{macrocode}
% \subsubsection{\mode{[fleqn,reqno]}}
% ~
%    \begin{macrocode}
    \if@emphEQ@FLR % fleqn and reqno
        \ifdim\alignsep@>0pt % => align
            \@emphEQ@aligntrue
            \setlength{\@emphEQ@displaywidth}{%
                \linewidth-\@mathmargin+\tagshift@}%
        \else
            \ifdim\eqnshift@=0pt % => multline
                \@emphEQ@multlinetrue
                \if@emphEQ@NoNumEq
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-\multlinegap-\@mathmargin
                        -\@emphEQ@boxtypelength}%
                \else
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-\tagwidth@-\@mathmargin
                        -\multlinetaggap-\@emphEQ@boxtypelength}%
                \fi
            \else
                \ifdim\tagshift@=0pt % => gather
                    \@emphEQ@gathertrue
                    \setlength{\@emphEQ@displaywidth}{%
                        \totwidth@-\@mathmargin}%
                \else
                    \@emphEQ@CloseEnough{\totwidth@-\tagshift@}%
                    {\linewidth}%
                    {\@emphEQ@alignattrue
                    \setlength{\@emphEQ@displaywidth}%
                    {\totwidth@-\eqnshift@}}{}%
                \fi
            \fi
        \fi
    \fi
%    \end{macrocode}
% \subsubsection{\mode{[reqno]}}
% ~
%    \begin{macrocode}
    \if@emphEQ@R % reqno
        \ifdim\alignsep@>0pt % => align
            \@emphEQ@aligntrue
            \setlength{\@emphEQ@displaywidth}{\totwidth@}%
        \else
            \ifdim\eqnshift@=0pt % => multline
                \@emphEQ@multlinetrue
                \if@emphEQ@NoNumEq
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-2\multlinegap
                        -\@emphEQ@boxtypelength}%
                \else
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-\tagwidth@-\multlinegap
                        -\multlinetaggap-\@emphEQ@boxtypelength}%
                \fi
            \else
                \ifdim\tagshift@=0pt % => gather
                    \@emphEQ@gathertrue
                    \setlength{\@emphEQ@displaywidth}{\totwidth@}%
                \else
                    \@emphEQ@CloseEnough{\tagshift@}{-\eqnshift@}%
                    {\@emphEQ@alignattrue
                    \setlength{\@emphEQ@displaywidth}{\totwidth@}}{}%
                \fi
            \fi
        \fi
    \fi
%    \end{macrocode}
% \subsubsection{\mode{[leqno]}}
% ~
%    \begin{macrocode}
    \if@emphEQ@L % leqno
        \ifdim\alignsep@>0pt % => align
            \@emphEQ@aligntrue
            \setlength{\@emphEQ@displaywidth}{\totwidth@}%
        \else
            \ifdim\eqnshift@=0pt % => multline
                \@emphEQ@multlinetrue
                \if@emphEQ@NoNumEq
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-2\multlinegap
                        -\@emphEQ@boxtypelength}%
                \else
                    \setlength{\@emphEQ@displaywidth}{%
                        \linewidth-\tagwidth@-\multlinegap
                        -\multlinetaggap-\@emphEQ@boxtypelength}%
                \fi
            \else
                \ifdim\tagshift@=0pt % => gather
                    \@emphEQ@gathertrue
                    \setlength{\@emphEQ@displaywidth}{\totwidth@}%
                \else
                    \@emphEQ@CloseEnough{%
                        \linewidth-\eqnshift@}{\tagshift@}{%
                        \@emphEQ@alignattrue
                        \setlength{\@emphEQ@displaywidth}{\totwidth@}}%
                        {}%
                \fi
            \fi
        \fi
    \fi
%    \end{macrocode}
% Phew! That was tedious, but necessary. I wish I could say it got
% better further down the road, but it doesn't. Now we can measure
% the width of the additional material on both sides of the math
% structure. We add braces here and there to avoid any
% \cmd{\thinmuskip}'s.
%    \begin{macrocode}
    \settowidth{\@emphEQ@lwd}{${\@emphEQ@Left}%
                               {\vphantom{\usebox{\@emphEQ@Box}}}$}%
    \settowidth{\@emphEQ@rwd}{${\vphantom{\usebox{\@emphEQ@Box}}}%
                               {\@emphEQ@Right}$}%
%    \end{macrocode}
%
% \subsection{The second pass}
%
% When we try to create an effect as in the preliminary example
% there are a few things we need to tell \LaTeX\ for the overall
% result to be acceptable. If the display math is centered, then the
% new one should also be centered. This means that when typesetting
% the math structure for the second time, we need to make
% adjustments to \cmd{\linewidth}, \cmd{\@mathmargin} etc.\ for the
% equation tag to be placed correctly.
%
% That process is extremely tedious, but there are only few
% shortcuts, so we just go through each of the four environments, check
% each of the four display modes and alter dimensions a we trudge
% along. First we check if we are trying to put something into an
% asymmetrical box and then make it symmetrical be removing the size
% of the shadow.
%    \begin{macrocode}
    \begin{lrbox}{\@emphEQ@Box}%
    \if@emphEQ@shadowbox
        \addtolength{\@emphEQ@boxtypelength}{-\shadowsize}%
    \fi
%    \end{macrocode}
% \subsubsection{\env{align}}
% ~
%    \begin{macrocode}
    \if@emphEQ@align
        \if@emphEQ@FLL
            \begin{minipage}{\linewidth+\@emphEQ@lwd
                +.5\@emphEQ@boxtypelength}%
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%%
        \fi
        \if@emphEQ@FLR
            \begin{minipage}{\linewidth}%
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%%
        \fi
        \if@emphEQ@L
            \begin{minipage}{\linewidth+\@emphEQ@lwd-\@emphEQ@rwd}%
        \fi
        \if@emphEQ@R
            \begin{minipage}{\linewidth-\@emphEQ@lwd+\@emphEQ@rwd}%
        \fi
    \fi
%    \end{macrocode}
% \subsubsection{\env{gather}}
% ~
%    \begin{macrocode}
    \if@emphEQ@gather
        \if@emphEQ@FLL
            \begin{minipage}{\linewidth+\@emphEQ@lwd
                +.5\@emphEQ@boxtypelength}%
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%%
        \fi
        \if@emphEQ@FLR
            \begin{minipage}{\linewidth}%
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%%
        \fi
        \if@emphEQ@R
            \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
                       -\eqnshift@}%
            \begin{minipage}{\linewidth-\@emphEQ@lwd+\@emphEQ@rwd
                             +\@emphEQ@templength-\eqnshift@}%
        \fi
        \if@emphEQ@L
            \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
                       -\eqnshift@}%
            \begin{minipage}{\linewidth+\@emphEQ@lwd-\@emphEQ@rwd
                             -\@emphEQ@templength+\eqnshift@}%
        \fi
    \fi
%    \end{macrocode}
% \subsubsection{\env{alignat}}
% ~
%    \begin{macrocode}
    \if@emphEQ@alignat
        \if@emphEQ@FLL
            \begin{minipage}{\linewidth+\@emphEQ@lwd
                +.5\@emphEQ@boxtypelength}%
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%%
        \fi
        \if@emphEQ@FLR
            \begin{minipage}{\linewidth}%
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%%
        \fi
        \if@emphEQ@L
            \begin{minipage}{\linewidth+\@emphEQ@lwd-\@emphEQ@rwd}%
        \fi
        \if@emphEQ@R
            \begin{minipage}{\linewidth-\@emphEQ@lwd+\@emphEQ@rwd}%
        \fi
    \fi
%    \end{macrocode}
% \subsubsection{\env{multline}}
% ~
%    \begin{macrocode}
    \if@emphEQ@multline
        \if@emphEQ@FLL
            \begin{minipage}{\linewidth}%
                \if@emphEQ@NoNumEq
                    \addtolength{\@mathmargin}{\@emphEQ@lwd
                        +.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\@mathmargin}{\shadowsize}
                    \fi%
                \else
                    \addtolength{\multlinetaggap}{\@emphEQ@lwd
                        +.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinegap}{\shadowsize}%
                    \fi
                \fi
                \addtolength{\multlinegap}{\@emphEQ@rwd
                    +.5\@emphEQ@boxtypelength}%
        \fi
        \if@emphEQ@FLR
            \begin{minipage}{\linewidth}%
                \if@emphEQ@NoNumEq
                    \addtolength{\multlinegap}{\@emphEQ@rwd
                        +.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinegap}{\shadowsize}%
                    \fi
                \else
                    \addtolength{\multlinetaggap}{\@emphEQ@rwd
                        +.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinetaggap}{\shadowsize}%
                    \fi
                \fi
                \addtolength{\@mathmargin}{\@emphEQ@lwd
                    +.5\@emphEQ@boxtypelength}%
        \fi
        \if@emphEQ@L
            \begin{minipage}{\linewidth}%
                \if@emphEQ@NoNumEq
                    \addtolength{\multlinegap}{.5\@emphEQ@rwd
                        +.5\@emphEQ@lwd+.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinegap}{.5\shadowsize}%
                    \fi
                \else
                    \addtolength{\multlinetaggap}{\@emphEQ@lwd
                        +.5\@emphEQ@boxtypelength}%
                    \addtolength{\multlinegap}{\@emphEQ@rwd
                        +.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinegap}{\shadowsize}%
                    \fi
                \fi
        \fi
        \if@emphEQ@R
            \begin{minipage}{\linewidth}%
                \if@emphEQ@NoNumEq
                    \addtolength{\multlinegap}{.5\@emphEQ@rwd
                        +.5\@emphEQ@lwd+.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinegap}{.5\shadowsize}
                    \fi
                \else
                    \addtolength{\multlinetaggap}{\@emphEQ@rwd
                        +.5\@emphEQ@boxtypelength}%
                    \addtolength{\multlinegap}{\@emphEQ@lwd
                        +.5\@emphEQ@boxtypelength}%
                    \if@emphEQ@shadowbox
                        \addtolength{\multlinetaggap}{\shadowsize}
                    \fi
                \fi
        \fi
    \fi
%    \end{macrocode}
% Finally we get to typeset the contents of \cmd{\@emphEQ@mathbody} for
% the second time\ldots
%    \begin{macrocode}
    \vskip-\abovedisplayskip\relax\vskip-1pt\relax
    \the\@emphEQ@mathbody
    \end{minipage}%
    \end{lrbox}%
%    \end{macrocode}
%
% \subsection{Putting it into the box}
%
% Because we were clever to start with---by measuring the width of
% the display math  and storing it in
% \cmd{\@emphEQ@displaywidth}---we can now put it into a box of
% width
% \cmd{\@emphEQ@displaywidth}+\cmd{\@emphEQ@rwd}+\cmd{\@emphEQ@lwd}.
% This doesn't apply to \env{multline} though: it has to be set in a
% box of width \cmd{\@emphEQ@displaywidth}.
%    \begin{macrocode}
\setlength{\@emphEQ@BoxWidth}{\@emphEQ@displaywidth+\@emphEQ@rwd
                              +\@emphEQ@lwd}%
%    \end{macrocode}
% \subsubsection{\env{align}}
% ~
%    \begin{macrocode}
\if@emphEQ@align
    \if@emphEQ@FLL
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength%
            \kern-\@mathmargin
            \kern-\@emphEQ@lwd
            \usebox{\@emphEQ@Box}%
            \kern-\@emphEQ@displaywidth
            \kern-\@emphEQ@rwd
            \kern-\@emphEQ@lwd
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@FLR
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength%
            \kern-\@mathmargin
            \kern-\@emphEQ@lwd
            \usebox{\@emphEQ@Box}%
            \kern-\alignsep@
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@L
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
            %\kern\eqnshift@
            %\kern-\alignsep@
            $\@emphEQ@Left$%
            \kern-\eqnshift@
            %\kern-\alignsep@
            \usebox{\@emphEQ@Box}%
            %\kern-\eqnshift@
            \kern-\alignsep@
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@R
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
            $\@emphEQ@Left$%
            \kern-\eqnshift@
            \usebox{\@emphEQ@Box}%
            \kern-\eqnshift@
            $\@emphEQ@Right$}}%
    \fi
\fi
%    \end{macrocode}
% \subsubsection{\env{alignat}}
% ~
%    \begin{macrocode}
\if@emphEQ@alignat
    \if@emphEQ@FLL
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@mathmargin
            \kern-\@emphEQ@lwd
            \usebox{\@emphEQ@Box}%
            \kern\@mathmargin
            \kern\@emphEQ@displaywidth
            \kern-\linewidth
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@FLR
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@mathmargin
            \kern-\@emphEQ@lwd
            \usebox{\@emphEQ@Box}%
            \kern\@mathmargin
            \kern\@emphEQ@displaywidth
            \kern-\linewidth
            \kern\@emphEQ@lwd
            \kern.5\@emphEQ@boxtypelength
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@L
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
            $\@emphEQ@Left$%
            \kern-\eqnshift@
            \usebox{\@emphEQ@Box}%
            \kern-\eqnshift@
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@R
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
            $\@emphEQ@Left$%
            \kern-\eqnshift@
            \usebox{\@emphEQ@Box}%
            \kern-\eqnshift@
            $\@emphEQ@Right$}}%
    \fi
\fi
%    \end{macrocode}
% \subsubsection{\env{gather}}
% ~
%    \begin{macrocode}
\if@emphEQ@gather
    \if@emphEQ@FLL
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@mathmargin
            \kern-\@emphEQ@lwd
            \usebox{\@emphEQ@Box}%
            \kern-\linewidth
            \kern\@mathmargin
            \kern\@emphEQ@displaywidth
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@FLR
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize
            \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@mathmargin
            \kern-\@emphEQ@lwd
            \usebox{\@emphEQ@Box}%
            \kern-\linewidth
            \kern.5\@emphEQ@boxtypelength
            \kern\@mathmargin
            \kern\@emphEQ@displaywidth
            \kern\@emphEQ@lwd
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@L
        \setlength{\tagwidth@}{\eqnshift@+\@emphEQ@rwd}%
        \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
                                        -\eqnshift@}%
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
            \ifdim\@emphEQ@templength<\tagwidth@
                \setlength{\tagwidth@}{\@emphEQ@templength
                                       +\@emphEQ@lwd}%
                \ifdim\tagwidth@<\eqnshift@
                    \kern-\@emphEQ@templength
                    \kern\eqnshift@
                \fi
            \else
                \kern-\@emphEQ@lwd
                \kern\@emphEQ@rwd
                \kern-\@emphEQ@templength
                \kern\eqnshift@
            \fi
            $\@emphEQ@Left$%
            \kern-\eqnshift@
            \usebox{\@emphEQ@Box}%
            %\kern-\eqnshift@
            \kern-\@emphEQ@lwd
            \kern\@emphEQ@rwd
            \kern-\@emphEQ@templength
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@R
        \setlength{\tagwidth@}{\eqnshift@+\@emphEQ@rwd}%
        \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
                                        -\eqnshift@}%
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
            \kern-\@emphEQ@lwd
            \kern\@emphEQ@rwd
            \kern\@emphEQ@templength
            \kern-\eqnshift@
            $\@emphEQ@Left$%
            \ifdim\@emphEQ@templength>\tagwidth@
                \kern-\eqnshift@
            \else
                \kern\@emphEQ@lwd
                \kern-\@emphEQ@rwd
                \kern-\@emphEQ@templength
            \fi
            \usebox{\@emphEQ@Box}%
            \kern-\eqnshift@
            $\@emphEQ@Right$}}%
    \fi
\fi
%    \end{macrocode}
% \subsubsection{\env{multline}}
%
% \env{multline} is somewhat more difficult because \env{multline$*$}
% differs on several accounts. Thus we make use of our little test
% to see if the math structure was numbered to begin with
% (\verb|\if@emphEQ@NoNumEq|).
%    \begin{macrocode}
\if@emphEQ@multline
    \if@emphEQ@FLL
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@emphEQ@lwd
            \if@emphEQ@NoNumEq
                \if@emphEQ@shadowbox \kern-\shadowsize \fi
                \kern-\@mathmargin
            \else
                \kern-\tagwidth@
                \kern-\multlinetaggap
            \fi
            \usebox{\@emphEQ@Box}%
            \kern-\@emphEQ@boxtypelength
            \if@emphEQ@NoNumEq
                \kern-\multlinegap
            \else
                \kern\multlinegap
            \fi
            \kern-\@emphEQ@rwd
            \kern-\@emphEQ@lwd
            \kern-\@mathmargin
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@FLR
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@emphEQ@lwd
            \kern-\@mathmargin
            \usebox{\@emphEQ@Box}%
            \kern-\@emphEQ@boxtypelength
            \kern-\@emphEQ@rwd
            \kern-\@emphEQ@lwd
            \if@emphEQ@NoNumEq
                \kern-\multlinegap
            \else
                \kern-\multlinetaggap
            \fi
            \kern-\@mathmargin
            \kern-\tagwidth@
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@L
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@emphEQ@lwd
            \if@emphEQ@NoNumEq
                \kern-\multlinegap
                \kern.5\@emphEQ@lwd
                \kern-.5\@emphEQ@rwd
                \if@emphEQ@shadowbox \kern-.5\shadowsize \fi
            \else
                \kern-\multlinetaggap
                \kern-\tagwidth@
            \fi
            \usebox{\@emphEQ@Box}%
            \kern-.5\@emphEQ@boxtypelength
            \if@emphEQ@NoNumEq
                \kern.5\@emphEQ@rwd
                \kern-.5\@emphEQ@lwd
            \fi
            \kern-\@emphEQ@rwd
            \kern-\multlinegap
            $\@emphEQ@Right$}}%
    \fi
    \if@emphEQ@R
        \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
            \if@emphEQ@shadowbox \kern.5\shadowsize \fi
            $\@emphEQ@Left$%
            \kern-.5\@emphEQ@boxtypelength
            \if@emphEQ@NoNumEq
                \if@emphEQ@shadowbox \kern-.5\shadowsize \fi
                \kern-.5\@emphEQ@rwd
                \kern.5\@emphEQ@lwd
            \fi
            \kern-\@emphEQ@lwd
            \kern-\multlinegap
            \usebox{\@emphEQ@Box}%
            \kern-.5\@emphEQ@boxtypelength
            \kern-\@emphEQ@rwd
            \if@emphEQ@NoNumEq
                \kern-\multlinegap
                \kern-.5\@emphEQ@lwd
                \kern.5\@emphEQ@rwd
            \else
                \kern-\multlinetaggap
            \fi
            \kern-\tagwidth@
            $\@emphEQ@Right$}}%
    \fi
\fi
%    \end{macrocode}
%
% \subsubsection{The final step}
%
% At last here comes the good part! We are now ready to place the
% box containing all of our math material. If we have used a
% \env{multline} we have to do a few kerning tricks but at least we
% would seem to know the drill by now\ldots To make sure vertical
% spacing is ok, we put it all into a simple math environment
% \verb|\[...\]|.
%    \begin{macrocode}
\[
    \if@emphEQ@align
        \if@emphEQ@L
            \kern-\alignsep@
            \kern\eqnshift@
        \fi
    \fi
    \if@emphEQ@gather
        \if@emphEQ@L
            \kern-\@emphEQ@templength
            \kern\eqnshift@
            \kern\@emphEQ@rwd
            \kern-\@emphEQ@lwd
        \fi
        \if@emphEQ@R
            \setlength{\tagwidth@}{\eqnshift@+\@emphEQ@rwd}%
            \ifdim\@emphEQ@templength>\tagwidth@
                \kern-\@emphEQ@templength
                \kern\eqnshift@
                \kern\@emphEQ@lwd
            \else
                \kern\@emphEQ@templength
                \kern-\eqnshift@
                \kern\@emphEQ@rwd
                \kern-\@emphEQ@lwd
            \fi
        \fi
    \fi
    \if@emphEQ@multline
        \if@emphEQ@NoNumEq
            % naught
        \else
            \if@emphEQ@FLL
                \kern-\@mathmargin
                \kern\tagwidth@
                \kern\multlinetaggap
            \fi
            \if@emphEQ@L
                \kern\tagwidth@
                \kern\multlinetaggap
                \kern-\multlinegap
            \fi
            \if@emphEQ@R
                \kern-\tagwidth@
                \kern-\multlinetaggap
                \kern\multlinegap
            \fi
        \fi
    \else
%    \end{macrocode}
% If we are using a \cmd{\shadowbox} in centered display mode, I
% would rather that the shadowsize is ignored when placing the box.
% Reason: I think it looks better. Judge for yourself:
% \begin{gather}
% a=b\\
% \Phi(x)=\int_{-\infty}^x e^{-t^2/2}\, dt
% \end{gather}
%
% \begin{empheq}[boxtype=\shadowbox]
% \begin{gather}
% a=b\\
% \Phi(x)=\int_{-\infty}^x e^{-t^2/2}\, dt
% \end{gather}
% \end{empheq}
%    \begin{macrocode}
        \if@emphEQ@shadowbox
            \if@emphEQ@R
                \kern\shadowsize
            \fi
            \if@emphEQ@L
                \kern\shadowsize
            \fi
        \fi
    \fi
        \@emphEQ@boxtype{\usebox{\@emphEQ@Box}}%
%    \end{macrocode}
% After all is done, we empty out the added material and the
% boxtype.
%    \begin{macrocode}
        \gdef\@emphEQ@Left{}\gdef\@emphEQ@Right{}%
        \gdef\@emphEQ@boxtype{}%
    \]%
    \ifnum0=`{\fi}%
    \expandafter\end\expandafter{\@emphEQ@EnvName}%
}
%    \end{macrocode}
%
% \subsection{Going public\ldots}
% \begin{macro}{boxtype}\begin{macro}{Left}\begin{macro}{Right}\begin{macro}{empheq}
% In order to simplify the user interface, we make use of
% \pkg{keyval}. We define three keys to be used along with a more
% accessible version of \env{@emphEQ@MainEnv}.
% \changes{v0.7}{2003/05/11}{Changed the user interface slightly}
%    \begin{macrocode}
\define@key{empheq}{boxtype}{\renewcommand\@emphEQ@boxtype{#1}}
\define@key{empheq}{Left}{\def\@emphEQ@Left{#1}}
\define@key{empheq}{Right}{\def\@emphEQ@Right{#1}}
\newenvironment{empheq}[1][]{\setkeys{empheq}{#1}\@emphEQ@MainEnv}%
                          {\end@emphEQ@MainEnv\ignorespacesafterend}%
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\DeclareLeftDelimiter}
% \changes{v0.7}{2003/05/11}{Added delimiter interface}
% \begin{macro}{\DeclareRightDelimiter}
% \changes{v0.7}{2003/05/11}{Added delimiter interface}
% It might come in handy to have delimiters of the appropriate size
% available to cover the math display as in \eqref{eq:1}. Therefore
% we define two commands that will create such delimiters once and
% for all.
% Use this as an inspiration for further kinds of delimiters.
%    \begin{macrocode}
\newcommand{\DeclareLeftDelimiter}[2][\!]{%
    \@namedef{empheq\expandafter\@gobble\string#2}{
    \left#2
    \vphantom{\usebox{\@emphEQ@Box}}%
    \right.#1}}
\newcommand{\DeclareRightDelimiter}[2][\!]{%
    \@namedef{empheq\expandafter\@gobble\string#2}{%
        #1\left.
        \vphantom{\usebox{\@emphEQ@Box}}%
        \right#2}}%
\DeclareRightDelimiter{\rbrace}
\DeclareLeftDelimiter{\lbrace}
%</package>
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \Finale
\endinput