Home

User's guide

image

Contents

1. generate file breqn sty from breqn dtx package trace 9 Environments and commands 9 1 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 dmath Like equation but supports line breaking and variant numbers dmath Unnumbered like displaymath but supports line breaking dseries Like equation but starts out in text mode intended for series of math ematical expressions of the form A B and C As a special feature if you use begin math end math 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 facilitat ing conversion of display math to inline math and vice versa If you write a display as begin dseries begin math A end math begin math B end math and begin math C end math end dseries then conversion to inline form is simply a matter of removing the begin dseries and end dseries lines the contents of the display need no alterations It would be nice to provide the same feature for notation but there is no easy way to do that because the function has no entry point to allow changing what happens before math mode is entered Making it work would therefore require turning into an active character something that I hesitate to do in a BTEX 2e context dseries Un
2. Note avoid M m P p because they look like they might be the start of a keyword minus or plus Then TX looks further to see if the next letter is i or 1 And if the next thing is an undefined macro the attempt to expand the macro results in an error message 177 def eqfontsize Inherit from context NOT USED 172 def eqcolor black Default to black NOT USED 179 newdimen eqnumsep eqnumsep 10pt Min space between equ number and body 180 newdimen eqmargin eqmargin 8pt For multline gap emulation 23 The eqindent and eqnumside variables need to have their values initialized from context actually But that takes a bit of work which is postponed till later 181 def eqindent C C or I centered or indented 182 def eqnumside R R or L right or left 183 def eqnumplace M M or T or B middle top or bottom Typesetting the equation number is done thus eqnumcolor eqnumsize eqnumfont eqnumform eq number 184 4d eqnumfont upshape Upright even when surrounding text is slanted 185 def eqnumfont Null for easier debugging mjd 1997 09 26 186 def eqnumform 1 1 italiccorr Add parens 187 def eqnumsize Allow numbers to have different typesize Tricky questions on eqnumsize Should the default be normalsize Then the user can scale down the equation body with small and not affect the equation number Or should the default be empty Then in large sections of
3. gt mathord left delimiter vrule Gright biggm vert gt mathrel left delimiter vrule Gright First save the primitive meanings of left and right 1627 saveprimitive left left ios Osaveprimitive right Q right The variable lr level is used by the first mathrel in an equation to tell whether it is at top level yes break and measure the LHS no keep going 1629 newcount lr level 79 It would be nice to have better error checking here if the argument is not a delimiter symbol at all Ah a small problem when renaming commands In the original version delimiter is hijacked in order to remove the after bidir or open or close instruction following the delimiter declaration 1630 ExplSyntax0n 1631 def eq left 132 ifnext eq nullleft begingroup let math_delimiter NNnNn eq left a 1633 134 def eq right 135 ifnext eq nullright begingroup let math_delimiter NNnNn eq right a 1636 The arguments are 1 delim symbol 2 1637 4 def eq left a 1 2 endgroup left delimiter 1 space after open 1638 def eq left at1 2 3 4 5 6 endgroup 1639 left math_delimiter NNnNn 1 2 3 4 5 after open 1640 def eq right a 1 2 3 4 5 6 endgroup 1641 right math_delimiter NNnNn 1 2 3 4 5 after close ss scan 1 2 3 4 5 3 1642 1543 ExplSyntaxO0ff The null versions 1644 def eq nullleft 1 left 1 after open ios def eq nullright 1 O righ
4. ifx found punct empty 74 else eqpunct found punct 795 fi 76 BRM Added the punctuation kept getting carried to following environs 77 xdef found punct empty 78 EQ afterspace 799 Needed for the dseries environment among other things s0 global let EQ afterspace empty The eq repack function looks at the information at hand and proceeds accord ingly TeX Note this scans BACKWARDS from the end of the math s1 def eq repack s22 A previous penalty of 3 on the vertical list means that we need 303 to break open a left right box 804 begin macrocode ss ifcase lastpenalty 806 case 0 normal case 807 setbox tw lastbox 808 eq repacka EQ copy eq repacka EQ box 809 unskip s0 or case 1 finished recursing Grab the mathon object since we need it to inhibit line breaking at bare glue nodes later 811 unpenalty dl eq repacka 812 setbox tw lastbox 813 eq repacka EQ copy eq repacka EQ box 814 xp gobble sis or case 2 save box width LHS width Don t need to set EQ hasLHS here because it was set earlier if applicable 816 unpenalty 817 setbox tw lastbox 818 setbox z copy tw setbox z hbox unhbox z unskip unpenalty 819 addtolength eq wdL wd z 820 setlength eq wdR wd EQ box BRM eq wdL patch 821 xdef EQ setwdL eq wdL the eq wdL relax At this point box 2 typically ends with mii0 a glue 2 77771 plus 2 77771 penalty 10001
5. mark primitives being the exceptions in providecommand saveprimitive 2 7 uz begingroup u3 edef tempa string 1 edef tempb meaning 1 7 ua ifx tempa tempb global let 2 17 115 else If arg1 is no longer primitive then we are in trouble unless arg2 was already given the desired primitive meaning somewhere else 116 edef tempb meaning 2 117 ifx tempa tempb 118 else saveprimitive a 1 2 119 fi 120 fi 121 endgroup 122 Aux function check for the special cases Most of the time this branch will be skipped so we can stuff a lot of work into it without worrying about speed costs 123 providecommand saveprimitive a 2 124 begingroup is def tempb 1 1 2 edef tempb 2 car 125 tempb nullfont select font nullfont 127 topmark string topmark 128 firstmark string firstmark 129 botmark string botmark 130 splitfirstmark string splitfirstmark 21 math endmath Q display enddisplay insert mark vadjust breqn debugmsg debugwr 131 splitbotmark string splitbotmark 132 1 string 1 133 nil for the car 134 edef Otempa expandafter strip prefix meaning tempb 135 edef tempb meaning 1 7 136 ifx tempa tempb global let 2 17 137 else 138 PackageError breqn 139 Unable to properly define string 2 primitive 140 noexpand ino longer primitive eha 141 fi 142 fi u3
6. 1146 def eq try layoute D 147 Set length dim a eq linewidth eq indentstep ius edef parshape parshape 2 1149 Opt the eq wdL space the eq indentstep space the dim a relax 1150 t ust def adjust rel penalty penalty 99 us2 eq trial b D eq try layout A 1153 Try a straight ladder layout Preliminary filtering ensures that eq wdL is less than 70 of the current line width Layout L Ladder layout LHS RHS RHS If fails try Drop ladder layout NOTE This is great for some cases multi rela tions but tends to break really badly when it fails usa def eq try layout L y uss setlength dim b eq linewidth eq wdL uss edef parshape parshape 2 Opt the eq linewidth space 1157 the eq wdL space the dim b relax 1158 t uso eq trial b L eq try layout D 1160 In the stepped layout there is no LHS or LHS is greater than the line width and RHS is small Then we want to split up the equation into lines of roughly equal width and stagger them downwards to the right leaving a small amount of whitespace on both sides But also if there is an equation number we want to try first a layout that leaves room for the number Otherwise it would nearly always be the case that the number would get thrown on a separate line Layout S Stepped layout typically no LHS or very long variations on STUFE ese MORE STUFF sai MORE STUFF If fails try Almost Columnar layout
7. EQ continue eq trial done 980 eq trial done Success o1 def eq trial done os2 trace breqn debugmsg End trial Success s3 let eq failout relax 984 eq trial init This is called from eq trial b to initialize or re initialize certain variables as needed when running one or more trials at a given line width By default assume success skip the fallback code os def eq trial init global let EQ fallback eq nextlayout eq nextlayout In the fallback case cancel the current group to avoid unnecessary group nesting with associated save stack cost etc ose def eq nextlayout 1 os7 endgroup oss trace breqn debugmsg Nope that ain t gonna work 99 begingroup 1 990 eq failout o1 def eq failout 2 trace breqn debugmsg End trial failout 7Z o3 global let EQ trial EQ last trial 994 eq trial save Save the parameters of the current trial os def eq trial save 1 s xtrace 97 begingroup def elt 1X 2 MessageBreak space space 1 2 let endelt empty breqn 998 hh breqn debugmsg gt bounding box the eq wdT x the eq vspan badness the eq badness 999 amp let elt relax let endelt relax 100 endgroup 1001 trace 1002 xdef 1 1003 eq linewidth the eq linewidth 1004 save info about the fit 1005 eq lines the eq lines eq badness the eq badness def nx eq badline eq badline 1006 save size info 1007 eq wdT the eq wdT
8. amp 2 endcsname 1 endgroup 8q_ fix xp let csname string amp q endcsname gobble mathchars reset Need to patch up this function from flexisym a little to better handle certain constructed symbols like neq o ExplSyntaxOn o7 g addto macro mathchars reset os amp let symRel secondoftwo let symBin secondoftwo o let symDeL secondoftwo let symDeR secondoftwo 20 eq cons saveprimitive 10 let symDeB secondoftwo 101 cs_set_eq NN math_csym_Rel Nn use_ii nn 102 cs_set_eq NN math_csym_Bin Nn use_ii nn 103 cs_set_eq NN math_csym_DeL Nn use_ii nn 104 cs_set_eq NN math_csym_DeR Nn use_ii nn 105 cs_set_eq NN math_csym_DeB Nn use_ii nn 106 107 ExplSyntaxOff BTE X s cons appends to the end of a list but we need a function that adds material at the beginning 108 def eq cons 1 2 19 begingroup let elt relax xdef 1 elt 2 1 endgroup 110 If some preceding package redefined one of the primitives that we must change we had better do some checking to make sure that we are able to save the primitive meaning for internal use This is handled by the saveprimitive function We follow the example of input where the primitive meaning is stored in an internal control sequence with a prefix Primitive control sequences can be distinguished by the fact that string and meaning return the same information Well not quite all nullfont and topmark and the other
9. eq measurements 939 MessageBreak 940 bounding box the eq wdT x the eq vspan badness the eq badness 941 MessageBreak 942 leftskip the leftskip rightskip the rightskip 7 s3 endgroup 944 os trace Layout Trials Driver Basically trying different sequences of parshapes Init 946 lLet EQ trial empty This is a token register used to carry trial info past a group boundary with only one global assignment oa newtoks EQ continue This is used for storing the actual line width info of the equation contents after breaking os lLet EQ widths empty 57 EQ fallback eq linewidths eq trial eq trial a o9 let EQ fallback empty This is the list of target widths for line breaking BRM Odd I don t think I ve seen this use anything but displaywidth o0 def eq linewidths displaywidth linewidth columnwidth The eq trial function tries each candidate line width in eq linewidths until an equation layout is found that yields satisfactory line breaks o51 def eq trial 92 ifx empty eq linewidths 953 global EQ continue 954 else 955 iffalse fi xp eq trial a eq linewidths 956 fi 97 the EQ continue 958 The eq trial a function reads the leading line width from eq linewidths if the new line width is greater than the previous one start running trials with it otherwise do nothing with it Finally run a peculiar edef that leaves eq linewidths
10. eq wdMin the eq wdMin 1008 eq vspan the eq vspan eq dp the eq dp eq firstht the eq firstht 59 eq trial b eq trial c eq trial d 1009 save info about the LHS 1010 eq wdL the eq wdL def nx EQ hasLHS EQCGhasLHS 1011 save info about the numbering 1012 def nx eq hasNumber eq hasNumber 7 1013 save info about the chosen layout 1014 def nx eq layout eq layout 1015 def nx eq parshape parshape 1016 def nx eq measurements eq measurements 1017 def nx adjust rel penalty adjust rel penalty 7 1018 def nx eq shiftnumber eq shiftnumber 1019 def nx eq isIntertext False 1020 1021 By default this just runs eq trial c cf eq trial d 1022 def eq trial b eq trial c Run the equation contents through the current parshape 1023 def eq trial c 1 2 1024 trace bregn debugmsg Trying layout 1 with MessageBreak 1025 begingroup 1026 60 eq trial init 1027 def eq layout 1 1028 setbox z vbox 1029 hfuzz maxdimen 1030 eq trial p run the given parshape 1031 if Not eq badline 7 1032 eq trial save EQOtrial parshape space xp gobble paz If there is a number try the same parshape again with adjustments to make room for the number This is an awkward place for this It only allows trying to fit the number w the SAME layout shape 1033 if eq hasNumber eq retry with number fi 1034 if L eq layout eq check density 1035
11. 41 define key breqn compact 99 prerelpenalty 1 relax begin dmath layout S Specify a particular layout We take care to ensure that eq layout ends up containing one and only one letter 42 define key breqn layout 7 7 43 edef eq layout car 1 O nil 404 begin dmath spread ipt To change the interline spacing in a particular equation 45 define key breqn spread 46 addtolength eqlinespacing 1 47 addtolength eqlineskip 1 as eqlineskiplimit eqlineskip 409 To change the amount of space on the side for multline layout ao define key breqn sidespace 7 ai setlength eq given sidespace 1 412 begin dmath style smal1 32 The style option is mainly intended for changing the type size of an equation but as a matter of fact you could put arbitrary TFX code here thus the option name is style rather than just typesize In order for this option to work when setting options globally we need to put the code in eqstyle rather than execute it directly 43 define key breqn style eqstyle xp the eqstyle 1 begin dmath shortskiplimit lem If the line immediately preceeding a display has length l the first line of the display is indented 7 and a shortskip limit s is set then the spacing above the display is equal to abovedisplayshortskip if l s lt i and abovedisplayskip otherwise The default shortskip limit is 2em which is what TFX
12. True fi i366 ifnum eq lines gt sixt n 1367 eq dense enough b 1368 else 1369 dim b z let elt eq delt eq measurements 1370 dim c eq density factor eq wdT multiply dim c eq lines 1371 trace breqn debugmsg Density check black the dim b eq density factor total the dim c 1372 ifdim dim b gt dim c true false true else false false false fi 1373 fi 1374 Args are space above indent width height depth badness 1375 def eq delt 1X 2 3x 4 50 6 endelt addtolength dim b 3 This is an approximate calculation used to keep from going over maxdimen if the number of lines in our trial break is large enough to make that a threat If l t n represent left side width total width and number of lines the formula is 70 1 t lt 4n 9n 1 or equivalently since rational arithmetic is awkward in T X b 1 t lt 4n 9n 10 1376 def eq dense enough b y 13377 int b eq wdT divide int b p 1378 dim b eq wdL divide dim b int b 1379 dim c eq lines p multiply dim c f ur 1380 int b eq lines multiply int b 9 advance int b 10 381 divide dim c int b 13822 trace breqn debugmsg Density check 1 t the dim b space lt the dim c space 4n 9n 10 1383 ifdim dim b lt dim c true true true else false true false fi 1384 eq parshape 1385 let eq parshape empty eq params The interline spacing and penalties in eq params are used during both prelimi nary line breaking
13. a scan marker It should get a non expandable definition It could be relax but let s try a chardef instead 1297 chardef endelt This is similar to a parshape spec but for each line we record more info space above indent width x height dp and badness 108 def eq measurements 1299 elt 4 5pt 5 0pt 66 0ptx6 8pt 2 4pt 27 Gendelt 1300 1301 Loop through the list of boxes to measure things like total height including in terline stretch etc We check the actual width of the current line against the natural width after removing rightskip in case the former is less than the latter because of shrinkage In that case we do not want to use the natural width for RHS max width because it might unnecessarily exceed the right margin 1302 def eq measure lines 1303 Llet eq ml continue eq measure lines no Settbox tw lastbox dim b wd tw find target width of line 1305 setbox z hbox to dim b unhbox tw0 check for overfull 1306 eq badness badness 1307 ifnum eq badness lt inf bad else let eq badline True fi i308 eq ml a eq ml continue 68 eq ml a eq ml vspace eq dense enough 1309 1310 1311 1312 1313 1314 def eq m1 a 7 setbox tw hbox unhbox z unskip find natural width trace ifnum eq badness lt inf bad else breqn debugmsg Overfull the wd tw gt the dim b fi trace Is actual width less than natural width 1315 1316 1
14. advance int a tw uss setlength dim b 2 eq indentstep uss setlength dim c eq linewidth dim b 187 edef parshape parshape 1188 replicate int a space the eq indentstep space the dim a 1189 space the dim b space the dim c relax 1190 us1 eq trial b 1 eq try layout A 1192 In the almost columnar layout which is the layout of last resort we let all lines run to the full width and leave the adjusting of the indents to later Layout A Almost Columnar layout Pretty much straight full width more of a last resort If fails give up 1193 def eq try layout A usa edef parshape parshape 1 Opt the eq linewidth relax uss 9 if EQ hasLHS def adjust rel penalty penalty 99 fi 1196 eq trial b A 1197 MH Should be moved to a section where all keys are set to defaults uss let eq shiftnumber False 65 eq retry with number a Number placement adjustments 119 def eq retry with number 1200 if eq shiftnumber 1291 trace breqn debugmsg Place number Shifted number requested 7 1202 else Condition and right numbers We re just going to have to shift 1203 ifdim eq wdCond gt z if R eqnumside 1204 trace breqn debugmsg Place number Condition w Right number gt Shift number 1205 let eq shiftnumber True 1206 fi fi Compute free space 1207 h dim b eqnumsep advance dim b wd EQ numbox 1208 dim b eq wdNum 1209 if L eqnumside 1210 ifdim totalle
15. applicable it is silently ignored rather than treated as an error begin dmath style smal1 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 ipt framesep 2pt begin dmath background red begin dmath color purple begin dmath breakdepth 0 Use the 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 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 style option in addition to the number option style refstepcounter fequation Use of the normal label command instead of the label option works I think most of the time untested labelprefix prepends its argument to the label only useful as a global option really and must be called before label Use the indentstep option to specify something other than the default amount for the indention of relation symbols The default is 8pt Use the compact option in compound equations to inhibit lin
16. by the maintainer If a particular environment needs to call a different end action the end com mand of the environment should be defined to gobble two args and then call a function like check punct or qed 654 def check punct or ged 1 65 xdef found punct Gempty BRM punctuation was being remembered past this eqn s6 WSPR err why isn t that just global let found punct empty 67 def finish end csname end 1 endcsname latex end 1 6s check punct 659 eqpunct User settable function for handling the punctuation at the end of an equation You could for example define it to just discard the punctuation so newcommand eqpunct 1 thinspace 1i set label set label just sets currentlabel but it takes the counter as an argument in the hope that PT X will some day provide an improved labeling system that includes type info on the labels 61 providecommand set label 2 protected edef currentlabel 2 eq topspace The action of eq topspace is complicated by the need to test whether the short eq botspace versions of the display skips should be used This can be done only after the final parshape and indent have been determined so the calls of this function are buried relatively deeply in the code by comparison to the calls of eq botspace This also allows us to optimize slightly by setting the above skip with parskip instead of vskip 1 is either noindent or vskip parskip BRM Hmm we nee
17. cmm m it 10 b penalty 888 glue 10 5553 rule x0 0 penalty 10000 glue 10 5553 glue medmuskip 2 22217 minus 1 66663 OT1 cmr m n 10 glue medmuskip 2 22217 minus 1 66663 hbox 14 9051 9 50012 x43 36298 hbox 0 39998 23 60025 x7 36115 shifted 14 10013 OMX cmex m n 5 hat hat R hbox 14 9051 6 85951 x11 21368 hbox 14 9051 6 85951 x11 21368 fraction contents elided penalty 5332 glue 10 5553 rule x0 0 penalty 10000 glue 10 5553 glue medmuskip 2 22217 minus 1 66663 OMS cmsy m n 10 hat hat glue medmuskip 2 22217 minus 1 66663 OML cmm m it 10 d hbox 0 39998 23 60025 x7 36115 shifted 14 10013 OMX cmex m n 5 hat hat S penalty 10000 glue rightskip 0 0 plus 10000 0 penalty 3 glue lineskip 1 0 Figure 2 Preliminary equation contents part 2 48 This is the remainder of the RHS after the post right split penalty 3 glue lineskip 1 0 hbox 7 5 2 5 x16383 99998 glue set 1 63239 penalty 888 glue 10 5553 rule x0 0 penalty 10000 glue 10 5553 glue medmuskip 2 22217 minus 1 66663 OT1 cmr m n 10 glue medmuskip 2 22217 minus 1 66663 OT1 cmr m n 10 OML cmm m it 10 e penalty 5332 glue 10 5553 rule x0 0 penalty 10000 glue 10 5553 glue medmuskip 2 22217 minus 1 66663 OMS cmsy m n 10 hat hat glue medmuskip 2 22217 mi
18. else 1036 if Not eq badline 1037 eq trial succeed 1038 fi 1039 fi 1040 else 1041 eq trial save EQ last trial 1042 fi 1043 t 10a EQ fallback 2 145 endgroup 1046 1047 def eq trial d 1 2 eq trial c 1 60 eq check density eq shortLHS eq trial p adjust rel penalty eq fix lastline 1048 def eq check density 149 trace breqn debugmsg Checking density for layout L 150 if Or Not EQ hasLHS eq shortLHS 1051 trace breqn debugmsg Density check No LHS or is short OK 1052 eq trial succeed 1053 else if eq dense enough 1054 eq trial succeed 1055 fi fi 1056 Test to see if we need to apply the eq dense enough test 1057 def eq shortLHS ifdim eq wdL gt 44 eq wdT 1 else O fi 0 def eq shortLHS False Run a trial with the current parshape and measure it ios def eq trial p 1059 parshape 100 0 eq dump box unhcopy EQ copy 1651 1 par leave parshape readable 1002 eq lines prevgraf 1063 eq fix lastline 10654 let eq badline False 165 if i eq layout ifnum eq lines gt ne let eq badline True fi fi 106 eq curline eq lines loop counter for eq measure lines 1067 let eq measurements empty 1068 eq ml record indents 109 eq measure lines 1070 eq recalc 1071 trace debug showmeasurements 1072 Normally this is a no op 1073 let adjust rel penalty empty Remove parfillskip from the l
19. empty 512 else Put the number in a box so we can use its measurements in our number placement calculations The extra braces around eqnumform make it possible for eqnumfont to have either an itshape recommended or a textit value sis trace breqn debugmsg Number eq number 7 514 set label equation eq number 515 global sbox EQ numbox 516 next label global let next label empty 37 eq finish 517 eqnumcolor eqnumsize eqnumf ont eqnumf orm eq number 518 519 global eq wdNum wd EQ numbox global advance eq wdNum eqnumsep 520 h let eq hasNumber True locally true 521 fi 522 fi 523 The information available at this point from preliminary measuring includes the number of lines required the width of the equation number the total height of the equation body and most important the parshape spec that was used in determining height and number of lines Invoke the equation formatter for the requested centering indentation having worked out the best parshape BRM This portion is extensively refactored to get common operations together so corrections get consistently applied MH I ve destroyed Bruce s nice refactoring a bit to get the abovedisplayskips correct for both groups of equations and single dmath environments I will have to redo that later 524 newcount eq final linecount 525 let eq GRP first dmath True 52 def eq finish 57 begingroup 523 trace breqn debugmsg Formatt
20. glue rightskip 0 0 plus 10000 0 and we want to ensure that the thickmuskip glue gets removed And we now arrange for EQ copy and EQ box to keep the LHS in a separate subbox this is so that we can introduce a different penalty before the first relation symbol if necessary depending on the layout decisions that are made later 822 global setbox EQ copy hbox 823 hbox unhcopy tw unskip unpenalty unskip 824 box EQ copy 825 t 826 global setbox EQ box hbox 7 827 hbox unhbox tw unskip unpenalty unskip 828 box EQ box 829 830 unskip 31 or case 3 unpack left right box 832 unpenalty 833 eq lrunpack sa else 835 breqn repack err 836 fi 37 eq repack RECURSE 838 Error message extracted to streamline calling function 339 def breqn repack err s0 PackageError breqn eq repack penalty neq 0 1 2 3 relax 841 We need to transfer each line into two separate boxes one containing everything and one that omits stuff like inserts that would interfere with measuring 842 def eq repacka 1 343 global setbox 1 hbox unhcopy tw unskip 52 eq nulldisplay 844 count lastpenalty 845 ifnum count lt M else advance count M fi 846 unpenalty If creating the measure copy ignore all cases above case 3 by folding them into case 1 847 ifx EQ copy 1 ifnum count gt thre count ne fi fi 848 ifcase count 849 case 0 normal line break 850 penalty M put ba
21. hardcodes but this parameter overrides that 44 define key breqn shortskiplimit def eq shortskiplimit 1 ais def eq shortskiplimit 2em begin dmath frame The frame option merely puts a framebox around the body of the equation To change the thickness of the frame give the thickness as the argument of the option For greater control you can change the appearance of the frame by redefining eqframe It must be a command taking two arguments the width and height of the equation body The top left corner of the box produced by eqframe will be pinned to the top left corner of the equation body ais define key breqn frame fboxrule def eq frame T a7 dim a 1 relax edef eq framewd the dim a Until such time as we provide a frame implementation that allows the frame to stretch and shrink we d better remove any stretch shrink from the interline glue in this case as freeze glue eqlinespacing freeze glue eqlineskip 419 40 define key breqn fullframe def eq frame U ai freeze glue eqlinespacing freeze glue eqlineskip 422 423 def eq frame F no frame 424 def eq framewd fboxrule Wishful thinking begin dmath frame width 2pt color blue sep 2pt To change the space between the frame and the equation there is a framesep option a define key breqn framesep fboxsep a6 if eq frame F def eq frame T fi a7 dim a 1 relax edef eq0framesep the dim a as freeze glue
22. let token xp check qed b 0 else xp finish end 641 fi 642 For each environment ENV that takes an implied qed at the end the control sequence ENVqed must be defined and it must include suitable code to yield the desired results in a displayed equation 643 def check qed b 1 2 644 ifundefined 2qed 7 6 w 645 toks xp found punct csname 2qed endcsname 646 xdef found punct the toks s7 og finish end 649 end 2 650 The lookahead for punctuation following a display requires mucking about with the normal operation of end Although this is not exactly something to be done lightly on the other hand this whole package is so over the top anyway what s a little more going to hurt And rationalizing this aspect of equation markup is a worthy cause Here is the usual definition of end def end if csname end 1i endcsname checkend 1 42 expandafter endgroup if endpe doendpe fi if ignore global ignorefalse ignorespaces fi We can improve the chances of this code surviving through future minor changes in the fundamental definition of end by taking a little care in saving the original meaning 651 def tempa 1 endcsname 2 nil def latex end 1 2 652 expandafter tempa end 1 nil 63 def end 1 csname end 1 endcsname latex end 1 Why don t we call CheckCommand here Because that doesn t help end users much it works better to use it during package testing
23. 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 6 3 Math symbol subversion In order for automatic line breaking to work the operation of all the math sym bols of class 2 3 4 and 5 must be altered relations binary operators opening delimiters closing delimiters This is done by an auxiliary package flexisym As long as you stick to the advertised TX interface for defining math symbols DeclareMathSymbo1 things should work OK most of the time Any more com plex math symbol setup is quite likely to quarrel with the flexisym package See Section 11 on page 10 for further information 6 4 Subscripts and superscripts Because of the changes to math symbols of class 2 5 writing certain combinations such as or _ pm or geq without braces would lead to error messages The problem described here already exists in standard ATEX to a lesser extent as you may know if you ever tried neq or cong and indeed there are no examples in the TeX book to indicate any sanction for omitting braces around a subscript or superscript The flexisym package therefore calls as of version 0 92 another package called mathstyle which turns and _ 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 nontr
24. means that two single line expressions in a dgroup can be closer together than intereqskip if the math expressions are vertically smaller than the tag 29 Centered Right Number Equations 1 might be unhbox or unhcopy 2 is the box name 1328 def eq dump box 1 2 1399 4 debug box 17 uo noindent 1 2 setbox f ur lastbox setbox tw lastbox If the LHS contains shrinkable glue in an L layout the alignment could be thrown off if the first line is shrunk noticeably For the time being disable shrinking on the left hand side The proper solution requires more work mjd 1999 03 17 uo if L eq layout box tw else unhbox tw fi 1402 adjust rel penalty unhbox f ur 1403 Various typesetting bits invoked from eq finish BRM This has been ex tensively refactored from the original breqn initially to get left right skips and parshape used consistently ultimately to get most things handled the same way in the same order Given that left and right skips have been set typeset the frame number and equation with the given number side and placement o4 def eq typeset QUnnumbered uo eq typeset frame os eq typeset equation 1407 vos def eq typeset LM y uoo Set length dim a eq vspan ht EQ numbox dp EQ numbox 2 iio eq typeset leftnumber uu eq t ypeset frame ui eq t ypeset equation 1413 Typeset equation and left top number and shifted u14 def eq typeset LT wis d
25. messing up summa tion limits in LHS But I may have fixed that problem by fixing other things os def mark lhs a 290 6 mskip thickmuskip vadjust penalty tw0 penalty Mi vadjust 300 If you want the LHS to extend past the first mathrel symbol to a following one mark the first one with hiderel a hiderel b c I m not sure now why I didn t use begingroup endgroup here mjd 1999 01 21 28 m Bin m Rel bin break rel break bin mark rel mark d Bin d Re1 m symRel d symRe1 m symBin d symBin m symDel d symDe1 m symDeR d symDeR m symDeB d symDeB m symDeA d symDeA display setup everydisplay 301 newcommand hiderel 1 mathrel advance l1r level ne 1 cf flexisym handling of mathbins and mathrels These are alternate definitions of m Bin and m Rel activated by display setup 302 303 304 305 306 307 308 309 310 311 316 317 318 hhhb let m Bin m Bin hhhhh let m Rel mGRel let EQ prebin space relax def EQ prebin space a mskip eq binoffset keep glue mskip eq binoffset def bin break ifnum lastpenalty z0 penalty prebinoppenalty fi EQ prebin space def rel break ifnum abs num lastpenalty lt abs num prerelpenalty penalty prerelpenalty fi Exp1SyntaxOn hhb def d Bin bin break m Bin hhhh def d GRel mark lhs rel break m Re1 cs_set Npn math_dsym_Bin Nn bin break math_b
26. of the parshape widths NOT in addition to it We also must trim the widths so that the sum of skips indents and widths add up to no more than the eq linewidth 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 def adjust parshape 1 7 Oxp adjust parshape a 1 relax edef 1 temp a 7 def adjust parshape a 1 2 relax setlength dim a leftskipt rightskip edef temp a 1 adjust parshape b 2 relax def adjust parshape b 1 2 ifx 1 edef temp a temp a relax xp gobble 67 eq ml record indents endelt eq measurements eq measure lines 1275 else 1276 dim b 1 relax 1277 dim c 2 relax 1278 addtolength dim c dim a dim b 1279 ifdim dim c gt eq linewidth setlength dim c eq linewidth fi 1280 addtolength dim c dim b 7 1281 edef temp a temp a space the dim b space the dim c 1282 fi 12833 adjust parshape b 1284 Plunk the parshape s indent values into an array for easy access when constructing eq measurements 1235 def eq ml record indents 1286 int a z 1237 def tempa 1288 advance int a ne 1289 xp edef csname eq i number int a endcsname the dim a 1290 ifnum int a lt int b afterassignment tempb fi 1291 dim a 1292 t 1233 6 def tempb afterassignment tempa dim a no def tempc 1 2 int b 2 afterassignment tempa dim a 125 xp tempc Cparshape 1296 This is
27. opening delimiter 1710 else 1711 eq binoffset eqbinoffset 1712 advance eq binoffset lr level eqdelimoffset plusifill relax 1713 def dt fill cancel hskip z minusifill relax 1714 fi 1715 penalty M BRM discourage break after an open fence 1716 inv def after close ims global advance 1r level m ne 1719 prebinoppenalty bop incr multiply prebinoppenalty lr level 1720 advance prebinoppenalty zero bop 121 ifnum eqbreakdepth lt lr level 1722 else cs_set_eq NN math_sym_Bin Nn math_dsym_Bin Nn 4444 4 let m Bin d Bin 1723 fi When we get back to level 0 no delimiters remove the stretch component of eqbinoffset 1724 ifnum lr level lt ne eq binoffset eqbinoffset relax fi 1725 82 subsup f lag ss scan 1726 1727 ExplSyntax0ff 1728 ss scan is called after a right delimiter and looks ahead for sub and superscript tokens If sub and or superscripts are present we adjust the line ending penalty to distinguish the various cases sub sup or both This facilitates the later work of excising the sub sup box and reattaching it with proper shifting Sub Superscript measurement BRM There s possibly a problem here When ss scan gets invoked after a left right pair in the LHS during eq measure it produces an extra box marked with penalty 3 Apparently eq repack expects only one for the LHS The end result is eq wdL 0 0pt or at least very small i729 let sub
28. setkeys breqn labelprefix eq 338 define key breqn label 339 edef next label noexpand label next label pre 1 30 Llet next label pre empty 301 define key breqn labelprefix def next label pre 1 322 global let next label empty 333 global let next label pre empty Allow a variant number begin dmath number nref foo textprime 304 def ine key breqn number def eq number 1 35 let currentlabel eq number 396 31 begin dmath shiftnumber begin dmath holdnumber Holding or shifting the number 37 define key breqn shiftnumber let eq shiftnumber True 303 define key breqn holdnumber let eq holdnumber True begin dmath density 5 39 def ine key breqn density def eq density factor 1 begin dmath indentstep 1lem To change the amount of indent for post initial lines Note for lines that be gin with a mathbin symbol there is a fixed amount of indent already built in eqbinoffset and it cannot be reduced through this option The indentstep amount is the indent used for lines that begin with a mathrel symbol 40 define key breqn indentstep eqindentstep 1 relax begin dmath compact begin dmath compact 2000 To make mathrels stay inline to the extent possible use the compact option Can give a numeric value in the range 10000 10000 to adjust the behavior 10000 always break at a rel symbol 10000 never break at a rel symbol
29. smaller text like the dangerous bend stuff in TRXbook the equation number size will keep in synch with the context Maybe need an eqbodysize param as well to allow separating the two cases iss def eqnumcolor 4 or color than eq body e g color blue 189 newlength eqlinespacing eqlinespacing 14pt plus2pt Base to base space between lines 199 newlength eqlineskip eqlineskip 3pt plus2pt Min space if eqlinespacing too small 191 newdimen eqlineskiplimit eqlineskiplimit 2pt Threshold for switching to eqlineskip The value of eqbinoffset should include a negative shrink component that cancels the shrink component of medmuskip otherwise there can be a noticeable variation in the indent of adjacent lines if one is shrunken a lot and the other isn t 192 newmuskip eqbinoffset eqbinoffset 15mu minus 3mu Offset from mathrel alignment pt for math 193 newmuskip eqdelimoffset eqdelimoffset 2mu Additional offset for break inside delims 194 newdimen eqindentstep eqindentstep 8pt Indent used when LHS wd is n a or too large 15 newtoks eqstyle Customization hook 195 newcount eqbreakdepth eqbreakdepth 2 Allow breaks within delimiters to this depth 197 newcount eqinterlinepenalty eqinterlinepenalty 10000 No page breaks between equation lines 198 newcount intereqpenalty intereqpenalty 1000 Pagebreak penalty between equations BRM Wa 199 newlength intereqskip intereqskip 3pt plus2pt Additional vert space b
30. trace 1120 eq try layout multi 1121 fi 1122 Layout Multiline layout If no LHS try Stepped S layout Else try Stepped S Ladder L Drop ladder D or Stepladder 1 depending on LHS length 1123 def eq try layout multi 1124 if EQC hasLHS 1125 ifdim eq wdL gt eq linewidth 126 trace breqn debugmsg Choose Shape LHS the eq wdL gt linewidth Find the total width of the RHS If it is relatively short a step layout is the thing to try 1127 setlength dim a wd EQ copy eq wdL 1128 ifdim dim a lt 25 eq linewidth eq try layout s 1129 else eq try layout l 1130 fi 1131 BRM Originally 7 Extreme for L since rhs has to wrap within the remaining 30 1132 else ifdim eq QwdL gt 50 eq linewidth 133 trace 1134 breqn debugmsg Choose Shape LHS the eq wdL gt 50 linewidth linewidth the eq linewi 1135 trace 1136 eq try layouteD 1137 else use trace breqn debugmsg Choose Shape LHS the eq wdL not extraordinarily wide 1139 eq try layoute L 1140 fi fi 1141 else 1142 trace breqn debugmsg Choose Shape No LHS here Try one line layout first then step layout 1143 eq try layout S already checked case i 1144 fi 1145 eq try layout D Change the penalty before the first mathrel symbol to encourage a break there Layout D Drop Ladder Layout for wide LHS LOOOOOOOONG LHS RHS 63 eq try layouteOL eq try layoute s If fails try Almost Columnar layout
31. way it skips over whitespace including newline while looking for the char which is not good for math material So we call optarg instead 49 newenvironment dmath 7 45 let eq hasNumber True optarg dmath a1 def dmath 1 452 trace breqn debugmsg DMATH 43 everydisplay expandafter the everydisplay display setup a4 if noskipsec leavevmode fi a5 if inlabel leavevmode global inlabelfalse fi 45 if eq group else eq prelim fi a7 setkeys breqn 1 as the eqstyle The equation number might have been overridden in 1 a59 eq setnumber Start up the displayed equation by reading the contents into a box register Enclose this phase in an extra group so that modified hsize and other params will be auto restored afterwards 35 dmath enddmath eq prelim 40 begingroup 41 eq setup a 42 eq startup 463 Before it finishes off the box holding the equation body enddmath needs to look ahead for punctuation and qed aoa def enddmath 1 check punct or qed 465 def end dmath aco 6 gdef EQ setwdL Occasionally undefined a7 eq capture 468 endgroup 409 EQ setwdL Measure a copy of the equation body to find the minimum width required to get acceptable line breaks how many lines will be required at that width and whether the equation number needs to be shifted to avoid overlapping This informatio
32. 1161 def eq try layoute st y 162 setlength dim b eq linewidth 2 eqmargin advance dim b 1em About how many lines will we need if dim b is the line width ues int a wd EQ copy divide int a dim b Adjust the target width by number of lines times indentstep We don t need to decrement int a because TEX division is integer division with truncation 164 addtolength dim b int a eq indentstep 64 eq try layout 1 eq try layout A eq shiftnumber Adjust for equation number But try not to leave too little room for the equation body uss if eq hasNumber 1166 ifdim dim b gt 15em 1167 advance dim b eqnumsep advance dim b wd EQ numbox 1168 addtolength dim b eq wdNum 1169 fi 1170 fi Now some hand waving to set up the parshape 1171 int b z 172 def tempa dim 173 edef parshape parshape 2 Opt the dim b space 1174 the eqmargin space the dim b relax uz eq trial b S eq try layoutG A 1176 This is the step ladder layout similar to the drop ladder layout but the LHS is too wide and needs to be broken up Layout 1 Stepladder Similar to Drop Ladder but LHS is long and needs to be broken up If fails try Almost Columnar layout 177 def eq try layout l y uve setlength dim a eq linewidth eq indentstep 177 int a eq wdL divide int a dim a uso advance int a tw 181 edef parshape parshape number int a space 1182 Opt the eq linewidth 1183 t use
33. 1845 newenvironment dseries let eq hasNumber True optarg dseries 1847 def enddseries 1 check punct or qed And the unnumbered version of same 1848 newenvironment dseries let eq hasNumber False optarg dseries 1849 namedef enddseries 1 check punct or qed isso Qnamedef end dseries end dseries 1851 def dseries 1 Turn off the special breaking behavior of mathrels etc for math formulas embed ded in a dseries environment BRM DS Expermient Use alternative display setup 1852 4 def display setup displaystyle 1853 let display setup dseries display setup 1854 Question should this be the default for dseries 1855 4 let eq centerlines True 156 global eq wdCond z BRM use special layout for dseries 1857 dmath 11 1858 dmath layout M 1 1859 mathsurround z math penalty Mi 1860 let endmath ends math 1861 def premath BRM Tricky to cleanup space OR add space ONLY BETWEEN math 1862 ifdim lastskip lt 3em unskip 87 1863 else ifnum lastpenalty lt M dquad fi fi 1864 IgA BRM Tricky if a subformula breaks we d like to start the next on new line 1865 def postmath unpenalty eq addpunct penalty intermath penalty dquad ignoretrue 1866 ignorespaces 1867 1868 def end dseries 1869 unskip unpenalty 1870 endmath mathsurround z end dmath 1871 BRM Try this layout for dseries Essentially layout i but w o l
34. 19833 if grp aligned 1984 ifdim dim a gt grp linewidth 1985 global let grp aligned False 1986 fi 1987 fi If we re adding an unshifted group number that equations didn t know about re check shifting 1988 add tolength dim a grp wdNum Effective length 1989 if grp shiftnumber 1990 else 1991 if And grp hasNumber Not grp eqs numbered 1992 ifdim dim a gt grp linewidth 1993 global let grp shiftnumber True 1994 fi 1995 fi 1996 fi If we can still align total width is sum of maximum LHS amp RHS 1997 if grp aligned 1998 global grp wdT grp wdL 1999 global advance grp wdT grp wdR 2000 fi 2001 xtrace 202 breqn debugmsg DGROUP Formatting 2003 MessageBreak grp wdL the grp wdL grp wdR the grp wdR 2004 MessageBreak Shift Number theb le grp shiftnumber Eqns numbered theb le grp eqs n 2005 MessageBreak Aligned theb le grp aligned 2006 MessageBreak grp wdNum the grp wdNum 2007 trace BRM Originally this stuff was dumped directly without capturing it in a vbox 2008 setbox GRP wholebox vbox 2009 let elt eqgrp elt 2010 the GRP queue 2011 If we re placing a group number not individual eqn numbers NOTE For now just code up LM number NOTE Come back and handle other cases NOTE Vertical spacing is off perhaps because of inter eqn glue A bit of a hack to get the top spacing correct Fix this logic properly some day
35. 20 6306 twang adjust sub depth 1821 lower sub depth box tw 1822 For delimiters that curve top and bottom the twang factor allows horizontal shifting of the sub and superscripts so they don t fall too far away or too close for that matter This is accomplished by arranging for e g right rangle to leave a penalty N in the math list before the subsup penalty that triggers lrss reattach where N is the mathcode of rangle ignoring small variant 1823 def twang adjust 1 isa 6 beg ingroup 1825 ifundefined twang right delim code 1826 setlength dim d 1 mathaxis 1827 put an upper limit on the adjustment 1828 ifdim dim d gt 1lem dim d 1em fi 1829 kern csname twang right delim code endcsname dimGd 1830 t 1831 endgroup 1832 The method used to apply a twang adjustment is just an approximate solution to a complicated problem We make the following assumptions that hold true approximately for the most common kinds of delimiters 1 The right delimiter is symmetrical top to bottom 2 There is an upper limit on the size of the adjustment 3 When we have a superscript the amount of left skew that we want to apply is linearly proportional to the distance of the bottom left corner of the su perscript from the math axis with the ratio depending on the shape of the delimiter symbol By symmetry Assumption 3 is true also for subscripts upper left corner Assumption 2 is more obv
36. 317 1318 ifdim dim b lt wd tw setlength dim a dim b shrunken line else setlength dim a wd two OK to use natural width fi addtolength dim a leftskip BRM Deduct the skip if we re retrying w number If there s no aboveskip assume we ve reached the top of the equation 1319 1320 1321 1322 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 skip a lastskip unskip unpenalty ifdim skip a z let eq m1l continue relax end the recursion else Sum repeated vskips if present def tempa y ifdim lastskip z else addtolength skip a lastskip unskip unpenalty xp tempa fi Yh fi edef eq measurements elt the skip a space X extra space to facilitate extracting only the dimen part later csname eq i ifnum eq curline lt parshape number eq curline else number parshape fi endcsname the dim a x the ht tw the dp tw the eq badness endelt eq measurements F advance eq curline m ne ifnum eq curline z let eq ml continue relax fi Handle an embedded vspace 1343 1344 1345 1346 1347 1348 def eq ml vspace global advance eq vspan lastskip unskip unpenalty ifdim lastskip z else xp eq ml vspace fi def eq dense enough 7 ifnum eq lines lt thr 69 true true true true false true false true false false false false eq density factor
37. 6 36 breqn parshape warning eq prevshape eq saveparinfo eq setnumber Warning message extracted to a separate function to streamline the calling func tion 487 def breqn parshape warning 488 PackageWarning breqn 489 Complex paragraph shape cannot be followed by this equation 490 Storage see eq saveparinfo 41 lLet eq prevshape empty Save the number of lines and parshape info for the text preceding the equation 492 def eq saveparinfofy 43 count prevgraf advance count thre for the null display soa edef eq prevshape prevgraf the count space as ifcase parshape 496 case 0 no action required 47 or edef eq prevshape eq prevshape 498 parshape ne displayindent displaywidth relax 499 Maybe best to set eq prevshape the same in the else case also Better than nothing 500 else 501 breqn parshape warning 502 fi 503 If the current equation number is not explicitly given then use an auto generated number unless the no number switch has been thrown dmath theequation is the number form to be used for all equations eq number is the actual value for the current equation might be an exception to the usual sequence soa def eq setnumber so eq wdNum z so if eq hasNumber 507 ifx eq number empty 508 stepcounter equation let eq number theequation 509 fi sio h f i This sets up numbox etc even if unnumbered 511 ifx eq number
38. 7 AeA Ww oe Oa ND OH 10 11 12 13 14 15 16 17 18 To do Alignment for equation groups Use dpc s code for package options in keyval form Encapsulate break math into a subroutine taking suitable arguments Need a density check for layout S when linewidth is very small Make trigger a warning about using coloneq instead Ill centered multiline equation three line case in test008 Attaching a single group number Make sure to dump out box registers after done using them Do the implementation for eq resume parshape Check on stackrel and buildrel and relbar and Test math symbols at the beginning of array cells Test md in and out of delims Framing the equation body the parshape and number placement need ad justing when a frame is present Cascading line widths in list env Noalign option for dmath multline arrangement Nocompact option suggested 1998 05 19 by Andrew Swann delbreak cmd to add discretionary space at a break within delimiters Reduce above below skip when the number is shifted 100 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Need a middelim command for marking a delimiter symbol as nondirec tional if it has an innate directionality etc xrightarrow from amsmath won t participate in line breaking unless some thing extra is done Make BreakingRel and BreakingBin
39. 70 predisplaypenalty M postdisplaypenalty M 831 abovedisplayskip z skip abovedisplayshortskip z skip 32 belowdisplayskip z skip belowdisplayshortskip z skip 8373 xdef EQ displayinfo 874 prevgraf the prevgraf predisplaysize the predisplaysize 875 displaywidth the displaywidth displayindent the displayindent 876 listwidth the linewidth 53 eq newline eq newlinea eq newlineb eq revspace eq revspaceb Not sure how best to test whether leftmargin should be added Let s do this for now mjd 1997 10 08 877 ifdim displayindent gt z 878 advance listwidth the leftmargin 879 advance listwidth the rightmargin 880 fi 881 relax An halign containing only one cr for the preamble puts no box on the vertical list which means that no baselineskip will be added so we didn t need to set it to zero and the previous value of prevdepth carries through Those properties do not hold for an empty simple equation without halign s2 halign cr 883 enddisplay sea par sss endgroup s86 EQ displayinfo 887 Here we use ifnext so that in a sequence like seen a b BTEX does not attempt to interpret the a b as a vertical space amount We would have used eq break in the definition of eq newlineb except that it puts in a keep glue object which is not such a good idea if a mathbin symbol follows the indent of the mathbin will be wrong because the leading negative glue will not di
40. 87 kern dim a 1588 1589 def eq typesetOrightnumber 7 90 30 Set length skip c dim a ht EQ numbox 1590 vglue skip c NON discardable 15922 hbox to hsize hfil copy EQ numbox penalty M 1593 kern dim a 1594 1595 def eq typeset equation 1596 nobreak 15977 eq params eq parshape iss nointerlineskip noindent 159 add grp label 16500 eq dump box unhbox EQ box par 1601 30 Framing an equation The eqframe function is called in vertical mode with the reference point at the top left corner of the equation including any allowance for fboxsep Its arguments are the width and height of the equation body plus fboxsep 1602 newcommand eqframe 2 1503 begingroup 16504 30 f bo xrule eq framewd relax fboxsep eq framesep relax 1605 6360s framebox z rule height 2 kern 1 1605 endgroup 1607 The frame is not typeset at the correct horizontal position Will fix later 1608 def eq addframe 1609 hbox to z 1610 setlength dim a eq0framesep eq framewd 1611 kern dim a 1612 vbox to z kern dim a 1613 hbox eqframe eq wdT eq vspan 1614 vss 1615 1616 hss 1617 t 1618 1619 def eq typeset frame 1620 if F eq frame else 1621 Tricky put before noindent so it s not affected by glue in leftskip 1622 nobreak nointerlineskip 78 1623 vbox to eq firstht moveright leftskip hbox to z eq addframe hss vss 1624 kern eq
41. Also we do the calculation in a group for maximum safety 2012 global let eq GRP first dmath True 2013 begingroup 214 dmath first leftskip 215 eq topspace vskip parskip 216 endgroup 217 S if And grp hasNumber Not grp eqs numbered 2018 eq topspace vskip parskip 2019 if grp shiftnumber 93 eqgrp elt 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 copy GRP numbox penalty oM kern egqlineskip else setlength dim a ht GRP wholebox dp GRP wholebox ht GRP numbox dp GRP numbox 2 setlength skip c dim a ht GRP numbox vglue skip c NON discardable copy GRP numbox penalty OM trace breqn debugmsg GROUP NUMBER preskip the skip c postkern the dim a height the ht GRP who MessageBreak box height the ht GRP numbox box depth the dp GRP numbox trace kern dim a kern abovedisplayskip To cancel the topspace above the first eqn fi fi trace 4 debug box GRP wholebox trace unvbox GRP wholebox let elt relax We d need to handle shifted right number here too 2041 2042 eq botspace not needed unless bottom number Mission is to typeset the next equation from the group queue 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 The arg is an EQ trial def eqgrp e
42. Gtempa fi 33 Add the next option and recurse if there remain more options 34 def options b 1 2 3 Onil 35 options c 1 nil 30 ifx 2 empty else options b 2 3 nil fi sf Discard everything after the first space 33 def options c 1 2 nil options d 1 nil N Discard everything after the first sign add a comma only if the remainder is not empty 33 def options d 1 2 nil ifx Gempty 1 empty else fi 1 The tail of the ifundefined test ao end ifundefined test 19 Some useful tools The comparative brevity of nx and xp is valuable not so much for typing convenience as for reducing visual clutter in code sections that require a lot of expansion control 17 emptytoks f ur inf bad maxint int a int b int b dim a dim b dim c dim d dim e dim A skip a skip b skip c toks a toks b toks c toks d toks e toks f abs num ifnext ifnexta a let nx noexpand a2 let xp expandafter Constant empty token register analogous to empty 4 ifundefined Gemptytoks newtoks emptytoks Constants 0 3 are provided in plain TeX but not 4 44 chardef f ur 4 inf bad is for testing box badness 45 newcount inf bad inf bad 1000000 We want to use maxint rather than coerced maxdimen for linepenalty in one place 4 newcount maxint maxint 2147483647 Provide some shorter aliases for various scratch registers a7 let int a te
43. Q copy For eq body sans vadjust insert mark material 21 newsavebox EQ numbox For equation number 22 newdimen eq wdNum width of number separation NEW 213 newsavebox GRP numbox For group number NEW 214 newdimen grp wdNum width of number separation NEW 215 4 B EQ Qvimbox Vadjust insert or mark material 216 AhB EQ vimcopy Spare copy of same 217 AAB eq impinging Temporary box for measuring number placement 218 newcount eq lines Internal counter actual number of lines 219 newcount eq curline Loop counter 20 newcount eq badness Used in testing for overfull lines 21 newcount EQ vims For bookkeeping 22 def eq numbertrue let eqGhasNumber True 223 def eq numberfalse let eq hasNumber False 224 let eq hasNumber False Here for the dimens it would be advisable to do some more careful management to conserve dimen registers First of all most of the dimen registers are needed in the measuring phase which is a tightly contained step that happens after the contents of the equation have been typeset into a box and before any external functions have a chance to regain control e g the output routine Therefore it is possible to make use of the the dimen registers 0 9 reserved by convention for scratch use without fear of conflict with other macros But I don t want to use them directly with the available names dimen dimen i dimen ii dimen3 dimen4 dimen9 It would be mu
44. Q prebin space EQ prebin space a 293 mark lhs a But the penalty for the first mathrel should still be lower than a binoppenalty If not when the LHS contains a binop the split will occur inside the LHS rather than at the mathrel On the other hand if we end up with a multline sort of equation layout where the RHS is very short the break before the relation symbol should be made less desirable than the breakpoints inside the LHS Since a lower penalty takes precedence over a higher one we start by putting in the highest relpenalty during subsequent measuring if we find that that RHS is not excessively short then we put in an extra normal relpenalty when rejoining the LHS and RHS 294 penalty9999 instead of normal rel break 25 else no penalty forbid break 296 fi 297 Temporarily add an extra thickmuskip to the LHS it will be removed later This is necessary to compensate for the disappearance of the thickmuskip glue preceding a mathrel if a line break is taken at that point Otherwise we would have to make our definition of mathrel symbols more complicated like the one for mathbins The penalty of 2 put in with vadjust is a flag for eq repack to suggest that the box containing this line should be measured to find the value of eq wdL The second vadjust ensures that the normal prerelpenalty and thickmuskip will not get lost at the line break during this preliminary pass BRM I originally thought the mskip thickmuskip was
45. The breqn package The breqn maintainers mh ctan gmail com 2012 05 10 v0 98b Abstract The breqn package facilitates automatic line breaking of displayed math expressions User s guide 1 A bit of history Originally breqn flexisym and 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 Hggholm to as sume maintainership of this part of his work and he wish to express my gratitude to them and to Barbara Beeton in particular for providing me with the files he needed MH hope to continue Michael s work thereby allowing users to create more masterpteces of the publishing art as I think he would have wanted Following the July 2008 breqn release breqn was left in the hands of a main tenance team while MH moved on with other projects 2 Package loading The recommended way of loading the breqn package is to load it after other pack ages dealing with math i e after amsmath amssymb or packages such as math pazo or mathptmx The flexisym package described in section 11 on page 10 is required by breqn and ensures the math symbols are set up correctly By default breqn loads it with support for Computer Modern but if you use a different math package requiring The maintainers would like to
46. ach line for centerlines setlength dim e eq wdT eq wdMin dim d z NOTE Need some work here centering when there s a condition 1518 VA 1519 A 1520 h 1521 1522 1523 1524 1525 1526 1527 1528 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 advance dim e eq wdT multiply dim e 1 relax if eq wdMin lt dim e dim e eq wdMin fi multiply dim e 1 relax advance dim e eq wdT dim d z if eq centerlines divide dim e2 relax dim d dim e fi setlength leftskip dim a plus dim d addtolength dim e dim c setlength rightskip z plus dim e Ominus5 p Special case if framing reduce the stretchiness of the formula eg condition Or if we have a right number FORCE space for it dim b z if F eq frame else dim b dim c fi if And eq hasNumber Not eq shiftnumber if R eqnumside dim c eq wdNum ifdim dim c gt dim b dim b dim c fi fi fi If either of those cases requires hard rightskip move that part from glue ifdim dim b gt z addtolength dim e dim c 7 rightskip dim b plus dim e Ominus5 p fi And peculiar further special case in indented environs width isn t where it would seem ifdim eq wdCond gt z 76 1550 addtolength rightskip totalleftmargin 1551 fi 1552 parfillskip z skip 1553 Set the left and right side spacing for indented equations Some things handled by eq C Qsetsides t
47. ack 2139 unpenalty 240 setbox tw lastbox 2141 4 batchmode showboxbreadth maxdimen showboxdepth99 showbox tw errorstopmode 242 global setbox EQ box hbox 2143 hbox unhcopy tw unskip penalty M unhbox EQ box 244 global setbox EQ copy hbox 2145 hbox unhbox tw unskip penalty M unhbox EQ copy 246 unskip 247 ifcase lastpenalty else xp gobble fi 24s dar repack 2149 97 condition condition a 35 Miscellaneous The condition command With the star form set the argument in math mode instead of text mode In a series of conditions use less space between members of the series than between the conditions and the main equation body WSPR tidied fixed things up as it made sense to me but might have broken something else 2150 newskip conditionsep conditionsep 10pt minus5pt 2151 newcommand conditionpunct 2152 newcommand condition 2153 begingroup tempswatrue 2154 ifstar tempswafalse condition a condition a 2155 newcommand condition a 2 conditionpunct 2156 unpenalty unskip unpenalty unskip BRM Added 2157 hbox 1 258 penalty 201 relax hbox Penalty to allow breaks here 2159 hskip conditionsep 2160 setbox z if tempswa hbox 2 else hbox textmath setup 2 fi BRM s layout is achieved with this line commented out but it has the nasty side effect of shifting the equation number to the next line 2161 A global eq wdCond wd z 2162 use
48. ains the left right box This is just a repeat of the algorithm in tex web with some modest simplifications from knowing that this is only going to be called at top level in a displayed equation thus always mathstyle uncramped displaystyle 1788 def lrss reattach 7 i709 begingroup 170 The TeXbook Appendix G step 18 1791 setlength prelim sup base ht z sup drop 172 setlength prelim sub depth dp z sub drop 1793 unhbox z 17x4 ifcase subsup flag case 0 this can t happen ins or lr subscript case 1 subscript only 1726 or lr superscript case 2 superscript only 177 else 1r subsup case 3 sub and superscript both 1798 fi i799 endgroup 1800 1801 def lr subscript 1802 sub depth sub base one 1803 ifdim prelim sub depth gt sub depth sub depth prelim sub depth fi 1804 setlength dim a ht tw 8 sym xheight 185 ifdim dim a gt sub depth sub depth dim a fi 1805 twang adjust sub depth 1807 lower sub depth box tw 1808 1809 def lr superscript 1810 Sup base sup base one 1811 ifdim prelim sup base gt sup base sup base prelim sup base fi 1812 setlength dim a dp tw 25 sym xheight 1813 ifdim dim a gt sup base sup base dim a fi 1814 twang adjust sup base isis raise sup base box tw 1816 18317 def 1r subsup isis Sub depth sub base two 85 1819 ifdim prelim sub depth gt sub depth sub depth prelim sub depth fi 18
49. akdepth eqbreakdepth 1 relax begin darray cols lcricr The cols option only makes sense for the darray environment but we liberally allow all the options to be used with all the environments and just ignore any unsensible ones that happen to come along ao def ine key breqn cols global let preamble empty 47 darray mkpream 1 percentchar aaa FORMAT STATUS 34 dmath enddmath def eq frame T CLM works tolerably def eqindent C def eqnumside L def eqnumplace M CLT works tolerably def eqindent C def eqnumside L def eqnumplace T ILM def eqindent I def eqnumside L def eqnumplace M mathindent40 po ILT def eqindent I def eqnumside L def eqnumplace T mathindent40 p Indended w left number work ok if mathindent is larger than number width but then equations must fit into smaller space Is shiftnumber allowed to put eqn at left instead of indent CRM def eqindent C def eqnumside R def eqnumplace M CRB def eqindent C def eqnumside R def eqnumplace B IRM def eqindent I def eqnumside R def eqnumplace M mathindent10 p IRB def eqindent I def eqnumside R def eqnumplace B mathindent10 p The main environments BRM The following incorporates several changes 1 modifications supplied by MJD to fix the eaten paragraph problem 2 Added display setup here rather than globally For the dmath environment we don t want the standard optional arg processing because of the
50. and final typesetting 1386 def eq params 13837 baselineskip eqlinespacing 1388 lineskip eqlineskip lineskiplimit eqlineskiplimit Forbid absolutely a pagebreak that separates the first line or last line of a multiline equation from the rest of it Or in other words no equation of three lines or less will be broken at the bottom of a page instead it will be moved whole to the top of the next page If you really really need a page break that splits the first or last line from the rest of the equation you can always fall back to pagebreak I suppose 1389 clubpenalty M widowpenalty M interlinepenalty eqinterlinepenalty 139 linepenalty199 exhyphenpenalty5000 was 9999 make breaks at eg a bit easier For equations hfuzz should be at least 1pt But we have to fake it a little because we are running the equation through T X s paragrapher In our trials we use minus 1pt in the rightskip rather than hfuzz and we must do the same during final breaking of the equation otherwise in borderline cases TFX will use two lines instead of one when our trial indicated that one line would be enough i301 ifdim hfuzz lt p hfuzz p fi i302 4 hfuzz 2pt i393 ifdim hfuzz lt 2pt relax hfuzz2pt fi i304 parfillskip z skip 13395 hfuzz z Make sure we skip T X s preliminary line breaking pass to save processing time i396 tolerance9999 pretolerance m ne 1397 71 28 Equation layout options Using the not
51. and twiddle a bit with the widths of the first and last cell in each row we can use the same algorithms for centering and equation number placement as dmath As well as handling footnotes and vadjust objects the same way We can t just use arraycolsep for darray if we want to be able to change it without screwing up interior arrays So let s make a new colsep variable The initial value is 2em but let it shrink if necessary 204 newskip darraycolsep darraycolsep 20pt plusifil minus12pt Let s make a nice big default setup with eighteen columns split up into six sets of lcr like eqnarray 285 newcount cur row newcount cur col 2086 def Ctempa t1 2 3 2087 cur col 1 hfil 288 setbox z hbox displaystyle m0th nx col box 289 tabskip z skip 290 amp cur col 2 hfil 291 setbox z hbox displaystyle mathord mathord m th nx col box 2092 hfil 20993 amp cur col 3 setbox z hbox displaystyle m th nx col box 204 hfil tabskip darraycolsep 2095 29 xdef darray preamble 2097 tempa 123 amp tempa 456 amp tempa 789 2008 amp tempa 10 11 12 amp tempa 13 14 15 amp tempa 16 17 18 2099 cr 2100 2101 ifundefined Mathstrut let Mathstrut strut 2102 def darray cr Mathstrut cr 2103 def col box 2104 xtrace 2105 breqn debugmsg Col number cur row number cur col the wd z space x the ht z the dp z 2106 trace 2107 unhbox
52. ast line box 1074 def eq fix lastline 1075 setbox tw lastbox dim b wd tw 1076 eq dp dp tw Remove parfillskip but retain rightskip Need to keep the original line width for later shrink testing 1077 nointerlineskip hbox to dim b unhbox tw 1078 skip c lastskip unskip unskip hskip skip c 1079 t 1080 61 eq recalc eq recalc a eq recalc b eq layout eq try layoute Calculate eq wdT et cetera 181 def eq recalc 1082 eq wdT z eq wdMin maxdimen eq vspan z skip eq badness z 1083 let elt eq recalc a eq measurements let elt relax 1084 1085 def eq recalc a 1x 2 3 endelt 186 eq firstht 2 relax 1087 let elt eq recalc b 1088 e 1t 1x 2 3 endelt 1089 1090 def eq recalc b 1X 2 3x 4 50 6 endelt 191 Set length dim a 2 3 1092 0 ifdim dim a gt eq wdT eq wdT dim a fi 1093 ifdim dim a lt eq wdMin eq wdMin dim a fi 104 eq dp 5 relax 1095 addtolength eq vspan 1 4 eq dp Record the max badness of all the lines in eq badness 1096 ifnum 6 gt eq badness eq badness 6 relax fi 1097 A value of for eq layout means that we should deduce which layout to use by looking at the size of the components Any other value means we have a user specified override on the layout Layout Definitions Based on initial equation measurements we can choose a sequence of candidate parshapes that the equation might fit into We a
53. ation C centered I indented applied to the equation body T top B bottom M middle L left R right applied to the equation number the commonly used equation types are C CRM CRB CLM CLT I IRM IRB ILM ILT In other words CLM stands for Centered equation body with Left hand Middle placed equation number and IRB stands for Indented equation with Right hand Bottom placed equation number Here are some general thoughts on how to place an equation tag Currently it does not work as desired the L option positions the tag app 10 lines below the math expression the RM doesn t position the tag on the baseline for single line math expressions Therefore I am going to first write what I think is supposed to happen and then implement it Below is a small list where especially the two three specifications should be quite obvious I just don t want to forget anything and it is important to the implementation Definition 1 If a display consists of exactly one line the tag should always be placed on the same baseline as the math expression The remaining comments refer to multi line displays Definition 2 If a tag is to be positioned at the top T it should be placed such that the baseline of the tag aligns with the baseline of the top line of the display Definition 3 If a tag is to be positioned at the bottom B it should be placed such that the baseline of the tag aligns with the baseline of the bottom line of the display D
54. ber aren t right group frame Framing a group doesn t work you might be able to get frames on the individual equations at best group brace The brace option for dgroup is intended to produce a large brace encompassing the whole group This hasn t been implemented yet darray environment The darray environment is unfinished dseries environment The syntax and usage for the dseries environment are in doubt and may change failure arrangements When none of the line breaking passes for a dmath envi ronment succeeds i e at least one line is overfull the final arrangement is usually rather poor A better fall back arrangement in the failure case is needed 8 Package options Many of the package options for the breqn package are the same as options of the dmath or 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 breqn package options are designed to be set with a setkeys command after the package is loaded For example to load the package and set the maximum delimiter nesting depth for line breaks to 1 usepackage breqn setkeys breqn breakdepth 1 See the discussion of environment options Section 10 on page 9 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
55. box z 2163 endgroup The dsuspend environment First the old one that didn t work 2164 newenvironment XXXXdsuspend 2165 global setbox EQ box vbox bgroup parboxrestore If we are inside a list environment displayindent and displaywidth give us totalleftmargin and linewidth 2166 parshape 1 displayindent displaywidth relax 2167 hsize columnwidth noindent ignorespaces 2168 HA 2169 par egroup Let s try giving EQ box the correct height for the first line and EQ copy the depth of the last line 2170 global setbox GRP box vbox 2171 vbox copy EQ box vtop unvbox EQ box 2172 unvbox GRP box 2173 t Need to add a dummy element to GRP queue 2174 global GRP queue xp the GRP queue 2175 elt gdef EQ trial 98 discretionarytimes nref 2176 t 2177 And then the one that does work 2178 newenvironment dsuspend 2179 global setbox EQ box vbox bgroup parboxrestore 2180 parshape 1 displayindent displaywidth relax 2181 hsize columnwidth noindent ignorespaces 282 L 2183 par egroup 2184 global setbox GRP box vbox 2185 hbox copy EQ box vtop unvbox EQ box 2186 unvbox GRP box 2187 t 2188 global GRP queue xp the GRP queue 2189 h elt gdef EQ trial let eq isIntertext True 2190 elt let eq isIntertext True 2191 t 2192 Allow intertext as a short form of the dsuspend environment it s more con venient to write b
56. breqn package are semantically oriented structure The way in which compound displayed for mulas are subdivided matches the logical structure more closely than say the standard eqnarray environment Separate equations in a group of equa tions are written as separate environments instead of being bounded merely by 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 automatic line breaking Overlong equations will be broken automatically to the prevailing column width and continuation lines will be indented follow ing standard conventions line breaks within delimiters Line breaks within left right delimiters work in a natural way Line breaks can be forbidden below a given depth of delimiter nesting through a package option mixed math and text Display equations that contain mixed math and text or even text only are handled naturally by means of a dseries environment that starts out in text mode instead of math mode 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 to inline math and to apply special effects such as adding space before the punctuation fl
57. ccept the first shape that works else fall to next one The sequence is hardcoded in the eq try layout jshape Would it be useful be more flexible eg try layouts LDA in order 198 def eq layout This is a branching function used to choose a suitable layout if the user didn t specify one in particular Default layout Try Single line layout first else try Multiline layouts 1099 namedef eq try layoute 10 60 let eq trial b eq trial c 101 edef parshape parshape 1 Opt the eq linewidth relax 102 eq trial b i eqotry layout multi uo setlength dim a wd EQ copy 2em Fudge can t shrink more than this uot if we re in a numbered group try hard to fit within the numbers 105 dim b eq linewidth uo if eq shiftnumber else if eq group 1107 if eq hasNumber addtolength dim b wd EQ numbox eqnumsep 1108 else if grp hasNumber addtolength dim b wd GRP numbox eqnumsep 1109 fi fi fi fi 62 iio ifdim dim a lt dim b Do we even have a chance of fitting to one line uu trace breqn debugmsg Choose Shape the wd EQ copy may fit in the dim b BRM assuming it might fit don t push too hard 1112 setlength dim b columnwidth dim a eq wdCond 7 1113 rightskip z plus dim b minus hfuzz 1114 eq trial b i eq try layout multi 1115 else us trace 117 breqn debugmsg Choose Shape Too long the wd EQ copy for one line 1118 free width the dim b 1119
58. ch more useful to have names for these registers indicative of way they are used Another source whence dimen registers could be borrowed is the amsmath package which allocates six registers for equation measuring purposes We can reuse them under different names since the amsmath functions and our functions will never be used simultaneously eqnshift alignsep tagshift tagwidth totwidth lineht 225 newdimen eq dp Depth of last line 26 newdimen eq wdL Width of the left hand side 227 newdimen eq wdT Total width for framing 28 newdimen eq wdMin Width of narrowest line in equation 229 newdimen grp wdL Max width of LHS s in a group 25 eq overrun 230 newdimen grp wdR Max RHS of all equations in a group 231 newdimen grp wdT 232 newdimen eq wdRmax 233 newdimen eq firstht Height of first line BRM measure the condition too 234 newdimen eq wdCond 23 newdimen eq indentstep Indent amount when LHS is not present 23 newdimen eq linewidth Width actually used for display 237 newdimen grp linewidth Max eq linewidth over a group Maybe eq hshift could share the same register as mathindent mjd 1997 10 22 2383 newdimen eq hshift 230 let eq isIntertext False Init eq indentstep to a nonzero value so that we can detect and refrain from clobbering a user setting of zero And eq sidespace to maxdimen because that is the right init before computing a min 20 eq indentstep maxdimen 21
59. chuk ar ticle With package option refnumbers leave unnumbered all uncited equations even if they are not done with the star form Bertolazzi s easyeqn idea In an equation group use a vertical bracket with the equation number to mark the lines contained in that equation For a two line multline thingamabob try to make sure that the lines overlap in the middle by 2 em or whatever settable design variable Provide a separate vertical column for the principal mathrel symbols and center them within the column if they aren t all the same width Maybe an option for dmath relwidth x so that two passes are not required to get the max width of all the mathrels Or no just require it to be an halign or provide a macro to be applied to all the shorter rels lhs widerel 19pt xrightarrow foo try to use vadjust for keepglue 102
60. ck the linebreak penalty 851 or case 1 do nothing end of equation 852 relax 853 or case 2 no op obsolete case 854 or case 3 transfer vspace and or penalty 855 ifx 1 EQ box eq revspace else eq revspaceb fi 856 or case 4 put back an insert 857 eq reinsert 858 or case 5 put back a mark 859 eq remark 860 or case 6 put back a vadjust 861 eq readjust 862 else some other break penalty 863 penalty count 864 fi 865 unhbox 1 866 Throw in a null display in order to get predisplaysize etc My original approach here was to start the null display then measure the equation and set a phantom of the equation s first line before ending the null display That would allow finding out if T X used the short displayskips instead of the normal ones But because of some complications with grouping and the desirability of omitting unnecessary invisible material on the vertical list it seems better to just collect information about the display getting prevdepth requires halign and manually perform our own version of TfX s shortskip calculations This approach also gives greater control e g the threshold amount of horizontal space between predisplaysize and the equation s left edge that determines when the short skips kick in becomes a designer settable parameter rather than hardwired into T X s7 def eq nulldisplay s8 begingroup frozen everydisplay Gemptytoks s9 display 3
61. d to do setspace BEFORE this for small skips to work 662 def eq topspace 1 63 begingroup 664 global let EQ shortskips False If we are in dgroup or dgroup and not before the top one we just insert intereqskip Otherwise we must check for shortskip 665 if And eq group Not eq GRPOfirst dmath ooo trace breqn debugmsg Between lines 667 parskip intereqskip penalty intereqpenalty ss trace breqn debugmsg parskip the parskip 43 eq check shortskip 669 else 670 eq check shortskip 671 if EQ shortskips 672 parskip abovedisplayshortskip 673 aftergroup belowdisplayskip aftergroup belowdisplayshortskip BRM Not exactly T X s approach but seems right 674 ifdim predisplaysize gt z nointerlineskip fi 675 else 676 parskip abovedisplayskip 677 fi 678 fi 679 if F eq frame 680 else 681 addtolength parskip eq framesept eq0framewd 682 fi oa ktrace 684 breqn debugmsg Topspace theb le EQ shortskips parskip the parskip 685 predisplaysize the predisplaysize 686 trace 687 1 sss endgroup 689 60 def eq check shortskip 61 global let EQ shortskips False s2 setlength dim a abovedisplayskip ht EQ numbox Here we work around the hardwired standard TeX value and use the designer parameter instead 63 ifdim leftskip lt predisplaysize s4 else If the display was preceeded by a blank line predisplaysize is maxdimen and so we should in
62. e breaks at relation symbols By default a line break will be taken before each relation symbol except the first one With the compact option ATEX 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 spread option to increase or decrease the amount of interline space in an equation See the example given above Use the 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 fboxrule Use the framesep option to change the amount of space separating the frame from what it encloses The default space is fboxsep Use the background option to produce a colored background for the equation body The breqn package doesn t automatically load the color package so this option won t work unless you remember to load the color package yourself Use the color option to specify a different color for the contents of the equa tion Like the background option this doesn t work if you forgot to load the color package Use the 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 dmath breakdepth 0 The default value for breakdepth is 2 Even when breaks are allowed inside de limiters they are marked as
63. e equation width then aligning all of the equations is going to be simple Otherwise we are going to have to break at least one of the RHS s and or at least one of the LHS s The first thing to try is using maxwd_L for the LHS s and breaking all the RHS s as needed to fit in the remaining space However this might be a really dumb strategy if one or more of the LHS s is extraordinarily wide So before trying that we check whether maxwd_L exceeds some threshold width beyond which it would be unsensible not to break the LHS Such as max one third of the available width six ems or something like that Or how about this Compare the average LHS width and RHS width and divide up the available width in the same ratio for line breaking purposes BRM Fairly broad changes it mostly didn t work before for me begin dgroup produces a numbered group The number is the next equa tion number There are 2 cases e If ANY contained equations are numbered begin dmath then they will be subnumbered eg 1 la and the group number is not otherwise displayed e If ALL contained equations are unnumbered begin dmath then the group as a whole gets a number displayed using the same number placement as for equations 89 eq group GRP top begin dgroup produces an unnumbered group Contained equations are numbered or not as normal But note that in the mixed case it s too late to force the unnumbered eqns to retry w
64. e various formats NOTE should recognize the case where the LHS s are a bit Wild and then do simple left align not on relation 2083 34 The darray environment There are two potential applications for darray One is like eqnarray where the natural structure of the material crosses the table cell boundaries and math op erator spacing needs to be preserved across cell boundaries And there is also the feature of attaching an equation number to each row The other application is like a regular array but with automatic displaystyle math in each cell and better interline spacing to accommodate outsize cell contents In this case it is difficult to keep the vert ruling capabilities of the standard array environment without redoing the implementation along the lines of Arseneau s tabls package Because the vert ruling feature is at cross purposes with the feature of allowing interline 95 stretch and page breaks within a multiline array of equations the darray environ ment is targeted primarily as an alternative to eqnarray and does not support vertical ruling Overall strategy for darray is to use halign for the body In the case of a group use a single halign for the whole group What about intertext That s the most reliable way to get accurate column widths Don t spread the halign to the column width just use the natural width Then if we repack the contents of the halign into EQ box and EQ copy as done for dmath
65. eed to peek ahead for two things following punction such as period or command that should be pulled in for inclusion at the end of the equation and possibly also an end proof with an implied qed symbol that is traditionally included at the end of the display rather than typeset on a separate line We could require that the users type ged explicitly at the end of the display when they want to have the display take notice of it But the reason for doing that would only be to save work for the programmer the most natural document markup would allow an inline equation and a displayed equation at the end of a proof to differ only in the environment name begin math end math end proof versus begin dmath end dmath end proof The technical difficulties involved in supporting this markup within TEX 2e are admittedly nontrivial Nonetheless let s see how far we can go The variations that we will support are only the most straightforward ones end dmath end proof or end dmath Perhaps a comment end proof If there is anything more complicated than a space after the period we will not attempt to scan any further for a possible end proof This includes material such as begin figure end figure footnote renewcommand foo par 40 peek branch check punct or even a blank line because in ATEX a blank line is equivalent to par and the meaning of par is e
66. efinition 4 If a tag is to be positioned vertically centered M it should be placed such that the baseline of the tag is positioned exactly halfway between the baseline of the top line of the display and the baseline of the bottom line of the display Definitions 1 3 are almost axiomatic in their simplicity Definition 4 is different because I saw at least two possibilities for which area to span e Calculate distance from top of top line to the bottom of the bottom line position the vertical center of the tag exactly halfway between those two extremes e Calculate the distance from the baseline of the top line to the baseline of the bottom line position the baseline of the tag exactly halfway between these two extremes Additional combinations of these methods are possible but make little sense in my opinion I have two reasons for choosing the latter of these possibilities Firstly two expressions looking completely identical with the exception of a superscript in 72 eq dump box the first line or a subscript in the last line will have the tag positioned identically Secondly then M means halfway between T and B positions which makes good sense and then also automatically fulfills Definition 1 From an implementation perspective these definitions should also make it possible to fix a deficiency in the current implementation namely that the tag does not influence the height of a display even if the display is a single line This
67. en nigh impossible to incorporate the original sources with Michael s comments A big big thank you to him 14 14 Introduction The breqn package provides environments dmath dseries and dgroup for dis played equations with automatic line breaking including automatic indention of relation symbols and binary operator symbols at the beginning of broken lines These environments automatically pull in following punctuation so that it can be written in a natural way The breqn package also provides a darray environ ment similar to the array environment but using displaystyle for all the array cells and providing better interline spacing because the vertical ruling feature of array is dropped These are all autonumbered environments like equation and have starred forms that don t add a number For a more comprehensive and detailed description of the features and intended usage of the breqn package see breqndoc tex 15 Strategy Features of particular note are the ability to have linebreaks even within a left right pair of delimiters and the automatic alignment on relations and binary operators of a split equation To make dmath handle all this we begin by setting the body of the equation in a special paragraph form with strategic line breaks whose purpose is not to produce line breaks in the final printed output but rather to mark significant points in the equation and give us entry points for un packing left right boxes Afte
68. endgroup 144 Move the math start and math end functions into control sequences If I were redesigning TFX I guess I d put these functions into primitive control words instead of linking them to a catcode That way T X would not have to do the special lookahead at a to see if there s another one coming up Of course that s related to the question of how to provide user shorthand for common constructions TEX or an editing interface of some sort us begingroup catcode thr just to make sure ue global let math gdef display 17 endgroup us let endmath math 149 let enddisplay display Save the primitives vadjust insert mark because we will want to change them locally during equation measuring to keep them from getting in the way of our vertical decomposition procedures We follow the example of input end par where the primitive meaning is stored in an internal control se quence with a prefix 150 saveprimitive vadjust vadjust 151 saveprimitive insert insert 152 saveprimitive mark mark 20 Debugging Debugging help iss trace isa errorcontextlines 2000 relax Print a debugging message 155 long def breqn debugmsg 1 GenericInfo space 1 Sometimes the newline behavior of message is unsatisfactory this provides an alternative 156 def debugwr 1 immediate write sixt n 1 22 debug box eqinfo debug para egfontsi
69. ent value of the equation counter This might in rare cases cause something to blow up in which case the user needs to add protect 19338 g lobal sbox GRP numbox unhbox EQ numbox i939 grp wdNum eq wdNum 19410 let eq hasNumber False 1941 let eq number Gempty 1942 eq wdNum z 1943 VA 1944 protected edef theparentequation theequation ins setcounter parentequation value equation And set the equation counter to 0 so that the normal incrementing processes will produce the desired results if the child equations are numbered 1946 setcounter equation 0 1947 def theequation theparentequation alph equation 148 trace breqn debugmsg Group Number theequation 1949 At the end of a group need to reset the equation counter 91 grp push grp finish 1950 def grp resetnumber 7 151 setcounter equation value parentequation 1952 1953 newbox GRP box 1954 newbox GRP wholebox Save data for this equation in the group e push the trial data onto end of GRP queue e push an hbox onto the front of GRP box containing EQ box EQ copy penalty 1 and EQ numbox For putting the equation on a queue 1955 def grp push 1956 global GRP queue xp xp Oxp Oxp the xp GRP queue 1957 Oxp elt xp EQ trial 1958 1959 global setbox GRP box vbox 1960 hbox box EQ box box EQ copy penalty ne copy EQ numbox 1961 unvbox GRP box 1962 t 1963 EQ t
70. eq dense enough a eq delt eq dense enough b 1349 trace breqn debugmsg Density check less than 3 lines OK 1350 True 1351 else 1352 ifdim eq QwdL gt 7 eq wdT 1353 trace breqn debugmsg Density check LHS too long NOT OK 1354 False 1355 else xp xp xp eq dense enough a 1356 fi 1357 fi 1358 1359 def true true true fi fi iftrue iftrue iftrue 1360 def true false true fi fi iftrue iffalse iftrue 1361 def false true false fi fi iffalse iftrue iffalse 1362 def false false false fi fi iffalse iffalse iffalse This number specifies for the ladder layout how much of the equation s bounding box should contain visible material rather than whitespace If the amount of visible material drops below this value then we switch to the drop ladder layout The optimality of this factor is highly dependent on the equation contents 475 was chosen as the default just because it worked well with the sample equation designed to be as average as possible that I used for testing 1363 def eq density factor 475 Calculate whether there is more visible material than whitespace within the equa tion s bounding box Sum up the actual line widths and compare to the total area of the bounding box But if we have an extremely large number of lines fall back to an approximate calculation that is more conservative about the danger of exceeding maxdimen 1364 def eq dense enough a y 1365
71. eq shiftnumber 552 csname eq typeset eqnumside Shifted endcsname 553 else If there is only one line and the tag doesn t have to be shifted we call a special procedure to put the tag correctly 554 ifnum eq final linecount ne 555 csname eq typeset eqnumside single endcsname 556 else 557 csname eq typeset eqnumside eqnumplace endcsname 558 fi 559 fi 560 else 561 eq typeset GUnnumbered 562 fi 533 endgroup 564 eq botspace 565 These are temporary until the tag position algorithm gets rewritten At least the tag is positioned correctly for single line displays The horizontal frame posi tion is not correct but the problem lies elsewhere soo def eq typeset L single 557 nobreak sss eq params eq parshape so nointerlineskip noindent 50 add grp label si rlap kern leftskip box EQ numbox 52 if F eq frame 573 else 574 rlap raise eq firstht hbox to z eq addframe hss 575 fi 576 eq dump box unhbox EQ box par S77 57 def eq typeset R single 59 nobreak sso eq params eq parshape ssl nointerlineskip noindent 5822 add grp label ss if F eq frame sa else 585 rlap raise eq firstht hbox to z eq addframe hss 586 fi sv rlap kern leftskip kern linewidth kern wd EQ numbox copy EQ numbox 39 ses eq dump box unhbox EQ box 589 par 590 25 Special processing for end of equation At the end of a displayed equation environment we n
72. eqlinespacing freeze glue eqlineskip 429 430 def eq framesep fboxsep 33 begin dmath background red Foreground and background colors for the equation By default the background area that is colored is the size of the equation plus fboxsep If you need anything fancier for the background you d better do it by defining eqframe in terms of colorbox or fcolorbox 431 define key breqn background def eq background 1 a2 freeze glue eqlinespacing freeze glue eqlineskip 433 aa end macrocode 435 h begin literalcode 436 h begin dmath color purple az 4 end literalcode 438 h begin macrocode 439 def ine key breqn color def eq foreground 1 begin dmath center begin dmath nocenter The center option means add leftskip stretch to make the individual lines be centered this is the default for dseries 40 define key breqn center let eq centerlines True a4 define key breqn nocenter let eq centerlines False 442 lLet eq centerlines False begin dgroup noalign Equation groups normally have alignment of the primary relation symbols across the whole group The noalign option switches that behavior 43 define key breqn noalign let grp aligned False 44 let grp aligned True default begin dgroup breakdepth 2 Break depth of 2 means that breaks are allowed at mathbin symbols inside two pairs of delimiters but not three as define key breqn bre
73. er plus a letter If the main relation symbols in a group of equations are to be aligned then the final alignment computations cannot be done until the end of the group i e the horizontal positioning of the first n 1 equations cannot be done immediately Yet because of the automatic line breaking we cannot calculate an initial value of RHS max over the whole group unless we do a trial run on each equation first to find an RHS max for that equation Once we know RHS group max and LHS group max we must redo the trial set of each equation because they may affect the line breaks If the second trial for an equation fails one of its lines exceeds the available width but the first one succeeded fall back to the first trial i e let that equation fall out of alignment with the rest of the group All right then here is the general idea of the whole algorithm for group align ment To start with ignore the possibility of equation numbers so that our equa tion group has the form LHS 1 RHS 1 1 RHS 1 2 RHS 1 n 1 LHS 2 RHS 2 1 RHS 2 2 RHS 2 n 2 LHS 3 RHS 3 1 RHS 3 2 RHS 3 n 3 The number of RHS s might not be the same for all of the equations First accumulate all of the equation contents in a queue checking along the way to find the maximum width of all the LHS s and the maximum width of all the RHS s Call these widths maxwd_L and maxwd_R Clearly if maxwd_L maxwd_R is less than or equal to the availabl
74. erword spaces function the way they should puts in a comma and adds an appropriate amount of space To facilitate promotion demotion of formulas condition 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 condition command condition Thus to get no punctuation condition For conditions that contain no text you can use the starred form of the command which means to stay in math mode 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 But the breqn package refrains from predefining such abbreviations in order that they may be left to the individual author s taste 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 hiderel1 T n hiderel leq T 2 n leq c 3 n 2 n 10 Various environment options The following options are recognized for the dmath dgroup darray and dseries environments some of the options do not make sense for all of the environments but if an option is used where not
75. es a uniform indent for all lines after the first one and does not take any account of the equation 55 number A substantial majority of equations only require one line anyway and for them this first trial will succeed In the one line case if there is an equation number and it doesn t fit on the same line as the equation body we don t go on to other trials because breaking up the equation body will not gain us anything we know that we ll have to use two lines in any case so we might as well keep the equation body together on one line and shift the number to a separate line If we learn from the first trial that the equation body requires more than one line the next parshape trial involves adjusting the previous parshape to leave room for the equation number if present If no number is present again no further trials are needed Some remarks about parshape handling The TFX primitive doesn t store the line specs anywhere the parshape only returns the number of line specs This makes it well nigh impossible for different packages that use parshape to work together Not that it would be terribly easy for the package authors to make inter package collaboration work if it were possible If we optimistically conjecture that someone some day may take on such a task then the thing to do obviously is provide a parshape interface that includes a record of all the line specs For that we designate a macro parshape which includes not
76. estion for the article and amsart documentclasses 20 ifpackagewith amsmath fleqn 21 def eqindent I 262 23 def Ctempa 1 fleqn clo 2 3 nil 264 ifx 2 relax else def eqindent I fi 265 25 xp tempa filelist fleqn clo nil 27 if I eqindent 268 else 269 ifundefined if fleqn 270 edef eqindent 271 if TT csname fi endcsname csname if fleqn endcsname 272 I else C fi 273 274 th 275 fi 276 BRM This conditional implies we must use ALL indented or ALL centered 27 W if I eqindent os ifundefined mathindent 279 newdimen mathindent 20 H 281 ifundefined mathmargin 282 mathindent mathmargin 283 284 285 A fi 23 Measuring equation components Measure the left hand side of an equation This function is called by mathrel symbols For the first mathrel we want to discourage a line break more than for following mathrels so mark lhs gobbles the following rel break and substi tutes a higher penalty Maybe the LHS should be kept in a separate box Boolean does this equation have a left hand side 236 Let EQ hasLHS False 27 EQ QED If nonempty the ged material that should be incorporated into this equation after mark lhs mark lhs a hiderel the final punctuation 287 Let EQ QED empty oss def mark lhs 1 290 ifnum lr level lt ne 290 let mark lhs relax 291 global let EQ hasLHS True 292 global let E
77. etween equations 20 newcount prerelpenalty prerelpenalty M Linebreak penalty before mathrel symbols 21 newcount prebinoppenalty prebinoppenalty 888 Linebreak penalty before mathbins When breaking equations we never right justify so a stretch component of the muskip is never helpful and sometimes it is definitely undesirable Note that thick medmuskips frozen inside a fraction or radical may turn out noticeably larger than neighboring unfrozen ones Nonetheless I think this way is the best compromise short of a new T X that can make those built up objects shrink horizontally in proportion the alternative is to pretty much eliminate the shrink possibility com pletely in displays 22 newmuskip Dmedmuskip Dmedmuskip 4mu minus 3mu medmuskip in displays 23 newmuskip Dthickmuskip Dthickmuskip 5mu minus 2mu thickmuskip in displays 24 And now some internal variables 1997 10 22 some of these are dead branches that need to be pruned MH Started cleaning up a bit No more funny loops 204 def eq number Internal variable 25 newlength eqleftskip eqleftskip centering Space on the left NOT USED 26 newlength eqrightskip eqrightskip centering Space on the right NOT USED 27 newlength eq vspan eq vspan z skip Glue used to vcenter the eq number 28 newmuskip eq binoffset eq binoffset eqbinoffset Roughly eqbinoffset eqdelimoffset 29 newsavebox EQ box Storage for equation body 210 newsavebox E
78. exible numbering Equation numbering is handled in a natural way with all the flexibility of the amsmath package and with no need for a special nonumber command special effects It is easy to apply special effects to individual displays e g changing the type size or adding a frame using available space Horizontal shrink is made use of whenever feasible With most other equation macros it is frozen when it occurs between left right delimiters or in any sort of multiline structure so that some expres sions require two lines that would otherwise fit on one high quality spacing The abovedisplayshortskip is used when applicable other equation macros fail to apply it in equations of more than one line abbreviations Unlike the amsmath equation environments the breqn environ ments can be called through user defined abbreviations such as beq eeq 6 Shortcomings of the package The principal known deficiencies of the breqn package are 6 1 Incompatibilities As it pushes the envelope of what is possible within the context of ATEX 2e the breqn package 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 6 2 Indention of delimited fragments When line breaks within delimiters are involved the automatic indention of con tinuation lines is likely to be unsatisfactory and need
79. firstht 1625 fi 1626 31 Delimiter handling The special handling of delimiters is rather complex but everything is driven by two motives to mark line breaks inside delimiters as less desirable than line breaks elsewhere and to make it possible to break open left right boxes so that line breaks between left and right delimiters are not absolutely prohibited To control the extent to which line breaks will be allowed inside delimiters set eqbreakdepth to the maximum nesting depth Depth 0 means never break inside delimiters Note eqbreakdepth is not implemented as a TFX counter because changes done by setcounter etc are always global It would be natural to use grouping in the implementation at an open delim iter start a group and increase mathbin penalties at a close delimiter close the group But this gives us trouble in situations like the array environment where a Close delimiter might fall in a different cell of the halign than the open delim iter Ok then here s what we want the various possibilities to expand to Note that right and biggr are being unnaturally applied to a naturally open type delimiter gt delimiter 4 after open left gt left delimiter 4 after open right gt right delimiter 4 after close biggl gt mathopen left delimiter vrule right after open biggr gt mathclose left delimiter vrule right after close bigg vert
80. ftmargin gt dim b dim b totalleftmargin fi 1211 else 1212 addtolength dim b totalleftmargin 1213 fi 1214 setlength dim a eq linewidth dim b advance dim alem relax Allowance for shrink Set up test against 1 line case only if not in a group 1215 int a ne if eq group int a maxint fi Now check for cases 1216 if eq shiftnumber Already know we need to shift 1217 else ifdim eq QwdT lt dim a Fits left amp right skips will be done later and parshape adjusted if needed 1218 trace breqn debugmsg Place number eqn and number fit together 1219 h else ifnum eq lines int a Shift if single line unless inside a dgroup NOTE this is too strong for dgroup 1220 trace 1221 amp breqn debugmsg Place number single line too long with number gt Shift number the int 1222 trace 1223 let eq shiftnumber True 1224 else Retry use leftskip for space for number for now whether right left amp adjust parshape 1225 leftskip wd EQ numbox advance leftskip eqnumsep 1226 setlength leftskip eqO wdNum 1227 setlength rightskip z plus dim a 1228 adjust parshape parshape 1229 trace 1230 breqn debugmsg Place number Try with leftskip the leftskip rightskip the rightskip 1231 MessageBreak parshape space xp gobble parshape 1232 trace 1233 nointerlineskip 1234 edef eq prev lines the eq lines 66 adjust parshape adjust parshape a adjust pars
81. functions Placement of number in an indented quotation or abstract If LH Swd gt 2em it might be a good idea to try with eq indentstep 2em before shifting the number Currently this doesn t happen if the first trial pass without the number succeeds with indentstep LH Swd gt 2em Read past end enumerate when checking for end proof Look into using a qed list of environment names instead of checking the existence of proofqed Pick up the vadjust footnote mark handling Forcing prohibiting page breaks after before an equation Adding a spanner brace on the left and individual numbers on the right indy numbered cases Provide shiftnumber holdnumber to override the decision Provide a mechanism for adjusting the vertical position of the number Here a version specific selection macro would be useful begin dmath style foredition 1 raisenumber 13pt Add an alignleft option for an equation group to mean break and align to a ladder layout as usual within the equations but for the group alignment used the leftmost point for equations that don t have an LHS this makes no difference Test with Arseneau s wrapfig for parshape everypar interaction Fix up the macro def elements Convert the literal examples in section Equation types and forms to typeset form Compile comparison examples e g a standard equation env with big left right objects that don t shrink versus how sh
82. g a null last line here is that the last line will contain parfillskip in addition to rightskip and a final penalty of 10000 instead of 1000N 1 lt N lt 9 which would interfere with the usual processing Setting a null last line and discarding it dodges this complication The penalty value 10001 is a no op case in the case statement of eq repacka 1775 penalty Mi z rule par 1776 setbox z lastbox unskip unpenalty 1777 hh Showboxbreadth maxdimen showboxdepth99 showlists 1778 Well for a small self contained computation carefully hand allocated dimens should be safe enough But let the maintainer beware This code cannot be arbitrarily transplanted or shaken up without regard to grouping and interaction with other hand allocated dimens 84 i779 dimendef sub depth 8 dimendef sup base 6 1780 dimendef prelim sub depth 4 dimendef prelim sup base 2 1781 def sym xheight fontdimen5 textfont twO 1722 def sup base one fontdimen13 textfont twO 17833 def sub base one fontdimen16 textfont two 1784 def sub base two fontdimen17 textfont two Note that only sup drop and sub drop come from the next smaller math style 1785 def sup drop fontdimen18 scriptfont twO 17286 def sub drop fontdimen19 scriptfont twO Provide a mnemonic name for the math axis fontdimen if it s not already defined 1787 providecommand mathaxis fontdimen22 textfont tw Assumes box 2 contains the sub sup and box 0 cont
83. gin and rightmargin Then we want to try in succession a number of different possibilities In each case if the next possibility is no wider than the previous one skip ahead to the one after 1 First try linewidth 2 the linewidth for the current level 2 list 2 If we cannot find adequate linebreaks at that width next try listwidth 2 the sum of leftmargin linewidth and rightmargin for the current list 3 If we cannot find linebreaks at that width next try linewidth 1 skipping this step if it is no larger then listwidth 2 If we cannot find linebreaks at that width next try listwidth 1 If we cannot find linebreaks at that width next try column width If we cannot find linebreaks at that width next try text width aom De S If we cannot find linebreaks at that width next try equation width if it exceeds text width i e if the style allows equations to extend into the margins At any given line width we run through a series of parshape trials and essen tially use the first one that gives decent line breaks But the process is a bit more complicated in fact In order to do a really good job of setting up the parshapes we need to know how many lines the equation will require And of course the number of lines needed depends on the parshape So as our very first trial we run a simple first approximation parshape Figure 5 whose main purpose is to get an estimate on the number of lines that will be needed it choos
84. hape b 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1250 1251 1252 1253 1254 edef eq prev badness the eq badness BRM eq trial p int a eq prev badness relax advance int a 50 relax int b eq prev lines if eq group advance int b ne fiZ Allow 1 extra line in group ifnum eq lines gt int b eq prev lines trace breqn debugmsg Adjustment causes more breaks gt Shift number let eq shiftnumber True else if eq badline trace breqn debugmsg Adjustment causes bad lines the eq badness gt Shift let eq shiftnumber True else ifnum eq badness gt int a BRM New case trace breqn debugmsg Adjustment is badder than previous the eq badness gt gt eq prev badness gt Shift trace let eq shiftnumber True else trace breqn debugmsg Adjustment succeeded fi fi fi fi fi fi If we got shifted restore parshape etc 1255 1256 1259 1260 1261 1262 if eq shiftnumber EQ trial Restore parshape amp other params leftskip z let eq shiftnumber True But set shift amp leftskip edef parshape eq parshape And copy saved parshape back to working copy fi eq trial save EQ trial Either way save the trial state fi Varies depending on the layout Adjust a parshape variable for a given set of left right skips Note that the fixed part of the left right skips effectively comes out
85. hat probably apply here e centerlines e totalleftmargin SHOULD we move farther right Leftskip is normally just the requested indentation 1554 def eq I setsides y 1555 leftskip mathindent But move left if shifted number presumably because of clashed w number 1556 if eq shiftnumber 1557 setlength dim a eq linewidth eq wdT mathindent 1558 ifdim dim a lt z 1559 leftskip z Or something minimal 1560 fi 1561 fi Push gently from right 1562 dim a z i603 S Set length dim b eq linewidth leftskip eq wdMin Special case if framing be much more rigid 1564 if F eq frame 1565 else 1566 setlength dim a eq linewidth leftskip eq wdT 1567 addtolength dim b dim a 7 1568 fi iss9 Or force the space for right number if needed 1570 begin macrocode 1571 if And eq hasNumber Not eq shiftnumber 1572 if R eqnumside 1573 dim c eq wdNum 1574 if dim c gt dim a 1575 addtolength dim b dim c 1576 dim a dim c 1577 fi 1578 fi 1579 fi 1580 setlength rightskip dim a plus dim b minus hfuzz hfuzz z 1581 parfillskip z skip 1582 Typesetting pieces frame equation and number if any dim a should contain the downward displacement of number s baseline TT eqframe 1583 def eq typeset leftnumber isa Set length skip c dim a ht EQ numbox 1585 vglue skip c NON discardable 1586 copy EQ numbox penalty OM 15
86. idered simply invalid markup if a display math environment were demoted to in line math and we want to keep their markup as parallel as possible If punctuation does not follow then the check ged branch is not applicable so def check punct futurelet let token check punct a s01 def check punct at s2 edef tempat 603 ifx let token sptoken nx finish end 604 else ifx let token nx check qed 605 else ifx let token nx check qed 606 else check punct b check the less common possibilities 607 fi fi fi 608 t soo tempa 610 ou begingroup 612 toks a s3 ifx let token nx check qed 41 latex end finish end s4 else ifx let token nx check qed s5 else ifx let token nx check qed 616 ov toks c fi fi fi matching with toks a ois catcode active catcode active catcode active s19 catcode active catcode active 620 toks b 61 else ifx let token nx check qed 622 else ifx let token nx check qed 623 else ifx let token nx check qed 64 else ifx let token nx check qed 65 else ifx let token nx check qed 66 else nx finish end s7 fi fi fi fi fi 628 629 xdef check punctOb 630 the toks a the toks b the toks c 631 632 endgroup 633 let found punct empty 634 def check qed 1 635 gdef found punct 1 656 peek skipping spaces check qed a 637 638 def check qed a o ifx end
87. im a eq firstht u6 eq t ypeset lef tnumber 73 u 7 eq typeset frame m eq typeset equation 1419 Typeset equation and left shifted number 120 def eq typeset LShifted 1421 place number 122 copy EQ numbox penalty OM 1423 dim a eqlineskip ua if F eq frame else 1425 setlength dim a eq framesep eq framewd 1426 fi 1427 kern dim a ize eq typeset frame u29 eq typeset equation 1430 Typeset equation and right middle number 1431 def eq typeset RM 1432 setlength dim af eq vspant ht EQ numbox dp EQ numbox 2 u33 eq typeset rightnumber 1434 eq typeset frame 1435 eq typeset equation 1436 Typeset equation and right bottom number 1437 def eq typeset RB uss NOTE is eq dp useful here 1439 setlength dim a eq vspan ht EQ numbox dp EQ numbox io eq typeset rightnumber ai eq typeset frame ua eq typeset equation 1443 Typeset equation and right shifted number 1444 def eq typeset RShifted 14s place number 1446 eq typeset frame 1447 eq t ypeset equation is penalty M 1449 dim a eqlineskip uso if F eq frame else 1451 addtolength dim a eq framesep eq framewd 1452 fi 1453 parskip dim a usa hbox to hsize hfil copy EQ numbox par 1455 Debugging aid to show all relevant formatting info for a given eqn 1456 ktrace 1457 def debug showformat 4 uss breqn debugmsg Formatting Layout eq layout space Center inden
88. imit to 1 line And no fallback 1872 def eq try layoute M y is73 edef parshape parshape 1 Opt the eq linewidth relax 174 eq trial b M 1875 BRM Tricky to get right value here Prefer breaks between formula if we ve got to break at all 1876 4 def intermath penalty 201 1877 def intermath penalty 221 BRM A bit tighter than it was lem minus 25em 1878 4 newcommand dquad hskip0O 4em 1879 newcommand dquad hskipO 6em minus 3em 1880 newcommand premath newcommand postmath Change the math environment to add premath and postmath They are no ops except inside a dseries environment Redefinition of math environment to take advantage of dseries env 1881 renewenvironment math 1882 leavevmode premath 1883 ifmmode badmath else math fi 1884 1885 ifmmode endmath else badmath fi 1886 1887 def ends math 1 check punct or qged 1888 def end math isso 30 ifmmode endmath else badmath fi 18900 postmath 1891 33 Equation groups For many equation groups the strategy is easy just center each equation indi vidually following the normal rules for a single equation In some groups each equation gets its own number in others a single number applies to the whole group and may need to be vertically centered on the height of the group In still 88 other groups the equations share a parent number but get individual equation numbers consisting of parent numb
89. ing e g a thickmuskip or med muskip from a following mathrel or mathbin symbol 1756 def ss finish 7 1737 S vadjust penalty thre o 7 1758 penalty right delim code penalty subsup flag keep glue 1759 For eq lrunpack we need to break open a left right box and reset it just in case it contains any more special breaks After it is unpacked the recursion of eq repack will continue acting on the newly created lines 1760 def eq 1lrunpack setbox z lastbox We remove the preceding glue item and deactivate baselineskip for the next line otherwise we would end up with three items of glue counting parskip at this point instead of the single one expected by our recursive repacking procedure 1761 unskip nointerlineskip Then we open box 0 take the left right box at the right end of it and break that open If the line ending penalty is greater than 10000 it means a sub and or superscript is present on the right delimiter and the box containing them must be taken off first 1762 noindent unhbox z unskip 173 Subsup flag lastpenalty unpenalty 17654 6 xdef right delim code number lastpenalty 1765 unpenalty i76 6360 ifnum subsup flag gt oM 1767 advance subsup flag M 1768 setbox tw lastbox 1759 else Setbox tw box voidb x 1770 fi 171 setbox z lastbox 1772 ifvoid tw unhbox z 173 else lrss reattach uses subsup flag box z box tw 1774 fi The reason for addin
90. ing equation s2 trace debug showmeasurements 530 if F eq frame else 531 freeze glue eqlinespacing freeze glue eqlineskip 532 fi 533 A eq topspace vskip parskip Set top spacing 534 csname eq eqindent setsides endcsname Compute leftskip rightskip 535 adjust parshape eq parshape Final adjustment of parshape for left right skips If we are in an a group of equations we don t want to calculate the top space for the first one as that will be delayed until later when the space for the group is calculated However we do need to store the leftskip used here as that will be used later on for calculating the top space 536 if eq group 537 if eq GRP first dmath 538 global let eq GRP first dmath False 539 xdef dmath first leftskip leftskip the leftskip relax sso trace breqn debugmsg Stored space dmath first leftskip 541 else 542 eq topspace vskip parskip Set top spacing 543 fi 544 else 545 eq topspace vskip parskip Set top spacing 546 fi saz trace debug showformat We now know the final line count of the display If it is a single line display we want to know as that greatly simplifies the equation tag placement until such a 38 time where this algorithm has been straightened out 548 afterassignment remove to nnil 549 eq final linecount expandafter gobble eq parshape nnil Now invoke the appropriate typesetter according to number placement 550 if eq hasNumber 551 if
91. iously true for parens and braces where the largest super extended versions consist of truly vertical parts with slight bending on the ends than it is for a rangle But suppose for the sake of expediency that it is approximately true for rangle symbols also Here are some passable twang factors for the most common types of delimiters in cmex10 as determined by rough measurements from magnified printouts vert bar double vert 0 square bracket 1 curly brace 25 parenthesis 33 rangle 4 Let s provide a non private command for changing the twang factor of a given symbol 86 1833 newcommand DeclareTwang 2 1834 ifcat nx 1 begingroup 1835 1lccode 1 lowercase endgroup DeclareTwang 2 i336 else 1837 Oxp decl twang 1 nil 2 7 1838 fi 1839 Note that this is dependent on a fixed interpretation of the mathgroup number 4 1840 def decl twang 1 2 3 4 5 6 7 nil 8 ist namedef twang number 4 5 6 8 1842 1843 DeclareTwang rangle 4 1844 DeclareTwang 33 1845 DeclareTwang rbrace 25 32 Series of expressions The dseries environment is for a display containing a series of expressions of the form A B or A and B or A B and C and so on Typically the expressions are separated by a double quad of space If the expressions in a series don t all fit in a single line they are continued onto extra lines in a ragged center format
92. ith number We ll just do a simple check of dimensions after the fact and force a shiftnumber if we re stuck NOTE Does this work for dseries as well alignment NOTE Does label attach to the expected thing For number placement We use shiftnumber placement on ALL equations if ANY equations need it or if an unnumbered equation is too wide to be aligned given that the group or other eqns are numbered does this latter case interract with the chosen alignment For Alignment As currently coded it tries to align on relations by default If LHS s are not all present or too long it switches to left justify Maybe there are other cases that should switch Should there be a case for centered NOTE Should there be some options to choose alignment 1892 let eq group False 1893 let grp shiftnumber False 1894 let grp hasNumber False 1895 let grp eqs numbered False 189 let grp aligned True Definition of the dgroup environment 1897 newenvironment dgroup i998 let grp hasNumber True optarg dgroup 1899 HA 1900 end dgroup 1901 And the i902 newtoks GRP queue 1993 newenvironment dgroup 1994 let grp hasNumber False optarg dgroup 1905 HA 1995 end dgroup 1907 1908 def dgroup 1 100 trace breqn debugmsg DGROUP 2 s5 s5 55 5 55 55555 5 i910 let eq group True global let eq GRPOfirst dmath True 1911 global GRP queue empty
93. ivial math macros as well as many other things where the connection is not immediately obvious e g the ATEX 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 J or 7M internally too bad that the ATX package loading code does not include automatic defenses to ensure normal catcodes in the interior of a package but it only handles the character But I took a random AMS journal article with normal end user kind of ATEX 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 7 Incomplete In addition in the alpha release 1997 10 30 the following gaps remain to be filled in documentation The documentation could use amplification especially more il lustrations and I have undoubtedly overlooked more than a few errors group alignment The algorithm for doing alignment of mathrel symbols across equations in a dgroup environment needs work Currently the standard and noalign alternatives produce the same output single group number When a dgroup has a group number and the individual equations are unnumbered the handling and placement of the group num
94. k recursive Finally add the mathon item to EQ box and EQ copy 73 setbox tw lastbox 74 global setbox EQ box hbox unhcopy tw unskip unpenalty unhbox EQ box 75 global setbox EQ copy hbox unhbox tw unskip unpenalty unhbox EQ copy 766 4 batchmode showbox EQ copy showthe eq wdL errorstopmode 77 6 fdim eq wdR gt z BRM eq wdL patch 768 setlength dim a wd EQ box eqOwdR 769 Apparently missing a thickmuskip 5mu 5 18em 0 27777777777 770 0 2777777777777em FUDGE 771 ifdim dim a gt eq wdL 772 xtrace 773 breqn debugmsg Correcting LHS from the eq wdL space to 774 the dim a the wd EQ box the eq wdR 775 trace 50 eq repack 776 eq wdL dim a 777 xdef EQ setwdL eq wdL the eq wdL relax 778 fi 779 fi 730 xtrace 71 breqn debugmsg Capture total length the wd EQ box MessageBreak 782 has LHS theb le EQ hasLHS eq wdL the eq wdL eq wdR the eq wdR 783 MessageBreak 784 eq wdCond the eq wdCond zss trace 76 egroup end vbox started earlier 737 xtrace 788 4 debugwr EQ box debug box EQ box 7e0 4 debugwr EQ copy debug box EQ copy z0 trace 791 Now we have two copies of the equation one in EQ box and one in EQ copy with inconvenient stuff like inserts and marks omitted eq addpunct is for tacking on text punctuation at the end of a display if any was captured by the gp lookahead 72 def eq addpunct 73
95. 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 dgroup environment all of the above and also begin dgroup noalign begin dgroup brace By default the equations in a dgroup are mutually aligned on their relation symbols lt gt and the like With the noalign option each equation is placed individually without reference to the others The brace option means to place a large brace encompassing the whole group on the same side as the equation number Options for the darray environment all of the above where sensible and also begin darray cols lcr hspace 2em 1lcr The value of the cols option for the darray environment should be a series of column specs as for the array environment with the following differences e 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 mbox in each of the individual cells e Vertical rules don t connect across lines 11 The flexisym package The flexisym package does some radical changes in the setup for math symbols to allow their definitions to change dynamically throughout a document The breqn 10 package uses this to make symbols of classes 2 3 4 5 run special functions inside an environment such as dmath that provide the necessary support for automatic
96. line breaking The method used to effect these changes is to change the definitions of DeclareMathSymbol and DeclareMathDelimiter and then re execute the stan dard set of ATEX math symbol definitions Consequently additional mathrel and mathbin symbols defined by other packages will get proper line breaking behav ior if the other package is loaded after the flexisym package and the symbols are defined through the standard interface 12 Caution Warning Things to keep in mind when writing documents with the breqn package e The notation must be written with the command coloneq Otherwise the and the will be treated as two separate relation symbols with an empty RHS between them and they will be printed on separate lines e Watch out for constructions like where a single binary operator or binary relation symbol is subscripted or superscripted When the breqn or flexisym package is used braces are mandatory in such constructions This applies for both display and in line math e If you want 4TRX to make intelligent decisions about line breaks when vert bars are involved use proper pairing versions of the vert bar symbols accord ing to context lvert n rvert instead of n With the nondirectional there is no way for TX to reliably deduce which potential breakpoints are inside delimiters more highly discouraged and which are not e If you use the german package or some other package that turns double quo
97. lly spaced normal height lines We also need to restore parshape if it had a non null value before the equation Not implemented yet 723 def eq resume parshape 26 Preprocessing the equation body Here is the function that initially collects the equation material in a box 720 def eq startup 70 global let EQ hasLHS False z1 setbox z vbox bgroup 732 noindent math displaystyle 733 penalty Mi 734 This setup defines the environment for the first typesetting pass note the hsize value for example 735 def eq setup at 76 everymath everydisplay 737 let newline eq newline future possibility 45 eq capture eq punct 738 let eq newline 70 let insert eq insert let mark eq mark let vadjust eq vadjust 70 hsize maxdimen pretolerance M Here it is better not to use flushglue Opt pluslfil for rightskip or else a negative penalty such as 99 for prerelpenalty will tempt T X to use more line breaks than necessary in the first typesetting pass Ideal values for rightskip and linepenalty are unclear to me but they are rather sensitively interdependent Choice of 10000 pt for rightskip is derived by saying let s use a value smaller than 1 fil and smaller than hsize but more than half of hsize so that if a line is nearly empty the glue stretch factor will always be less than 2 0 and so the badness will be less than 100 and so T X will not issue badness warnings 7 linepena
98. lt 1 global setbox GRP box vbox unvbox GRP box setbox z lastbox setbox tw hbox unhbox z ifnum lastpenalty ne else global setbox EQ numbox lastbox fi unpenalty global setbox EQ copy lastbox global setbox EQ box lastbox F F begingroup let eq botspace relax 1 if eq isIntertext vskip belowdisplayskip unvbox EQ copy else grp override eq finish 94 2065 fi 206 endgroup 2067 Override the eq trial data as needed for this equation in this group NOTE w numbering variations see above we may need to tell eq finish to allocate space for a number but not actually have one 208 def grp override For aligned possibly becomes an option For now ASSUMING we started out as CLM 260 def eqindent I compute nominal left for centering the group 270 3906 Se t length dim af grp linewidth grp wdT 2 Make sure L R not too wide should already have unset alignment 271 ifdim dim a lt z dim a z fi 272 dim b if L eqnumside grp wdNum else z fi make sure room for number on left if needed 273 if grp shiftnumber else 2074 ifdim dim b gt dim a dim a dim b fi 2075 fi 276 6 if grp aligned 2077 addtolength dim a grp wdL eq wdL 2078 fi 279 mathindent dim a 2080 ifdim dim b gt dim a 2081 let eq shiftnumber True 2082 fi Could set def eqnumplace T or even m if indentation is enough NOTE Work out how this should interact with th
99. lty m m2 rightskip z plus M p leftskip z skip parfillskip z skip 73 clubpenalty ne widowpenalty z interlinepenalty z After a relation symbol is discovered binop symbols should start including a special offset space But until then EQ prebin space is a no op m4 global let EQ prebin space relax Set binoppenalty and relpenalty high to prohibit line breaks after mathbins and mathrels As a matter of fact the penalties are then omitted by T X since bare glue without a penalty is not a valid breakpoint if it occurs within mathon mathoff items 75 binoppenalty M relpenalty OM 746 If an equation ends with a right delim the last thing on the math list will be a force break penalty Then don t redundantly add another forcing penalty question when does a penalty after a linebreak not disappear Answer when you have two forced break penalties in a row Ending punctuation if any goes into the last box with the mathoff kern If the math list ends with a slanted letter then there will be an italic correction added after it by TEX Should we remove it I guess so 26 1 Capturing the equation BRM There s a problem here or with ss scan If the LHS has left right pairs B scan gets involved It seems to produce a separate box marked w penalty 3 But it appears that eq repack is only expecting a single box for the LHS when it measures that box it s missing the typically larger bracketted section so
100. mDeB d symDeB let symDeA d symDeA 343 Llet left eq left let right eq right global lr level z 344 global eq wdCond z BRM new If we have an embedded array environment for example we don t want to have each math cell within the array resetting lr level globally to 0 not good And in general I think it is safe to say that whenever we have a subordinate level of boxing we want to revert to a normal math setup 34 everyhbox everyhbox emptytoks 346 let display setup relax textmath setup let textmath setup relax 347 t saa everyvbox everyvbox emptytoks 349 let display setup relax textmath setup let textmath setup relax 350 t 351 The textmath setup function is needed for embedded inline math inside text inside a display BRM DS Experiment Variant of display setup for use within dseries en vironmnents 352 def dseries display setup 3533 medmuskip Dmedmuskip thickmuskip Dthickmuskip 354 math_setup_display_symbols 355 hhhh let m Bin d Bin 356 Ahh Let mORe1 d GRel 357 hhh let symRel d symRel 358 hhh Let symBin d symBin 359 hhh let m DeL d DeL let m DeR d DeR let m DeB d DeB 300 hhh let m DeA d DeA 301 hhh let symDeL d symDeL let symDeR d symDeR 302 hhh let symDeB d symDeB let symDeA d symDeA 33 Llet left eq left let right eq right global lr level z 304 everyhbox everyhbox emptytoks 365 let display setup relax textmath setup let textmath se
101. mpcnta a8 let int b tempcntb a let int c count Same for dimen registers so let dim a tempdima si let dim b tempdimb 52 let dim c tempdimc 53 let dim d dimen sa let dim e dimen ii 55 let dim A dimen i Same for skip registers s6 let skip a tempskipa 57 let skip b tempskipb ss let skip c skip Same for token registers s9 let toks a temptokena co let toks b toks 6 toksdef toks c 2 62 toksdef toks d 4 63 toksdef toks e 6 a toksdef toks f 8 We need an absolute value function for comparing penalties 6 def abs num 1 ifnum 1 lt zO fi 1 The ifnext function is a variation of ifnextchar that doesn t skip over intervening whitespace We use it for the optional arg of nside dmath etc because we don t want unwary users to be tripped up by an unexpected attempt on 4TRX s part to interpret a bit of math as an optional arg 18 ifstar optarg True False Not And freeze glue z rule keep glue beginfequation ive NN 25 Wilece end equation s def ifnext 1 2 3 67 let tempd 1 def Ctempa 2 def tempb 3 s futurelet tempc ifnexta 69 Switch to tempa iff the next token matches 7 def ifnexta ifx Gtempc Gtempd let tempb tempa fi tempb Similarly let s remove space skipping from ifstar because in some rare case of nside an equation followed by a space and a where the is intended as the math binary operator it
102. n mathrel mathopen and mathclose symbols Normally it would suffice to call RequirePackage without any extra testing but the nature of the package is such that it is likely to be called earlier with different no options Then is it really helpful to be always warning the user about Incompatible Package Options I don t think so is ifpackageloaded flexisym io RequirePackage flexisym 2009 08 07 16 options options a options b options c options d nx xp 17 edef breqnpopcats breqnpopcats 18 catcode number number catcode 19 catcode number _ number catcode _ 2 21 catcode 7 catcode _ 8 catcode 12 relax 22 The keyval package for handling equation options and calc to ease writing compu tations 23 RequirePackage keyval calc relax And add an options cmd for processing package options that require an argument Maybe this will get added to the keyval package eventually 2 ifundefined options Get the package options and run setkeys on them 23 newcommand options 2 2 expandafter options a csname opt0 1 sty endcsname 2 7 setkeys 1 2 28 N Redefine opt pkgname sty as we go along to take out the options that are han dled and leave the ones that are not o def options a 1 2 30 edef tempa options b 2 Gempty nil 31 ifx 1 relax let 1 empty fi 32 xdef 1 1 ifx 1 empty O xp Ogobble tempa empty else
103. n will then be used by eq finish to do the typesetting of the real equation body a40 eq measure Piece together the equation from its constituents recognizing current constraints If we are in an equation group this might just save the material on a stack for later processing an if eq group grp push else eq finish fi 472 Ah yes now the lovely dmath environment a73 newenvironment dmath 7 a74 Let eq hasNumber False optarg dmath 7 ars 476 Qnamedef end dmath end dmath 477 namedef enddmath 1 check punct or qed If everypar has a non null value it s probably some code from afterheading that sets clubpenalty and or removes the parindent box Both of those actions are irrelevant and interfering for our purposes and need to be deflected for the time being If an equation appears at the very beginning of a list item possibly from a trivlist such as proof we need to trigger the item label azz def eq prelim a7 if inlabel indent par fi a80 if nobreak global nobreakfalse predisplaypenalty M fi ssi everypar emptytoks If for some reason dmath is called between paragraphs noindent is better than leavevmode which would produce an indent box and an empty line to hold it If we are in a list environment par is defined as par to preserve parshape a82 noindent a83 eq nulldisplay asa par 4 eq saveparinfo needs work a let intertext breqn intertext 48
104. nd k 7 the algorithm outputs two more vectors namely vl 0 5 5 0 9 5 1 0 vl 0 9 11 9 10 12 0 1 13 3 From the form of the matrix A after k 5 it is evident that these vectors satisfy the equation vA 0 0 Example 3 begin dmath T n hiderel leq T 2 lceil lg n rceil leq c 3 lceil lg n rceil 2 lceil lg n rceil lt 3c cdot3 lg n 3c n lg3 end dmath 13 T n lt T 2M8 1 lt gis 21871 lt 3c 318 3cn 83 Example 4 The reduced minimal Gr obner basis for I q_3 consists of begin dgroup begin dmath H_173 x_1 x_2 x_3 end dmath begin dmath H 2 2S x21 72 b 21 2 B27 20S g 1 ge2 end dmath begin dsuspend and end dsuspend begin dmath H 371 x13 2zi gl xi2 qe end dmath end dgroup The reduced minimal Gr bner basis for 13 consists of H z1 22 3 2 2 2 H3 x 4 1 2 3 U and Hi x 2x1q 22m Implementation The package version here is Michael s v0 90 updated by Bruce Miller Michael s changes between v0 90 and his last v0 94 will be incorporated where applicable The original sources of breqn and related files exist in a non dtx format devised by Michael Downes himself Lars Madsen has kindly written a Perl script for transforming the original source files into near perfect dtx state requiring only very little hand tuning Without his help it would have be
105. nd paragraph in my opinion if explicit end of paragraph markup is given before the end of an element it has to be respected and the preceding paragraph has to be fully finished off before proceeding further even inside an element like proof whose end element formatting requires integration with the end of the paragraph text And T X nically speaking a par token that comes from a blank line and one that comes from the sequence of characters p a r are equally explicit I hope to add support for footnote in the future as it seems to be a legitimate markup possibility in that context from a purely logical point of view but there are additional technical complications if one wants to handle it in full generality mjd 1999 02 08 This is a generalized look at next token and choose some action based on it function 591 def peek branch 1 2 592 let peek b 1 let peek space 2 futurelet let token peek a 593 594 def peek skipping spaces 1 peek branch 1 peek skip space s9 def peek a s ifx let token sptoken expandafter peek space 57 else expandafter peek b fi 598 s9 lowercase def peek skip space futurelet let token peek a For this one we need to recognize and grab for inclusion any of the following to kens both catcode 12 standard TFX value and catcode 13 as might hold when the Babel package is being used We do not support a space pre ceding the punctuation since that would be cons
106. newdimen eq given sidespace MH Appears to be unused Not a dimen register don t need to advance it 242 def eq overrun Opt To initialize eqnumside and eqindent properly we may need to grub around a bit in filelist However if the amsmath package was used we can use its option data More trouble if a documentclass sends an option of leqno to amsmath by default and it gets overridden by the user with a reqno documentclass option then amsmath believes itself to have received both options 23 ifpackagewith amsmath leqno 24 ifpackagewith amsmath reqno def eqnumside L 245 JA If the amsmath package was not used the next method for testing the leqno option is to see if leqno clo is present in filelist 245 def tempa 1 leqno clo 2 3 nil 247 ifx 2 relax else def eqnumside L fi 248 249 xp tempa filelist leqno clo nil Even that test may fail in the case of amsart if it does not load amsmath Then we have to look whether iftagsleft is defined and if so whether it is true This is tricky if you want to be careful about conditional nesting and don t want to put anything in the hash table unnecessarily 20 if L eqnumside 251 else 252 ifundefined iftagslefte 253 edef eqnumside 7 254 if TT csname fi endcsname csname iftagsleft endcsname 26 EQC hasLHS 255 L else R fi 256 257 258 fi 250 A similar sequence of tests handles the fleqn or not fleqn qu
107. numbered variant of dseries dgroup Like the align environment of amsmath but with each constituent equa tion wrapped in a dmath dmath dseries or dseries environment in stead of being separated by The equations are numbered with a group number When the constituent environments are the numbered forms dmath or dseries they automatically switch to subequations style numbering i e something like 3a 3b 3c depending on the current form of non grouped equation numbers See also dgroup dgroup Unnumbered variant of dgroup If the constituent environments are the numbered forms they get normal individual equation numbers i e some thing like 3 4 5 darray Similar to eqnarray but with an argument like array for giving column specs Automatic line breaking is not done here darray Unnumbered variant of darray rather like array except in using displaystyle for all column entries 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 intertext 9 2 Commands The commands provided by the breqn package are condition This command is used for a part of a display which functions as a condition on the main assertion For example begin dmath f x frac 1 x condition for x neq 0 end dmath fa for x 0 1 The condition command automatically switches to text mode so that in t
108. nus 1 66663 OML cmm m it 10 f kern1 0764 OT1 cmr m n 10 penalty 888 glue 10 5553 rule x0 0 penalty 10000 glue 10 5553 glue medmuskip 2 22217 minus 1 66663 OT1 cmr m n 10 glue medmuskip 2 22217 minus 1 66663 OML cmm m it 10 g kern0 35878 penalty 10000 glue rightskip 0 0 plus 10000 0 glue baselineskip 9 5 Figure 3 Preliminary equation contents part 3 49 This is the mathoff fragment glue baselineskip 9 5 hbox 0 0 0 0 x16383 99998 glue set 1 6384 mathoff penalty 10000 glue parfillskip 0 0 glue rightskip 0 0 plus 10000 0 Figure 4 Preliminary equation contents part 4 747 newdimen eq wdR eq wdR zO BRM 78 def eq capture 79 ifnum lastpenalty gt M penalty Mi fi We want to keep the mathoff kern from vanishing at the line break so that we can reuse it later 70 keep glue endmath 751 eq addpunct 752 par 7533 eq wdL z First snip the last box which contains the mathoff node and put it into EQ box Then when we call eq repack it will recurse properly 74 setbox tw lastbox 75 global setbox EQ box hbox unhbox tw unskip unskip unpenalty 7 76 unskip unpenalty 737 global setbox EQ copy copy EQ box 758 hh global setbox EQ vimcopy copy EQ vimbox 79 clubpenalty z 700 4 batchmode showboxbreadth maxdimen showboxdepth99 showlists errorstopmode 71 eq wdR z BRM eq wdL patch 722 eq repac
109. o dim e space for condition on right if any and formula is only a single line to center uso but only count it as being right aligned if we re not framing since the frame must enclose 1481 dim e z us2 if F eq frame 1483 ifnum eq lines ne ifdim eq wdCond gt z 1484 setlength dim e eq wdCond conditionsep 1485 fi fi fi 1486 dim b minimum needed on left max totalleftmargin left number space 1487 dim b z uss if L eqnumside ifdim dim b lt dim c 1489 dim b dim c 1490 fi fi vuoi ifdim dim b lt totalleftmargin 1492 dim b z 1493 else 1494 addtolength dim b totalleftmargin 1495 fi 149 dim d minimum needed on right max condition right number space 1497 dim d dim e uss if R eqnumside ifdim dim d lt dim c 1499 dim d dim c 1500 fi fi 1500 dim a left margin initially half available space 75 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 dim c right margin ditto setlength dim a eq linewidth eq wdT dim e Ototalleftmargin 2 dim c dim a If too far to the left ifdim dim a lt dim b addtolength dim c dim a dim b ifdim dim c lt z dim c z fi dim a dim b Or if too far to the right else ifdim dim c lt dimed addtolength dim a dim c dim d ifdim dim a lt z dim a z fi dim c dim d fi fi Now dim d dim e is the left amp right glue to center e
110. only the line specs but also the line count and even the leading parshape token This allows it to be directly executed without an auxiliary if empty test It should include a trailing relax when it has a nonempty value os let parshape Gempty The function eq measure runs line breaking trials on the copy of the equation body that is stored in the box register EQ copy trying various possible layouts in order of preference until we get successful line breaks where successful means there were no overfull lines The result of the trials is first a parshape spec that can be used for typesetting the real equation body in EQ box and second some information that depends on the line breaks such as the depth of the last line the height of the first line and positioning information for the equation number The two main variables in the equation layout are the line width and the placement of the equation number if one is present eq measure Run linebreak trials on the equation contents and measure the results o9 def eq measure If an override value is given for indentstep in the env options use it oo 06 ifdim eq indentstep maxdimen eq indentstep eqindentstep fi If eq linewidth is nonzero at this point it means that the user specified a particular target width for this equation In that case we override the normal list of trial widths o1 ifdim eq linewidth z else edef eq linewidths the eq linewidth fi o2 beging
111. open after close after bidir zero bop bop incr 1692 hhhhh delimiter 4 xp delim a csname sd 1 2 3 endcsname 1 2 3 after open 1093 Lhbhht 1604 Khhhh def d DeR 1 2 3 7 165 hhhhh delimiter 5 xp delim a csname sd 1 2 3 endcsname 1 2 3 after close 1096 hhh t 1697 Khhhh def d DeBH1 2 3 7 1698 Ahhhh delimiter 0 xp delim a csname sd 1 2 3 endcsname 1 2 3 after bidir 1009 Ahhh BRM These weren t defined but apparently should be Are these the right val ues 1700 Ahhhhh Let m DeA mODeA let d DeA meDeA after open and after close are carefully written to avoid the use of grouping and to run as fast as possible zero bop is the value used for prebinoppenalty at delimiter level 0 while bop incr is added for each level of nesting The standard values provide that breaks will be prohibited within delimiters below nesting level 2 17071 let after bidir empty 1702 mathchardef zero bop 888 relax 1703 mathchardef bop incr 4444 relax 1744 def after open y 175 global advance lr level ne 176 prebinoppenalty bop incr multiply prebinoppenalty lr level 177 advance prebinoppenalty zero bop ins ifnum eqbreakdepth lt 1r level 1709 cs_set_eq NN math_sym_Bin Nn math_isym_Bin Nn 444 4 let m Bin m Bin Inside delimiters add some fillglue before binops so that a broken off portion will get thrown flush right Also shift it slightly further to the right to ensure that it clears the
112. r the initial typesetting we take the resulting stack of line fragments and working backward splice them into a new single line paragraph this will eventually be poured into a custom parshape after we do some measuring to calculate what that parshape should be This streamlined horizontal list may contain embedded material from user commands intended to alter line breaks horizontal alignment and interline spacing such material requires special handling To make the shortskip possibility work even for multiline equations we must plug in a dummy T X display to give us the value of predisplaysize and calculate for ourselves when to apply the short skips In order to measure the equation body and do various enervating calculations on whether the equation number will fit and so on we have to set it in a box Among other things this means that we can t unhbox it inside or even TEX doesn t allow you to unhbox in math mode But we do want to un hbox it rather than just call box otherwise we can t take advantage of available shrink from medmuskip to make equations shrink to fit in the available width So even for simple one line equations we are forced to fake a whole display with out going through T X s primitive display mechanism except for using it to get predisplaysize as mentioned above In the case of a framed equation body the current implementation is to set the frame in a separate box of width
113. redefined to be the tail of the list If we succeed in finding satisfactory line breaks for the equation we will reset EQ continue in such a way that it will terminate the current trials An obvious branch here would be to check whether the width of EQ copy is less than eq linewidth and go im mediately to the one line case if so However if the equation contains more than one RHS by default each additional RHS starts on a new line i e we want the ladder layout anyway So we choose the initial trial on an assumption of multiple lines and leave the one line case to fall out naturally at a later point o9 def eq trial a 1 ooo dim c 1 relax o1 if T eq frame eq frame adjust dim c fi o2 ifdim dim c gt eq linewidth 963 eq linewidth dim c oo trace breqn debugmsg Choose Shape for width 1 the eq linewidth 7 965 let eq trial b eq trial d 966 csname eq try layout eq layout endcsname 7 trace else ss trace breqn debugmsg Next width 1 is shorter skip it s9 fi o70 edef eq linewidths iffalse fi 971 972 def eq frame adjust 1 973 addtolength 1 2 eq framewd 2 eq framesep o4 dim a eq framewd advance dim a eq framesep 5 advance 1 2 dim a 976 58 Note cu rious control structure Try to understand interaction of EQ fallback EQ continue eq failout o77 def eq trial succeed oe aftergroup gobbletwo cancel the EQ fallback code see eq trial c 7 o79 g loba1
114. rial 1954 if eq isIntertext else 1965 ifdim eq wdL gt grp wdL global grp wdL eq wdL fi 1966 ifdim eqQ wdT gt grp wdT global grp wdT eq wdT fi 1967 setlength dim a eq wdT eqewdL 1968 ifdim dim a gt grp wdR global grp wdR dim a fi 1969 ifdim eq linewidth gt grp linewidth global grp linewidth eq linewidth fi 1970 if eq hasNumber 1971 global let grp eqs numbered True 1972 ifdim eq wdNum gt grp wdNum global grp wdNum eq wdNum fi 1973 fi 1974 if EQC hasLHS else global let grp aligned False fi 1975 if D eq layout global let grp aligned False fi Layout D usually puts rel on 2nd line 1976 if eq shiftnumber global let grp shiftnumber True fi One eq shifted forces all 1977 fi 1978 Set accumulated equations from a dgroup environment BRM Questionable patch When processing the GRP queue put it into a vbox then unvbox it This since there s a bizarre problem when the output routine gets invoked at an inopportune moment All the not yet processed GRP queue ends up in the freelist and bad name clashes happen Of course it could be due to some other problem entirely 1979 def grp finish 1980 4 debug box GRP box 1981 4 breqn debugmsg GRP queue the GRP queue Now that we know the collective measurements make final decision about alignment amp shifting Check if alignment is still possible 92 1982 Sett Llength dim a grp wdL grp wdR 4em Allowance for shrink
115. rinking can allow it to fit Frame the figures since they are mostly text Possible enhancements 101 10 11 12 13 14 Provide a pull option meaning to pull the first and last lines out to the margin like the multline environment of the amsmath package Maybe this should get an optional argument actually to specify the amount of space left at the margin With the draft option one would like to see the equation labels in the left margin Need to check with the showkeys package Options for break preferences if there s not enough room do we first shift the number or first try to break up the equation body In an aligned group does sticking to the group alignment take precedence over minimizing the number of line breaks needed for individual equations And the general preferences probably need to be overridable for individual instances Extend suppress breaks inside delimiters support to inline math suggestion of Michael Doob Use belowdisplayshortskip above a dsuspend fragment if the fragment is only one line and short enough compared to the equation line above it Add eqfuzz distinct from hfuzz Make use of it in the measuring phase Provision for putting in a continued note Conserve box mem modify frac sub sup overline underline sqrt to turn off bin break and less urgently rel break More explicit support for Russian typesetting conventions cf Grin
116. roup eq params 03 leftskip z skip Even if hfuzz is greater than zero a box whose contents exceed the target width by less then hfuzz still has a reported badness value of 1000000 infinitely bad Because we use inf bad to test whether a particular trial succeeds or fails we want 56 EQ trial EQ continue EQ widths to make such boxes return a smaller badness To this end we include an hfuzz allowance in rightskip In fact eq params ensures that hfuzz for equations is at least 1pt o4 rightskip z plus columnwidth minus hfuzz s 4 eqinfo o6 global EQ continue eq trial o7 eq trial uses eq linewidths ois eq failout will be a no op if the trial succeeded o9 endgroup local parameter settings are passed outside the endgroup through EQ trial 920 EQ trial o21 o22 xtrace 923 def debug showmeasurements 94 breqn debugmsg gt number eq lines space lines 925 begingroup 026 def elt 1X 2 MessageBreak space space 1 2 s7 let endelt empty 928 breqn debugmsg gt trial info eq measurements s9 breqn debugmsg gt bounding box the eq wdT x the eq vspan badness the eq badness 90 let elt relax let endelt relax 931 endgroup 932 033 def debug showmeasurements 94 begingroup 035 def elt 1X 2 MessageBreak 1 2 7 936 let endelt empty o7 breqn debugmsg gt Measurements number eq lines space lines 938
117. sappear as it should at the line break sss def eq newline s89 s if star eq newlinea OM eq newlinea eqinterlinepenalty s00 def eq newlinea 1 7 s31 ifnext eq newlineb 1 eq newlineb 1 maxdimen s2 def eq newlineb 1 2 penalty OM When eq revspace re vspace is called we are the end of an equation line we need to remove the existing penalty of 10002 in order to put a vadjust object in front of it then put back the penalty so that the line break will still take place in the final result 33 def eq revspace s4 g lobal setbox EQ vimbox vbox unvbox EQ vimbox 895 unpenalty 896 global setbox ne lastbox s7 vadjust unvbox ne ss penalty M 899 The b version is used for the EQ copy box o0 def eq revspaceb 91 global setbox EQ vimcopy vbox unvbox EQ vimcopy 54 eq break needs work Figure 5 first approximation parshape for equations 902 unpenalty 903 global setbox ne lastbox o4 vadjust unvbox ne os penalty M 906 The function eq break does a preliminary linebreak with a flag penalty 7 def eq break 1 penalty 1000 1 keep glue 27 Choosing optimal line breaks The question of what line width to use when breaking an equation into several lines is best examined in the light of an extreme example Suppose we have a two column layout and a displayed equation falls inside a second level list with nonzero leftmar
118. se AT X 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 Missing endgroup inserted Missing endgroup i d 13 Examples Knuth SNA p74 Example 1 Replace j by h j and by k j in these sums to get cf 26 begin dmath label sna74 frac i 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 fracfth k frac k h frac i hk right frac 1 2 frac 1 2h frac 1 2k 12 end dmath which is equivalent to the desired result Replace j by h j and by k j in these sums to get cf 26 I ott h 0 ae I oro 2 _1 fh Pe k 1 _ 1 1 1 6 k h hkj j 2 2h 2k which is equivalent to the desired result Knuth SNA 4 6 2 p387 13 2 Example 2 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 v7 2 0 5 5 0 9 5 1 0 mx v7 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 math expression Now every column which has no circled entry is completely zero so when k 6 a
119. sert a fairly large skip to separate paragraphs i e no short skip Perhaps this should be a third parameter abovedisplayparskip 695 ifdim maxdimen predisplaysize 696 else 697 if R eqnumside 698 global let EQ shortskips True 699 else 700 if eq shiftnumber 701 else 702 if T eqnumplace 703 ifdim dim a lt eq firstht 704 global let EQ shortskips True 705 fi 706 else 707 setlength dim b eq vspan 2 708 ifdim dim a lt dim b 44 eq resume parshape eq startup 709 global let EQ shortskips True 710 fi 711 fi 712 fi 713 fi 714 fi 715 fi 716 At the end of an equation need to put in a pagebreak penalty and some vertical space Also set some flags to remove parindent and extra word space if the current paragraph text continues without an intervening par mz def eq botspace 78 penalty postdisplaypenalty Earlier calculations will have set belowdisplayskip locally to belowdisplayshortskip if applicable So we can just use it here 79 if F eq frame 720 else 721 addtolength belowdisplayskip eq framesep eq framewd 722 fi 73 vskip belowdisplayskip 74 endpetrue kill parindent if current paragraph continues 725 global ignoretrue ignore following spaces 76 eq resume parshape 727 This should calculate the total height of the equation including space above and below and set prevgraf to the number it would be if that height were taken up by norma
120. sup flag count 1730 def ss delim aGnew 1 2 3 4 5 xdef right delim code number 4 5 The argument of ss scan is an expanded form of a right delimiter macro We want to use the last three digits in the expansion to define right delim code The assignment to a temp register is just a way to scan away the leading digits that we don t care about i731 def ss scan 1 7 This part of the code 1732 begingroup 1733 ss delim a new 1 i734 endgroup i735 subsup flag M afterassignment ss scan a let let token i730 def ss scan a 7 1737 let breqn next ss scan b 17383 ifx let token sb advance subsup flag ne else 1739 ifx let token subscript advance subsup flag ne else 140 ifx let token subscript other advance subsup flag ne else 141 ifx let token sp advance subsup flag tw else 142 ifx let token superscript advance subsup flag tw else 143 ifx let token superscript other advance subsup flag tw else 1744 ss finish 1745 let breqn next relax ime fi fi fi fi fi fi 1747 breqn next let token 1748 1749 ExplSyntax0n 1750 def ss scan b 1 2 1 hack coff 1751 AAhhh let m Bin m Bin let m Rel m Rel 1752 cs_set_eq NN math_sym_Bin Nn math_isym_Bin Nn 1753 cs_set_eq NN math_sym_Rel Nn math_isym_Rel Nn 1734 2 afterassignment ss scan a let let token 1755 ExplSyntax0ff 83 eq lrunpack lrss reattach We need to keep following glue from disappear
121. sym_Bin Nn cs_set Npn math_dsym_Rel Nn mark lhs rel break math_bsym_Rel Nn Exp1Syntax0ff The difficulty of dealing properly with the subscripts and superscripts sometimes appended to mathbins and mathrels is one of the reasons that we do not attempt to handle the mathrels as a separate column a la eqnarray More of the same 319 320 321 322 323 325 332 Exp1SyntaxOn 4 1let m symRe1 symRel hhh def d symRel mark lhs rel break m symRel cs_set_protected Npn math_dcsym_Bin Nn bin break math_bcsym_Bin Nn cs_set_protected Npn math_dcsym_Rel Nn mark lhs rel break math_bcsym_Rel Nn Ah let m symBin symBin def d symBin bin break m symBin 1et m symDe1 symDel h 1let m symDeR symDeR 1let m symDeB symDeB h let m symDeA symDeA Setup Note that TEX reserves the primitive everydisplay under the name frozen everydisplay BRM Disable this It also affects non breqn math 333 4 global everydisplay expandafter the everydisplay display setup Change some math symbol function calls 334 def display setup 29 335 medmuskip Dmedmuskip thickmuskip Dthickmuskip 336 math_setup_display_symbols 337 Ah let m Bin d Bin let m Rel d Rel 333 A4 let symRel d symRel let symBin d symBin 330 Ahd let m DeL d DeL let m DeR d DeR let m DeB de DeB 340 AA Let m DeA d DeA 341 Ah let symDeL d symDeL let symDeR d symDeR 342 Ah let sy
122. t eqindent space 74 1459 Number placement eqnumside eqnumplace 1460 MessageBreak eq linewidth the eq linewidth totalleftmargin the totalleftmargin 1461 MessageBreak Centered Lines theb le eq centerlines Shift Number theb le eq shiftn 1462 MessageBreak eq wdT the eq wdT eq wdMin the eq wdMin 1463 MessageBreak LHS theb le EQ hasLHS eq wdL the eq wdL 1464 MessageBreak eq firstht the eq firstht eq vspan the eq vspan 1465 MessageBreak eq wdNum the eq wdNum 1466 MessageBreak eq wdCond the eq wdCond conditionsep the conditionsep 1467 MessageBreak leftskip the leftskip rightskip the rightskip 1468 MessageBreak abovedisplayskip the abovedisplayskip 1469 MessageBreak belowdisplayskip the belowdisplayskip 1470 MessageBreak parshape eq parshape 1471 1472 trace Set left amp right skips for centered equations making allowances for numbers if any right left and constraint Amazingly I ve managed to collect all the positioning logic for centered equa tions in one place so it s more manageable Unfortunately by the time it does all it needs to do it has evolved I m re using so many temp variables it s becoming unmanageble 1473 def eq0C setsides y 1474 dim c space for number if any and not shifted 1475 dim c z 176 if eq hasNumber if eq shiftnumber else 1477 dim c eq wdNum 1478 fi fi u7
123. t 1 after close Here is the normal operation of biggl for example biggl gt mathopen bigg mathopen bigg 1 gt hbox left 1 vbox to14 5 p right n space 1 lt AFor paren matching Like left biggl coerces its delimiter to be of mathopen type even if its natural inclination is towards closing The function delim reset makes delimiter characters work just about the same as they would in normal ATEX 16546 def delim reset 16547 let after open relax let after close relax 1548 let left left let right right 1649 If the amsmath or exscale package is loaded it will have defined bBigg if not the macros big and variants will have hard coded point sizes as inherited through the ages from plain tex In this case we can kluge a little by setting big size to p so that our definition of bBigg will work equally well with the different multipliers 1650 ifundefined bBigg not defined 151 let big size p 80 m DeL d DeL m DeR d DeR m DeB d DeB 1652 def big bBigg 8 5 def Big bBigg 11 5 153 def bigg bBigg 14 5 def Bigg bBigg 17 5 154 def biggg bBigg 20 5 def Biggg bBigg 23 5 1655 1656 def bBigg 1 2 1657 delim reset 1658 left 27 1659 vrule height 1 big size width nulldelimiterspace 1660 right 1661 t 1662 1663 def bigl 1 mathopen big 1 after open 1664 def Bigl 1 mathopen Big 1 af
124. tations on floating objects within dgroup e align 1 or 2 3 4 expressing various levels of demand for group wide alignment Level 4 means force alignment even if some lines then have to run over the right margin Level 1 the default means first break LHS RHS equations as if it occurred by itself then move them left or right within the current line width to align them if possible Levels 2 and 3 mean try harder to align but give up if overfull lines result e Need an hshift command to help with alignment of lines broken at a discretionary times sign Also useful for adjusting inside delimiter breaks 4 Introduction The breqn package for ATEX 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 left right constructs cannot span lines The 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 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 pro cessed For this reason especially in the alpha release users should proceed with care and keep an eye out for unexpected glitches or side effects 5 Principal features The principal features of the
125. te 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 leq in a section title will be written to the aux file as something like mathchar 3214 This situation probably ought to be improved but for now use protect e Watch out for the character at the beginning of a dmath or similar envi ronment if it is supposed to be interpreted as mathematical content rather than the start of the environment s optional argument This is OK begin dmath lambda 1i end dmath This will not work as expected 11 begin dmath lambda 1 end dmath e Watch out for unpaired delimiter symbols in display math only C langle rangle lvert rvert 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 vert and so on are fine When a null delimiter is used as the other member of the pair left or right this warning doesn t apply e If you inadvertently apply left or right to something that is not a de limiter the error messages are likely to be a bit more confusing than usual The normal ATEX response to an error such as left is an immediate message Missing delimiter inserted When the breqn package is in u
126. ter line breaking e Zero thickness rule e Null character e vadjust The TeXbook Exercise The null character idea would be nice except it creates a mathord which then screws up math spacing for e g a following unary minus sign the vrule is trans parent to the math spacing The vadjust is the cheapest in terms of box mem ory it vanishes after the pass through T X s paragrapher It is what I would have used except that the equation contents get run through two paragraphing passes once for breaking up LR boxes and once for the real typesetting If keep glue were done with an empty vadjust it would disappear after the first pass and in particular the pre bin op adjustment for relation symbols would disappear at a line break s4 def keep glue z rule relax replicate This is a fully expandable way of making N copies of a token list Based on a post of David Kastrup to comp text tex circa January 1999 The extra application of number is needed for maximal robustness in case the repeat count N is given in some weird T X form such as E9 or count9 3 usage message H replicate 5 i h ow de doo dee so begingroup catcode amp 11 s7 gdef replicate 1 ss csname amp expandafter replicate a romannumeral number number 1 000q endcsname 89 oo endgroup replicate a o1 long def replicate a 1 2 endcsname 3 1 endcsname 3 2 8m_ fix o2 begingroup catcode amp 11 93 long gdef amp m 1 2 1 csname
127. ter open 1665 def biggl 1 mathopen bigg 1 after open 1666 def Biggl 1 mathopen Bigg 1 after open 1667 def bigggl 1 mathopen biggg 1 after open 1668 def Bigggl 1 mathopen Biggg 1 after open 1669 1570 def bigr 1 mathclose big 1 after close 1971 def Bigr 1 mathclose Big 1 after close 1672 def biggr 1 mathclose bigg 1 after close 1973 def Biggr 1 mathclose Bigg 1 after close 174 def bigggr 1 mathclose biggg 1 after close 7s def Bigggr 1 mathclose Biggg 1 after close 1676 1977 hh No change needed I think mjd 1998 12 04 1678 A def bigm mathrel big 1679 A def Bigm mathrel Big 1680 AA def biggm mathrel bigg 1681 4A def Biggm mathrel1 Bigg 1682 AA def bigggm mathrel biggg 1683 AA def Bigggm mathrel Biggg Original definition of m DeL from flexisym is as follows m DeR and m DeB are the same except for the math class number def m DeL 1 2 3 7 delimiter 4 xp delim a csname sd 1 2 3 endcsname 1 2 3 Save the existing meanings of m De LRB Define display variants of DeL DeR DeB 1684 ExplSyntax0On 1685 cS_set Npn math_dsym_DeL Nn 1 2 math_bsym_DeL Nn 1 2 after open 1686 CS_set Npn math_dsym_DeR Nn 1 2 math_bsym_DeR Nn 1 2 after close 1687 cS_set Npn math_dsym_DeB Nn 1 2 math_bsym_DeB Nn 1 2 after bidir 1688 1689 Ahhh 1690 hhhh Let m DeL m DeL let m DeR m DeR let m GDeB m DeB 1001 hhhhh def d DeL 1 2 3 7 81 after
128. thank Morten H gholm for bringing breqn forward slightly different definitions it must be loaded before breqn Below is an example of how you enable breqn to work with the widely used mathpazo package usepackage mathpazo usepackage mathpazo flexisym usepackage breqn Currently the packages mathpazo and 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 flexisym dtx for how to create a support file it is easier than one might think Contributions welcome The documentation for the package was formerly found in breqndoc It has now been added to this implementation file Below follows the contents of the original breqn documentation Not all details hold anymore but I have prioritized fixing the package 3 Todo e Handling of QED e Space between end dmath and following punctuation will prevent the punctuation from being drawn into the equation e Overriding the equation layout e Overriding the placement of the equation number e alignid option for more widely separated equations where shared alignment is desired requires two passes e Or maybe provide an alignwidths option where you give lhs rhs width in terms of ems And get feedback later on discrepancies with the actual measured contents e intertext not needed within dgroup But currently there are limi
129. the LHS is measured Opt or very small I m not entirely clear what Michael had in mind for this case whether it s an oversight or whether I ve introduced some other bug At any rate my solution is to measure the RHS accumulated in EQ box at the time of the relation and subtract that from the total size 46 The contents of an equation after the initial typesetting pass as shown by showlists This is the material on which the eq repack function operates The equation was a b left frac c sp 2 2 d right e f g The contents are shown in four parts in this figure and the next three The first part contains two line boxes one for the mathon node and one for the LHS hbox 0 0 0 0 x16383 99998 glue set 1 6384 mathon penalty 10000 glue rightskip 0 0 plus 10000 0 penalty 1 glue baselineskip 7 69446 hbox 4 30554 0 0 x16383 99998 glue set 1 63759 OML cmm m it 10 a glue 2 77771 minus 1 11108 penalty 10001 glue rightskip 0 0 plus 10000 0 penalty 2 glue lineskip 1 0 Figure 1 Preliminary equation contents part 1 47 This is the first part of the RHS up to the right where a line break has been forced so that we can break open the left right box penalty 2 glue lineskip 1 0 hbox 14 9051 9 50012 x16383 99998 glue set 1 63107 penalty 99 glue thickmuskip 2 77771 minus 1 11108 OT1 cmr m n 10 glue thickmuskip 2 77771 minus 1 11108 OML
130. toks global setbox GRP box box voidb x 1912 global let GRP label empty 1913 0 g lobal grp wdL z global grp wdR z global grp wdT z 1914 g lobal grp linewidth z global grp wdNum z 1915 g lobal let grp eqs numbered False 1916 global let grp aligned True 1917 global let grp shiftnumber False 90 iis eq prelim w19 setkeys breqn 1 1920 if grp hasNumber grp setnumber fi 1921 1922 def end dgroup 3 EQ displayinfo grp finish 1924 if grp hasNumber grp resetnumber fi 19 N 1925 If the amsmath package is not loaded the parentequation counter will not be de fined 1925 ifundefined c parentequation newcounter parentequation Init 1927 global let GRP label empty 1923 def add grp label 1929 ifx empty GRP label 19330 else GRP label global let GRP label empty 1931 fi 1932 Before sending down the equation counter to the subordinate level set the current number in EQ numbox The eq setnumber function does everything we need here If the child equations are unnumbered EQ numbox will retain the group number at the end of the group 1933 def grp setnumber 1934 global let GRP label next label global let next label empty 19335 Trick eq setnumber to doing our work for us 1936 let eq hasNumber True 1937 eq setnumber Define theparentequation equivalent to current theequation edef is nec essary to expand the curr
131. tup relax 366 307 everyvbox everyvbox emptytoks 368 let display setup relax textmath setup let textmath setup relax 369 t 370 displaystyle 371 372 def textmath setup 373 math_setup_inline_symbols a hhhh Nlet m Bin m Bin let m Rel m Rel w 30 if display everydisplay 375 hhh let symRel m symRel let symBin m symBin 376 hhhh lLet m DeL m DeL let m DeR m DeR let m DeB me DeB 377 hhhh lLet m DeA m DeA 378 hhhh let symDeL m symDeL let symDeR mO symDeR 379 hhhh let symDeB m symDeB let symDeA m symDeA 30 let left left let right right 381 382 333 ExplSyntax0ff The test ifinner is unreliable for distinguishing whether we are in a displayed formula or an inline formula any display more complex than a simple one line equation typically involves the use of displaystyle instead of So we provide a more reliable test But it might have been provided already by the amsmath package 334 ifundefined displaytrue 38 xp newif csname if display endcsname 33 everydisplay xp the everydisplay displaytrue 337 Is there any reason to maintain separate everydisplay and eqstyle 24 The dmath and dmath environments Options for the dmath and dmath environments begin dmath label eq xyz begin dmath labelprefix eq label xyz WSPR added the option for a label prefix designed to be used in the preamble like so
132. ut it doesn t support embedded verbatim because it reads the material as a macro argument To support simultaneous use of amsmath and breqn the user command intertext is left alone until we enter a breqn environment 2193 newcommand breqn intertext 1 dsuspend 1 enddsuspend Discretionary times sign Standard TEX definition serves only for inline math Should the thin space be included Not sure 2194 renewcommand 2195 if display Since eq binoffset is mu glue we can t use it directly with kern but have to measure it separately in a box 2196 setbox z hbox mathsurround z mkern eq binoffset 2197 discretionary 2198 kern the wd z textchar discretionarytimes 2199 H 2200 thinspace 2201 else 2202 discretionary thinspace textchar discretionarytimes 2203 fi 2204 This is only the symbol it can be changed to some other symbol if desired 205 newcommand discretionarytimes times This is like ref but doesn t apply font changes or other guff if the reference is undefined And it is fully expandable for use as a label value Can break with Babel if author uses active characters in label key need to address that 99 mjd 1999 01 21 206 def nref 1 xp Onref csname r 1 endcsname 207 def nref 1 2 ifx relax 1 else xp firstoftwo 1 fi 2208 hhhbhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhllhbhhh 36 Wrap up The usual endinput 2209 package 3
133. would be a disservice to gobble the star as an option of the ommand In all other contexts the chance of having a space before the star is extremely small either the command is a control word which will get no space token after it in any case because of T X s tokenization rules or it is a control symbol such as which is exceedingly unlikely to be written as by any one who really wants the to act as a modifier for the ommand 7 def ifstar 1 2 72 let tempd def tempat 1 def Otempb 2 73 futurelet tempc ifnexta 74 Utility function for reading an optional arg without skipping over any intervening spaces 7 def optarg 1 2 ifnext 1 1 2 After let foo True the test if foo evaluates to true Would rather avoid newif because it uses three csnames per Boolean variable this uses only one 76 def True 00 77 def False 01 7s def Not 1 0 ifcase 11 or xp 1 else xp O fi 79 def And 1 2 0 ifcase 1 2 xp O else xp 1 fi s0 def Or 1 2 0 ifnum 1 2 lt 101 xp O else xp 1 fi si def theb le 1 if 1 True else False fi Remove the stretch and shrink from a glue register 32 def freeze glue 1 11 1 relax Note well the intentional absence of relax at the end of the replacement text of z rule use it with care ss def z rule vrule width z no relax use with care 19 Different ways to keep a bit of glue from disappearing at the beginning of a line af
134. z 2108 2109 newenvironment darray optarg darray 210 def darray 1 7 au trace breqn debugmsg DARRAY 25 s5 55 25 25 55 55 555 Y 212 if eq group else eq prelim fi 96 Init the halign preamble to empty then unless the cols key is used to provide a non null preamble just use the default darray preamble which is a multiple lcr 2113 global let preamble empty a4 setkeys breqn 1 ais the eqstyle eq setnumber 216 ifx preamble empty global let preamble darray preamble fi 217 check mathfonts 218 let check mathfonts relax tempting but too risky 219 xp let csname string endcsname darray cr 2120 setbox z vbox bgroup 2121 everycr noalign global advance cur row ne 2122 tabskip z skip cur col z 223 global cur row z 2124 penalty ne flag for dar repack 225 halign xp bgroup preamble 2126 Assimilate following punctuation 2127 def enddarray 1 check punct or qed 2123 def end darray 2129 ifvmode else eq addpunct Mathstrut fi crcr egroup 2130 dar capture 2131 egroup 2132 The dar capture function steps back through the list of row boxes and grinds them up in the best possible way 2133 def dar capture 2134 Ah Showboxbreadth maxdimen showboxdepth99 showlists 235 eq wdL z eq wdRmax z 2136 dar repack 2137 The dar repack function is a variation of eq repack 2138 def dar rep
135. ze eqcolor eqmargin eqindent eqbinoffset eqnumside eqnumplace eqnumsep eqnumf ont eqnumform eqnumsize eqnumcolor eqlinespacing eqlineskip eqlineskiplimit eqstyle eqinterlinepenalty intereqpenalty intereqskip Record the contents of a box in the log file without stopping 157 def debug box 1 us batchmode showboxbreadth maxdimen showboxdepth99 showbox 1 1599 errorstopmode 160 Show lots of info about the material before launching into the trials 11 def eqinfo 4 12 debug box EQ copy 13 wlog EQ copy the wd EQ copy space x 164 the ht EQ copy the dp EQ copy 165 Fh 166 Check params that affect line breaking 1697 def debug parat 1s debugwr hsize the hsize parfillskip the parfillskip 19 breqn debugmsg leftskip the leftskip rightskip the rightskip 7 170 breqn debugmsg linepenalty the linepenalty adjdemerits the adjdemerits 171 breqn debugmsg pretolerance the pretolerance tolerance the tolerance 172 parindent the parindent 173 iva trace 21 The listwidth variable The dimen variable listwidth is linewidth plus leftmargin plus rightmargin which is typically less than hsize if the list depth is greater than one In case a future package will provide this variable define it only if not yet defined 175 ifundefined listwidth newdimen listwidth 176 listwidth z 22 Parameters Here follows a list of parameters needed
136. zero and height zero pinned to the upper left corner of the equation body and then print the equation body on top of it For attaching an equation number it would be much simpler to wrap the equation 15 body in the frame and from then on treat the body as a single box instead of multiple line boxes But I had a notion that it might be possible some day to support vertical stretching of the frame 16 Prelim This package doesn t work with T X 2 09 nor with other versions of ATEX earlier than 1994 12 01 1 xpackage 2 NeedsTeXFormat LaTeX2e Declare package name and date 3 RequirePackage exp13 2009 08 05 4 ProvidesExp 1Package breqn 2012 05 10 0 98b Breaking equations Regrettably breqn is internally a mess so we have to take some odd steps 5 ExplSyntax0ff 17 Package options Most options are set with the options command which calls setkeys because the standard package option mechanism doesn t provide support for key value syntax First we need to get the catcodes sorted out 6 edef breqnpopcats 7 catcode number number catcode s relax 9 AtEndOfPackage breqnpopcats 10 catcode 7 catcode _ 8 catcode 12 relax DeclareOption mathstyleoff 2 PassOptionsToPackage mathstyleoff flexisym ig Process options 14 ProcessOptions relax 18 Required packages The flexisym package makes it possible to attach extra actions to math symbols in particular mathbi

Download Pdf Manuals

image

Related Search

Related Contents

Harmony ® - Farmaline  Descargar manual en PDF  Proxima ASA UltraLight X350 User's Manual  D4110 User`s Manual  TWZ Series Oil-Fired Hot Water Boilers INSTALLATION  BM-141GE, OP22-5-1 BB-141GE, OP22-5  

Copyright © All rights reserved.
Failed to retrieve file