-
Notifications
You must be signed in to change notification settings - Fork 3
/
breqn.dtx
7279 lines (7248 loc) · 243 KB
/
breqn.dtx
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
% \iffalse meta-comment
%
% Copyright (C) 1997-2003 by Michael J. Downes
% Copyright (C) 2007-2008 by Morten Hoegholm
% Copyright (C) 2007-2014 by Lars Madsen
% Copyright (C) 2007-2020 by Will Robertson
% Copyright (C) 2010-2017 by Joseph Wright
% Copyright (C) 2020-2020 by Ulrike Fischer
%
% 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".
%
% The Current Maintainer of this work is Will Robertson.
%
% This work consists of the main source file breqn.dtx
% and the derived files
% breqn.sty, breqn.pdf, breqn.ins.
%
% Distribution:
% CTAN:macros/latex/contrib/mh/breqn.dtx
% CTAN:macros/latex/contrib/mh/breqn.pdf
%
% Unpacking:
% tex breqnbundle.ins
%
% Documentation:
% 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 breqn.dtx
% makeindex -s gind.ist breqn.idx
% pdflatex breqn.dtx
% makeindex -s gind.ist breqn.idx
% pdflatex breqn.dtx
%
% Installation:
% TDS:tex/latex/breqn/breqn.sty
% TDS:doc/latex/breqn/breqn.pdf
% TDS:source/latex/breqn/breqn.dtx
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass{ltxdoc}
\CodelineIndex
\EnableCrossrefs
\setcounter{IndexColumns}{2}
\usepackage{color,verbatim,xspace,varioref,listings,amsmath,trace}
\usepackage{geometry}
\def\partname{Part}
\definecolor{hilite}{rgb}{0.2,0.4,0.7}
\def\theCodelineNo{\textcolor{hilite}{\sffamily\tiny\arabic{CodelineNo}}}
\lstloadlanguages{[AlLaTeX]TeX}
\lstnewenvironment{literalcode}
{\lstset{gobble=2,columns=fullflexible,basicstyle=\color{hilite}\ttfamily}}
{}
\makeatletter
{\catcode`\%=12
\long\gdef\@gobble@percent@space#1{\ifx
#1%\expandafter\@gobble\else\expandafter#1\fi}}
\AtBeginDocument{\def\verbatim@processline{\expandafter\check@percent
\the\verbatim@line\par}}
\newwrite\tmp@out
\newcounter{xio}
\newenvironment{xio}{% example input and output
\par\addvspace\bigskipamount
\hbox{\itshape
\refstepcounter{xio}\kern-\p@ Example \thexio}\@nobreaktrue
\immediate\openout\tmp@out\jobname.tmp \relax
\begingroup
\let\do\@makeother\dospecials\catcode`\^^M\active
\def\verbatim@processline{
\immediate\write\tmp@out{\expandafter\@gobble@percent@space
\the\verbatim@line}}%
\verbatim@start
}{%
\immediate\closeout\tmp@out
\@verbatim\frenchspacing\@vobeyspaces
\@@input \jobname.tmp \relax
\endgroup
\par\medskip
\noindent\ignorespaces
\@@input \jobname.tmp \relax
\par\medskip
}
\providecommand*\pkg[1]{\textsf{#1}}
\providecommand*\cls[1]{\textsf{#1}}
\providecommand*\opt[1]{\texttt{#1}}
\providecommand*\env[1]{\texttt{#1}}
\providecommand*\fn[1]{\texttt{#1}}
\providecommand*\cn[1]{\cs{#1}}
\providecommand*\csarg[1]{\texttt{\char`\{#1\char`\}}}
\providecommand*\tex{\TeX\xspace}
\providecommand*\latex{\LaTeX\xspace}
\providecommand*\dbldollars{\texttt{\detokenize{$$}}}%$$
\providecommand*\arg{}
\edef\arg{\expandafter\@gobble\string\#}
\newenvironment{aside}{\begin{quote}\bfseries}{\end{quote}}
\newenvironment{dn}{\begin{quote}\bfseries}{\end{quote}}
\newcommand\dash{\textemdash}
\newcommand\dbslash[1]{\texttt{\string\\}}
\newcommand\thepkg{the \pkg{breqn} package\xspace}
\providecommand*\texbook{\textsl{The \protect\TeX{}book}\xspace}
\providecommand*\dotsc{\ldots}
\providecommand*\eqref[1]{(\ref{#1})}
\providecommand*\qq[1]{\textquotedblleft#1\textquotedblright}
\providecommand*\quoted[1]{\textquoteleft#1\textquoteright}
\providecommand*\dquoted[1]{\textquotedblleft#1\textquotedblright}
\providecommand*\ie{i.e.,\xspace}
\providecommand*\eg{e.g.,\xspace}
\providecommand*\etc{etc.\xspace}
\providecommand*\cf{cf.\xspace}
\providecommand*\ndash{\unskip\textendash\ignorespaces}
\providecommand*\mdash{\unskip\textemdash\ignorespaces}
\makeatother
\usepackage{breqn}
\begin{document}
\DocInput{breqn.dtx}
\end{document}
%</driver>
% \fi
%
%
% \title{The \pkg{breqn} package}
% \def\fileversion{0.98l}
% \def\filedate{2021/10/28}
% \date{\pkg{breqn} bundle: \filedate\space\fileversion}
% \author{Authors: Michael J. Downes, Morten H\o gholm\\ Maintained by Morten H\o gholm, Will Robertson\\ Feedback: \texttt{https://github.com/wspr/breqn/issues}}
%
% \maketitle
% \begin{abstract}
% The \pkg{breqn} package facilitates automatic line-breaking of
% displayed math expressions.
% \end{abstract}
%
%
% \tableofcontents
%
%
% \part{User's guide}
%
% \section{A bit of history}
%
% Originally \pkg{breqn}, \pkg{flexisym}, and \pkg{mathstyle} were
% created by Michael J.~Downes from the American Mathematical Society
% during the 1990's up to late 2002. Sadly---and much to the shock of
% the \TeX\ world---Michael passed away in early 2003 at the age of
% only~44.
%
% The American Mathematical Society kindly allowed Morten H\o gholm to
% assume maintainership of this part of his work and we wish to
% express our gratitude to them and to Barbara Beeton in particular for
% providing the files needed.
%
% MH brought Michael's work to a wider audience, thereby allowing users to create
% more \emph{masterpieces of the publishing art} as we think he would
% have wanted.
%
% Following the July 2008 breqn release, \pkg{breqn} was left in the hands
% of a maintenance team, while MH moved on with other projects.
%
% \section{Package loading}
%
% The \pkg{breqn} package automatically loads \pkg{amsmath} to avoid loading order conflicts.
% It also automatically loads \pkg{flexisym} and \pkg{mathstyle}, but in some cases these
% packages need to be loaded separately. The canonical order for package loading is:
% \begin{verbatim}
% \usepackage{amsmath}
% \usepackage{flexisym}
% \usepackage{breqn}
% \end{verbatim}
%
% The recommended way of loading the \pkg{breqn} package is to load it
% \emph{before} other packages dealing with math symbols, \ie, before
% \pkg{amssymb}, or packages such as \pkg{mathpazo} or \pkg{mathptmx}.
% However, this can sometimes lead to macro definition clashes, and in such cases
% you may need to juggle the loading order to make it work.
%
% \subsection{Options for \pkg{flexisym}}
%
% The \pkg{flexisym} package (described in section \vref{flexisym}) is
% required by \pkg{breqn} and ensures the math symbols are set up
% correctly. By default \pkg{breqn} loads it with support for Computer
% Modern but if you use a different math package requiring slightly
% different definitions, \pkg{flexisym} must be explicitly loaded before \pkg{breqn} as shown above.
% Below is an example of how you enable \pkg{breqn} to work with the widely
% used \pkg{mathpazo} package.
% \begin{verbatim}
%\usepackage{mathpazo}
%\usepackage[mathpazo]{flexisym}
%\usepackage{breqn}
% \end{verbatim}
% Currently, the packages \pkg{mathpazo} and \pkg{mathptmx} are
% supported. Despair not: Chances are that the package will work using
% the default settings. If you find that a particular math font
% package doesn't work then please see implementation in
% \fn{flexisym.dtx} for how to create a support file---it is easier
% than one might think. Contributions welcome.
%
%
% \section{Introduction}
%
% The \pkg{breqn} package for \LaTeX\ provides solutions to a number of
% common difficulties in writing displayed equations and getting
% high-quality output. For example, it is a well-known inconvenience that
% if an equation must be broken into more than one line, \cs{left} \dots\
% \cs{right} constructs cannot span lines. The \pkg{breqn} package makes
% them work as one would expect whether or not there is an intervening
% line break.
%
% The single most ambitious goal of the \pkg{breqn} package, however, is
% to support automatic linebreaking of displayed equations. Such
% linebreaking cannot be done without substantial changes under the hood
% in the way math formulas are processed. For this reason, especially in
% the alpha release, users should proceed with care and keep an eye out
% for unexpected glitches or side effects.
%
% \section{Principal features}
% The principal features of the \pkg{breqn} package are:
% \begin{description}
%
% \item[semantically oriented structure] The way in which compound
% displayed formulas are subdivided matches the logical structure more
% closely than, say, the standard \env{eqnarray} environment. Separate
% equations in a group of equations are written as separate environments
% instead of being bounded merely by \dbslash/ commands. Among other
% things, this clears up a common problem of wrong math symbol spacing at
% the beginning of continuation lines. It also makes it possible to
% specify different vertical space values for the space between lines of a
% long, broken equation and the space between separate equations in a
% group of equations.
%
% \item[automatic line breaking] Overlong equations will be broken
% automatically to the prevailing column width, and continuation lines
% will be indented following standard conventions.
%
% \item[line breaks within delimiters] Line breaks within \cs{left} \dots\
% \cs{right} delimiters work in a natural way. Line breaks can be
% forbidden below a given depth of delimiter nesting through a package
% option.
%
% \item[mixed math and text] Display equations that contain mixed
% math and text, or even text only, are handled naturally by means of a
% \env{dseries} environment that starts out in text mode instead of math
% mode.
%
% \item[ending punctuation] The punctuation at the end of a displayed
% equation can be handled in a natural way that makes it easier to promote
% or demote formulas from\slash to inline math, and to apply special
% effects such as adding space before the punctuation.
%
% \item[flexible numbering] Equation numbering is handled in a natural
% way, with all the flexibility of the \pkg{amsmath} package and with no
% need for a special \cs{nonumber} command.
%
% \item[special effects] It is easy to apply special effects to individual
% displays, e.g., changing the type size or adding a frame.
%
% \item[using available space] Horizontal shrink is made use of
% whenever feasible. With most other equation macros it is frozen when it
% occurs between \cs{left} \dots\ \cs{right} delimiters, or in any sort of
% multiline structure, so that some expressions require two lines that would
% otherwise fit on one.
%
% \item[high-quality spacing] The \cs{abovedisplayshortskip} is used when
% applicable (other equation macros fail to apply it in equations of more
% than one line).
%
% \item[abbreviations] Unlike the \pkg{amsmath} equation environments, the
% \pkg{breqn} environments can be called through user-defined abbreviations
% such as \cs{beq} \dots\ \cs{eeq}.
%
% \end{description}
%
% \section{Shortcomings of the package}
% The principal known deficiencies of the \pkg{breqn} package are:
%
% \subsection{Incompatibilities} As it pushes the envelope
% of what is possible within the context of \LaTeXe, \thepkg will tend
% to break other packages when used in combination with them, or to fail
% itself, when there are any areas of internal overlap; successful use may
% in some cases depend on package loading order.
%
%
%
% \subsection{Indention of delimited fragments} When line breaks within
% delimiters are involved, the automatic indention of continuation lines
% is likely to be unsatisfactory and need manual adjustment. I don't see
% any easy way to provide a general solution for this, though I have some
% ideas on how to attain partial improvements.
%
% \subsection{Math symbol subversion}
% In order for automatic line breaking to work, the operation of all the
% math symbols of class 2, 3, 4, and 5 must be altered (relations, binary
% operators, opening delimiters, closing delimiters). This is done by an
% auxiliary package \pkg{flexisym}. As long as you stick to the advertised
% \LaTeX\ interface for defining math symbols (\cs{DeclareMathSymbol}),
% things should work OK most of the time. Any more complex math symbol
% setup is quite likely to quarrel with the \pkg{flexisym} package.
% See Section~\vref{flexisym} for further information.
%
% \subsection{Subscripts and superscripts}
%
% Because of the changes to math symbols of class 2--5, writing certain
% combinations such as \verb'^+' or \verb'_\pm' or \verb'^\geq' without
% braces would lead to error messages; (The problem described here
% already exists in standard \LaTeX\ to a lesser extent, as you may know
% if you ever tried \verb'^\neq' or \verb'^\cong'; and indeed there are
% no examples in the \LaTeX\ book to indicate any sanction for omitting
% braces around a subscript or superscript.)
%
% The \pkg{flexisym} package therefore calls, as of version 0.92, another
% package called \pkg{mathstyle} which turns \verb'^' and \verb'_' into
% active characters. This is something that I believe is desirable in any
% case, in the long run, because having a proper mathstyle variable
% eliminates some enormous burdens that affect almost any
% nontrivial math macros, as well as many other things where the
% connection is not immediately obvious, e.g., the \LaTeX\ facilities for
% loading fonts on demand.
%
% Not that this doesn't introduce new and interesting problems of its
% own---for example, you don't want to put usepackage statements
% after flexisym for any package that refers to, e.g., \verb'^^J' or
% \verb'^^M'
% internally (too bad that the \LaTeX\ package loading code does not
% include automatic defenses to ensure normal catcodes in the interior of
% a package; but it only handles the \verb'@' character).
%
% But I took a random AMS journal article, with normal end-user kind of
% \LaTeX\ writing, did some straightforward substitutions to change all
% the equations into dmath environments, and ran it with active math
% sub/sup: everything worked OK. This suggests to me that it can work in
% the real world, without an impossible amount of compatibility work.
%
% \section{Incomplete}
% In addition, in the \textbf{alpha release [1997/10/30]} the following
% gaps remain to be filled in:
% \begin{description}
% \item[documentation]
% The documentation could use amplification, especially more
% illustrations, and I have undoubtedly overlooked more than a few errors.
%
% \item[group alignment] The algorithm for doing alignment
% of mathrel symbols across equations in a \env{dgroup} environment
% needs work. Currently the standard and \opt{noalign} alternatives
% produce the same output.
%
% \item[single group number] When a \env{dgroup} has a group number and
% the individual equations are unnumbered, the handling and placement of
% the group number aren't right.
%
% \item[group frame] Framing a group doesn't work, you might be able to
% get frames on the individual equations at best.
%
% \item[group brace] The \opt{brace} option for \env{dgroup} is intended
% to produce a large brace encompassing the whole group. This hasn't been
% implemented yet.
%
% \item[darray environment] The \env{darray} environment is unfinished.
%
% \item[dseries environment] The syntax and usage for the \env{dseries}
% environment are in doubt and may change.
%
% \item[failure arrangements] When none of the line-breaking passes for a
% \env{dmath} environment succeeds\dash i.e., at least one line is
% overfull\dash the final arrangement is usually rather poor. A better
% fall-back arrangement in the failure case is needed.
%
% \end{description}
%
% \section{Package options}
%
% Many of the package options for \thepkg are the same as options of the
% \env{dmath} or \env{dgroup} environments, and some of them require an
% argument, which is something that cannot be done through the normal
% package option mechanism. Therefore most of the \pkg{breqn} package
% options are designed to be set with the \cs{breqnsetup} command after the
% package is loaded. For example, to load the package and set the
% maximum delimiter nesting depth for line breaks to~1:
% \begin{verbatim}
% \usepackage{breqn}
% \breqnsetup{breakdepth={1}}
% \end{verbatim}
%
% See the discussion of environment options, Section~\vref{envopts}, for
% more information.
%
% Debugging information is no longer available as a package
% option. Instead, the tracing information has been added in a fashion
% so that it can be enabled as a docstrip option:
% \begin{verbatim}
% \generate{\file{breqn.sty}{\from{breqn.dtx}{package,trace}}}
% \end{verbatim}
%
%
% \section{Environments and commands}
% \subsection{Environments}
% All of the following environments take an optional argument for
% applying local effects such as changing the typesize or adding a
% frame to an individual equation.
%
% \begin{description}
% \item[\env{dmath}] Like \env{equation} but supports line breaking and variant
% numbers.
%
% \item[\env{dmath*}] Unnumbered; like \env{displaymath} but supports line
% breaking
%
% \item[\env{dseries}] Like \env{equation} but starts out in text mode;
% intended for series of mathematical expressions of the form `A, B, and
% C'. As a special feature, if you use
% \begin{verbatim}
% \begin{math} ... \end{math}
% \end{verbatim}
% for each expression in the series, a suitable amount of inter-expression
% space will be automatically added. This is a small step in the direction of
% facilitating conversion of display math to inline math, and vice versa: If
% you write a display as
% \begin{verbatim}
% \begin{dseries}
% \begin{math}A\end{math},
% \begin{math}B\end{math},
% and
% \begin{math}C\end{math}.
% \end{dseries}
% \end{verbatim}
% then conversion to inline form is simply a matter of removing the
% \verb'\begin{dseries}' and \verb'\end{dseries}' lines; the contents of the
% display need no alterations.
%
% It would be nice to provide the same feature for \verb'$' notation but
% there is no easy way to do that because the \verb'$' function has no
% entry point to allow changing what happens before math mode is entered.
% Making it work would therefore require turning \verb'$' into an active
% character, something that I hesitate to do in a \LaTeXe\ context.
%
% \item[\env{dseries*}] Unnumbered variant of \env{dseries}
%
% \item[\env{dgroup}] Like the \env{align} environment of \pkg{amsmath},
% but with each constituent equation wrapped in a \env{dmath},
% \env{dmath*}, \env{dseries}, or \env{dseries*} environment instead of being
% separated by \dbslash/. The equations are numbered with a group number.
% When the constituent environments are the numbered forms (\env{dmath} or
% \env{dseries}) they automatically switch to `subequations'-style
% numbering, i.e., something like (3a), (3b), (3c), \dots, depending on
% the current form of non-grouped equation numbers. See also
% \env{dgroup*}.
%
% \item[\env{dgroup*}] Unnumbered variant of \env{dgroup}. If the
% constituent environments are the numbered forms, they get normal
% individual equation numbers, i.e., something like (3), (4), (5), \dots~.
%
% \item[\env{darray}] Similar to \env{eqnarray} but with an argument like
% \env{array} for giving column specs. Automatic line breaking is not
% done here.
%
% \item[\env{darray*}] Unnumbered variant of \env{darray}, rather like
% \env{array} except in using \cs{displaystyle} for all column
% entries.
%
% \item[\env{dsuspend}] Suspend the current display in order to print
% some text, without loss of the alignment. There is also a command
% form of the same thing, \cs{intertext}.
% \end{description}
%
% \subsection{Commands}
%
% The commands provided by \thepkg are:
% \begin{description}
% \item[\cs{condition}] This command is used for
% a part of a display which functions as a condition on the main
% assertion. For example:
% \begin{verbatim}
% \begin{dmath}
% f(x)=\frac{1}{x} \condition{for $x\neq 0$}
% \end{dmath}.
% \end{verbatim}
% \begin{dmath}
% f(x)=\frac{1}{x} \condition{for $x\neq 0$}
% \end{dmath}.
% The \cs{condition} command automatically switches to text mode (so that
% interword spaces function the way they should), puts in a comma, and
% adds an appropriate amount of space. To facilitate promotion\slash
% demotion of formulas, \cs{condition} \qq{does the right thing} if used
% outside of display math.
%
% To substitute a different punctuation mark instead of the default comma,
% supply it as an optional argument for the \cs{condition} command:
% \begin{verbatim}
% \condition[;]{...}
% \end{verbatim}
% (Thus, to get no punctuation: \verb'\condition[]{...}'.)
%
% For conditions that contain no text, you can use the starred form of the
% command, which means to stay in math mode:
% \begin{verbatim}
% \begin{dmath}
% f(x)=\frac{1}{x} \condition*{x\neq 0}
% \end{dmath}.
%
% If your material contains a lot of conditions like these, you might like
% to define shorter abbreviations, e.g.,
% \begin{verbatim}
% \newcommand{\mc}{\condition*}% math condition
% \newcommand{\tc}{\condition}% text condition
% \end{verbatim}
% But \thepkg refrains from predefining such abbreviations in order that
% they may be left to the individual author's taste.
%
% \item[\cs{hiderel}] In a compound equation it is sometimes desired to
% use a later relation symbol as the alignment point, rather than the
% first one. To do this, mark all the relation symbols up to the desired
% one with \cs{hiderel}:
% \begin{verbatim}
% T(n) \hiderel{\leq} T(2^n) \leq c(3^n - 2^n) ...
% \end{verbatim}
% \end{description}
%
% \section{Various environment options}\label{envopts}
%
% The following options are recognized for the \env{dmath}, \env{dgroup},
% \env{darray}, and \env{dseries} environments; some of the options do not
% make sense for all of the environments, but if an option is used where
% not applicable it is silently ignored rather than treated as an error.
% \changes{v0.98b}{2010/08/27}{replaced relindent with indentstep}
%
% \begin{verbatim}
% \begin{dmath}[style={\small}]
% \begin{dmath}[number={BV}]
% \begin{dmath}[labelprefix={eq:}]
% \begin{dmath}[label={xyz}]
% \begin{dmath}[indentstep={2em}]
% \begin{dmath}[compact]
% \begin{dmath}[spread={1pt}]
% \begin{dmath}[frame]
% \begin{dmath}[frame={1pt},framesep={2pt}]
% \begin{dmath}[breakdepth={0}]
% \end{verbatim}
%
% Use the \opt{style} option to change the type size of an individual
% equation. This option can also serve as a catch-all option for
% altering the equation style in other ways; the contents are simply
% executed directly within the context of the equation.
%
% Use the \opt{number} option if you want the number for a particular
% equation to fall outside of the usual sequence. If this option is used
% the equation counter is not incremented. If for some reason you need to
% increment the counter and change the number at the same time, use the
% \opt{style} option in addition to the \opt{number} option:
% \begin{verbatim}
% style={\refstepcounter{equation}}
% \end{verbatim}
%
% Use of the normal \cs{label} command instead of the \opt{label} option
% works, I think, most of the time (untested). \opt{labelprefix} prepends
% its argument to the label (only useful as a global option, really),
% and must be called before \opt{label}.
%
% \changes{v0.98b}{2010/08/27}{replaced relindent with indentstep}
% Use the \opt{indentstep} option to specify something other than the
% default amount for the indention of relation symbols. The default is
% 8pt.
%
% Use the \opt{compact} option in compound equations to inhibit line
% breaks at relation symbols. By default a line break will be taken before
% each relation symbol except the first one. With the \opt{compact} option
% \LaTeX\ will try to fit as much material as possible on each line, but
% breaks at relation symbols will still be preferred over breaks at binary
% operator symbols.
%
% Use the \opt{spread} option to increase (or decrease) the amount of
% interline space in an equation. See the example given above.
%
% Use the \opt{frame} option to produce a frame around the body of the
% equation. The thickness of the frame can optionally be specified by
% giving it as an argument of the option. The default thickness is
% \cs{fboxrule}.
%
% Use the \opt{framesep} option to change the amount of space separating
% the frame from what it encloses. The default space is \cs{fboxsep}.
%
% Use the \opt{breakdepth} option to change the level of delimiter nesting
% to which line breaks are allowed. To prohibit line breaks within
% delimiters, set this to 0:
% \begin{verbatim}
% \begin{dmath}[breakdepth={0}]
% \end{verbatim}
% The default value for breakdepth is 2. Even when breaks are allowed
% inside delimiters, they are marked as less desirable than breaks outside
% delimiters. Most of the time a break will not be taken within delimiters
% until the alternatives have been exhausted.
%
% Options for the \env{dgroup} environment: all of the above, and also
% \begin{verbatim}
% \begin{dgroup}[noalign]
% \begin{dgroup}[brace]
% \end{verbatim}
%
% By default the equations in a \env{dgroup} are mutually aligned on their
% relation symbols ($=$, $<$, $\geq$, and the like). With the
% \opt{noalign} option each equation is placed individually without
% reference to the others.
%
% The \opt{brace} option means to place a large brace encompassing the
% whole group on the same side as the equation number.
%
% Options for the \env{darray} environment: all of the above (where
% sensible), and also
% \begin{verbatim}
% \begin{darray}[cols={lcr@{\hspace{2em}}lcr}]
% \end{verbatim}
% The value of the \opt{cols} option for the darray environment should be
% a series of column specs as for the \env{array} environment, with the
% following differences:
% \begin{itemize}
% \item For l, c, and r what you get is not text, but math, and
% displaystyle math at that. To get text you must use a 'p' column
% specifier, or put an \cs{mbox} in each of the individual cells.
%
% \item Vertical rules don't connect across lines.
% \end{itemize}
%
% \section{The \pkg{flexisym} package}\label{flexisym}
%
% The \pkg{flexisym} package does some radical changes in the setup for
% math symbols to allow their definitions to change dynamically throughout
% a document. The \pkg{breqn} package uses this to make symbols of classes
% 2, 3, 4, 5 run special functions inside an environment such as
% \env{dmath} that provide the necessary support for automatic line
% breaking.
%
% The method used to effect these changes is to change the definitions of
% \cs{DeclareMathSymbol} and \cs{DeclareMathDelimiter}, and then
% re-execute the standard set of \LaTeX\ math symbol definitions.
% Consequently, additional mathrel and mathbin symbols defined by other
% packages will get proper line-breaking behavior if the other package is
% loaded after the \pkg{flexisym} package and the symbols are defined
% through the standard interface.
%
%
%
% \section{Caution! Warning!}
% Things to keep in mind when writing documents with \thepkg:
% \begin{itemize}
%
% \item The notation $:=$ must be written with the command \cs{coloneq}.
% Otherwise the $:$ and the $=$ will be treated as two separate relation
% symbols with an \qq{empty RHS} between them, and they will be printed
% on separate lines.
%
% \item Watch out for constructions like \verb'^+' where a single binary
% operator or binary relation symbol is subscripted or superscripted. When
% the \pkg{breqn} or \pkg{flexisym} package is used, braces are mandatory
% in such constructions: \verb'^{+}'. This applies for both display and
% in-line math.
%
% \item If you want \LaTeX\ to make intelligent decisions about line
% breaks when vert bars are involved, use proper pairing versions of the
% vert-bar symbols according to context: \verb'\lvert n\rvert' instead of
% \verb'|n|'. With the nondirectional \verb'|' there is no way for \LaTeX\
% to reliably deduce which potential breakpoints are inside delimiters
% (more highly discouraged) and which are not.
%
% \item If you use the \pkg{german} package or some other package that
% turns double quote \verb'"' into a special character, you may encounter
% some problems with named math symbols of type mathbin, mathrel,
% mathopen, or mathclose in moving arguments. For example, \cs{leq} in a
% section title will be written to the \fn{.aux} file as something like
% \verb'\mathchar "3214'. This situation probably ought to be improved,
% but for now use \cs{protect}.
%
% \item Watch out for the \texttt{[} character at the beginning of a
% \env{dmath} or similar environment, if it is supposed to be interpreted
% as mathematical content rather than the start of the environment's
% optional argument.
%
% This is OK:
% \begin{verbatim}
% \begin{dmath}
% [\lambda,1]...
% \end{dmath}
% \end{verbatim}
% This will not work as expected:
% \begin{verbatim}
% \begin{dmath}[\lambda,1]...\end{dmath}
% \end{verbatim}
%
% \item Watch out for unpaired delimiter symbols (in display math only):
% \begin{verbatim}
% ( ) [ ] \langle \rangle \{ \} \lvert \rvert ...
% \end{verbatim}
% If an open delimiter is used without a close delimiter, or vice versa,
% it is normally harmless but may adversely affect line breaking. This is only
% for symbols that have a natural left or right directionality. Unpaired
% \cs{vert} and so on are fine.
%
% When a null delimiter is used as the other member of the pair
% (\verb'\left.' or \verb'\right.') this warning doesn't apply.
%
% \item If you inadvertently apply \cs{left} or \cs{right} to something
% that is not a delimiter, the error messages are likely to be a bit
% more confusing than usual. The normal \LaTeX\ response to an error such
% as
% \begin{verbatim}
% \left +
% \end{verbatim}
% is an immediate message
% \begin{verbatim}
% ! Missing delimiter (. inserted).
% \end{verbatim}
% When \thepkg is in use, \LaTeX\ will fail to realize anything is wrong
% until it hits the end of the math formula, or a closing delimiter
% without a matching opening delimiter, and then the first message is an
% apparently pointless
% \begin{verbatim}
% ! Missing \endgroup inserted.
% \end{verbatim}
%
% \end{itemize}
%
% \section{Examples}
%
% \renewcommand\theequation{\thesection.\arabic{equation}}
% % Knuth, SNA p74
% \begin{xio}
% Replace $j$ by $h-j$ and by $k-j$ in these sums to get [cf.~(26)]
% \begin{dmath}[label={sna74}]
% \frac{1}{6} \left(\sigma(k,h,0) +\frac{3(h-1)}{h}\right)
% +\frac{1}{6} \left(\sigma(h,k,0) +\frac{3(k-1)}{k}\right)
% =\frac{1}{6} \left(\frac{h}{k} +\frac{k}{h} +\frac{1}{hk}\right)
% +\frac{1}{2} -\frac{1}{2h} -\frac{1}{2k},
% \end{dmath}
% which is equivalent to the desired result.
% \end{xio}
%
% % Knuth, SNA 4.6.2, p387
% \begin{xio}
% \newcommand\mx[1]{\begin{math}#1\end{math}}% math expression
% %
% Now every column which has no circled entry is completely zero;
% so when $k=6$ and $k=7$ the algorithm outputs two more vectors,
% namely
% \begin{dseries}[frame]
% \mx{v^{[2]} =(0,5,5,0,9,5,1,0)},
% \mx{v^{[3]} =(0,9,11,9,10,12,0,1)}.
% \end{dseries}
% From the form of the matrix $A$ after $k=5$, it is evident that
% these vectors satisfy the equation $vA =(0,\dotsc,0)$.
% \end{xio}
%
% \begin{xio}
% \begin{dmath*}
% T(n) \hiderel{\leq} T(2^{\lceil\lg n\rceil})
% \leq c(3^{\lceil\lg n\rceil}
% -2^{\lceil\lg n\rceil})
% <3c\cdot3^{\lg n}
% =3c\,n^{\lg3}
% \end{dmath*}.
% \end{xio}
%
% \begin{xio}
% The reduced minimal Gr\"obner basis for $I^q_3$ consists of
% \begin{dgroup*}
% \begin{dmath*}
% H_1^3 = x_1 + x_2 + x_3
% \end{dmath*},
% \begin{dmath*}
% H_2^2 = x_1^2 + x_1 x_2 + x_2^2 - q_1 - q_2
% \end{dmath*},
% \begin{dsuspend}
% and
% \end{dsuspend}
% \begin{dmath*}
% H_3^1 = x_1^3 - 2x_1 q_1 - x_2 q_1
% \end{dmath*}.
% \end{dgroup*}
% \end{xio}
%
%
%
%\section{Technical notes on tag placement}
%
%The method used by the breqn package to place the equation number is
%rather more complicated than you might think, and the whole reason is
%to allow the number to stay properly centered on the total height even
%when the height fluctuates due to stretching or shrinking of the page.
%
%
%Consider the following equation:
%\begin{dmath}[number={3.15}]
% N_{0} \simeq \left( \frac{\nu}{\lVert u\rVert_{H^{i}}} \right)
% \lvert I\rvert^{-1/2}
%\end{dmath}
%It will have only one line, if the column width is not too narrow.
%
%Scrutinizing the vertical list will shed light on some of the basic properties
%shared by all breqn equations. After that we will look at what would happen if
%two or more lines were needed. The numbers added on the left in the following
%\cs{showlists} output mark the points of interest.
%\begin{verbatim}
%[1] \penalty 10000
% \glue(\abovedisplayskip) 0.0
% \penalty 10000
% \glue(\belowdisplayskip) 0.0
%[2] \glue 4.0 plus 4.0
% \glue(\lineskip) 1.0
%[3] \vbox(16.53902+0.0)x0.0, glue set 16.53902fil
% .\glue 0.0 plus 1.0fil minus 1.0fil
% \penalty 10000
%[4] \glue -8.51945
%[5] \hbox(7.5+2.5)x25.55563
% .\OT1/cmr/m/n/10 (
% .\OT1/cmr/m/n/10 3
% .\OT1/cmr/m/n/10 .
% .\OT1/cmr/m/n/10 1
% .\OT1/cmr/m/n/10 5
% .\kern 0.0
% .\OT1/cmr/m/n/10 )
% \penalty 10000
%[6] \glue(\parskip) -18.01956
%[7] \hbox(16.53902+9.50012)x360.0, glue set 1.78647
%\end{verbatim}
%\begin{enumerate}
%\item These four lines are a hidden display structure from \TeX's
% primitive \texttt{\$\$} mechanism. It is used only to get the value
% of \cs{predisplaysize} so that we can later calculate by hand
% whether to use the short display skips or the regular ones. (The
% reason that we have to do it by hand traces back to the fact that
% \TeX\ 3.x does not allow unhboxing in math mode.) The penalties come
% from \cs{predisplaypenalty} and \cs{postdisplaypenalty}, which were
% locally set to 10000 to ensure there would be no unintended page
% breaks at these glue nodes.
%
%\item These two glue nodes are the ones that would normally have been
% produced at the top of a display; the first one is the above-display
% skip node (though we had to put it in by hand with \cs{vskip}) and
% the second one is the usual baselineskip/lineskip node.
%
%\item This is a dummy copy of the equation's first line, which is
% thrown in here to get the proper value of baselineskip (or lineskip
% in this case). Why do we need this? Because this ensures that we get
% the top spacing right before we fiddle with the glue nodes
% surrounding the equation number. And if the equation has a frame,
% this box is a good place to add it from.
%
%\item This is a special glue node that brings us to the right vertical
% position for adding the equation number. Its value is calculated
% from the variables that you would expect, given the presence of the
% dummy first line above the num- ber: starting position of the
% equation, height of first line, total height of equation body. If
% the equation body had more than one line, with stretchable glue
% between the lines, half of the stretch would be added in this glue
% node.
%
%\item The hbox containing the equation number.
%
%\item Backspace to bring the equation body to the right starting point. We use
% \cs{parskip} to put this glue in place because we're going to get a
% parskip node here in any case when we add the equation body with (in
% essence). If we didn't do this we'd get two glue nodes instead of
% one, to no purpose.
%
%\cs{\noindent} \cs{unhbox}\cs{EQ@box}.
%
%
%\item And lastly we see here the first line of the equation body,
% which appears to have height 16.5pt and depth 9.5pt.
%\end{enumerate}
%
%For comparison, the vertical list produced from the above equation in
%standard \LaTeX\ would look like this, if the same values of
%columnwidth and abovedisplayskip are used:
%\begin{verbatim}
%[1] \penalty 10000
%[2] \glue(\abovedisplayskip) 4.0 plus 4.0
% \glue(\lineskip) 1.0
% \hbox(16.53902+9.50012)x232.94844
%[3] .\hbox(7.5+2.5)x25.55563
% ..\hbox(7.5+2.5)x25.55563
% ...\OT1/cmr/m/n/10 (
% ...\OT1/cmr/m/n/10 3
% ...\OT1/cmr/m/n/10 .
% ...\OT1/cmr/m/n/10 1
% ...\OT1/cmr/m/n/10 5
% ...\kern 0.0
% ...\OT1/cmr/m/n/10 )
% .\kern101.49591
%[4] .\hbox(16.53902+9.50012)x105.8969
% ...
%[5] \penalty 0
%[6] \glue(\belowdisplayskip) 4.0 plus 4.0
% \glue(\lineskip) 1.0
% \hbox(6.94444+1.94444)x345.0, glue set 62.1106fil
%\end{verbatim}
%
%\begin{enumerate}
% \item \cs{predisplaypenalty}
% \item \cs{abovedisplayskip}
% \item equation number box
% \item equation body
% \item \cs{postdisplaypenaltly}
% \item \cs{belowdisplayskip}
%\end{enumerate}
%
%
% \section{Technical notes on Equation Layouts}
% \textbf{MJD [1998/12/28]}
%
% \providecommand{\qq}[1]{\textquotedblleft#1\textquotedblright}
% \providecommand{\mdash}{\textemdash}
% \providecommand{\ndash}{\textendash}
%
% \newcommand{\ititle}[1]{\textit{#1}}
%
% \newcommand{\LR}[2][.4]{%
% \framebox[#1\displaywidth]{$\displaystyle{}#2$}%
% }
%
% \newcommand{\LHS}[1]{\LR[\relifactor]{#1}}
%
% \newdimen\relindent \newdimen\rhswd
%
% \newcommand{\dwline}{%
% \hbox to\curdw{\vrule height1ex
% \leaders\hrule height.55ex depth-.45ex\hfil
% \tiny \space display width
% \leaders\hrule height.55ex depth-.45ex\hfil
% \vrule height1ex}%
% }
%
% \newenvironment{layout}[1][.15]{%
% \noindent
% $$\edef\curdw{\the\displaywidth}%
% \def\relifactor{#1}%
% \gdef\layoutcr{\cr}\def\\{\layoutcr}%
% \binoppenalty 10000 \relpenalty 10000
% \setbox8\vbox\bgroup
% \advance\baselineskip .35\baselineskip
% \advance\lineskip .35\baselineskip \lineskiplimit\lineskip
% \relindent=#1\displaywidth
% \rhswd=\displaywidth \advance\rhswd-\relindent
% \global\row 0 \gdef\rhsskew{}%
% \halign\bgroup \global\advance\row 1 $\hfil\displaystyle{}##$&%
% \ifnum\row>1 \rhsskew \fi $\displaystyle{}##\hfil$\cr
% }{%
% \crcr\egroup\egroup
% \vcenter{\halign{\hfil##\hfil\cr
% \hbox{\hss\dwline\hss}\cr\noalign{\vskip.6\baselineskip}\box8 \cr}}%
% $$\relax
% \ignorespacesafterend
% }
%
% \newcommand{\stagger}{\omit\span\gdef\layoutcr{\cr\omit\span}}
%
% \newcount\row
%
% \newcommand{\rhsskew}{}
% \newcommand{\skewleft}[1]{\gdef\rhsskew{\kern-#1\relax}}
%
%
% \subsection{Misc examples}
%
% Let us consider which of these have 50\% or more of wasted whitespace
% \emph{within the bounding box of the visible material}.
% \begin{layout}[.4]
% \LHS{L}&=\LR[.35]{R_{1}}\\
% &=\LR[.25]{R_{1}}
% \end{layout}
%
% \subsection{Ladder and step layouts}
%