#
source:
breqn.dtx
@
1

Revision 1, 92.3 KB checked in by hoegholm, 6 years ago (diff) |
---|

Line | |
---|---|

1 | % \iffalse meta-comment |

2 | % |

3 | % Copyright (C) 1997-2003 by Michael J. Downes |

4 | % Copyright (C) 2007 by Morten Hoegholm <mh.ctan@gmail.com> |

5 | % |

6 | % This work may be distributed and/or modified under the |

7 | % conditions of the LaTeX Project Public License, either |

8 | % version 1.3 of this license or (at your option) any later |

9 | % version. The latest version of this license is in |

10 | % http://www.latex-project.org/lppl.txt |

11 | % and version 1.3 or later is part of all distributions of |

12 | % LaTeX version 2005/12/01 or later. |

13 | % |

14 | % This work has the LPPL maintenance status "maintained". |

15 | % |

16 | % This Current Maintainer of this work is Morten Hoegholm. |

17 | % |

18 | % This work consists of the main source file breqn.dtx |

19 | % and the derived files |

20 | % breqn.sty, breqn.pdf, breqn.ins, breqn.drv. |

21 | % |

22 | % Distribution: |

23 | % CTAN:macros/latex/contrib/mh/breqn.dtx |

24 | % CTAN:macros/latex/contrib/mh/breqn.pdf |

25 | % |

26 | % Unpacking: |

27 | % (a) If mathstyle.ins is present: |

28 | % tex breqn.ins |

29 | % (b) Without breqn.ins: |

30 | % tex breqn.dtx |

31 | % (c) If you insist on using LaTeX |

32 | % latex \let\install=y\input{breqn.dtx} |

33 | % (quote the arguments according to the demands of your shell) |

34 | % |

35 | % Documentation: |

36 | % (a) If breqn.drv is present: |

37 | % latex breqn.drv |

38 | % (b) Without breqn.drv: |

39 | % latex breqn.dtx; ... |

40 | % The class ltxdoc loads the configuration file ltxdoc.cfg |

41 | % if available. Here you can specify further options, e.g. |

42 | % use A4 as paper format: |

43 | % \PassOptionsToClass{a4paper}{article} |

44 | % |

45 | % Programm calls to get the documentation (example): |

46 | % pdflatex breqn.dtx |

47 | % makeindex -s gind.ist breqn.idx |

48 | % pdflatex breqn.dtx |

49 | % makeindex -s gind.ist breqn.idx |

50 | % pdflatex breqn.dtx |

51 | % |

52 | % Installation: |

53 | % TDS:tex/latex/mh/breqn.sty |

54 | % TDS:doc/latex/mh/breqn.pdf |

55 | % TDS:source/latex/mh/breqn.dtx |

56 | % |

57 | %<*ignore> |

58 | \begingroup |

59 | \def\x{LaTeX2e} |

60 | \expandafter\endgroup |

61 | \ifcase 0\ifx\install y1\fi\expandafter |

62 | \ifx\csname processbatchFile\endcsname\relax\else1\fi |

63 | \ifx\fmtname\x\else 1\fi\relax |

64 | \else\csname fi\endcsname |

65 | %</ignore> |

66 | %<*install> |

67 | \input docstrip.tex |

68 | \Msg{************************************************************************} |

69 | \Msg{* Installation} |

70 | \Msg{* Package: breqn 2007/12/02 v0.93 Breqn (MH)} |

71 | \Msg{************************************************************************} |

72 | |

73 | \keepsilent |

74 | \askforoverwritefalse |

75 | |

76 | \preamble |

77 | |

78 | This is a generated file. |

79 | |

80 | Copyright (C) 1997-2003 by Michael J. Downes |

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

82 | |

83 | This work may be distributed and/or modified under the |

84 | conditions of the LaTeX Project Public License, either |

85 | version 1.3 of this license or (at your option) any later |

86 | version. The latest version of this license is in |

87 | http://www.latex-project.org/lppl.txt |

88 | and version 1.3 or later is part of all distributions of |

89 | LaTeX version 2005/12/01 or later. |

90 | |

91 | This work has the LPPL maintenance status "maintained". |

92 | |

93 | This Current Maintainer of this work is Morten Hoegholm. |

94 | |

95 | This work consists of the main source file breqn.dtx |

96 | and the derived files |

97 | breqn.sty, breqn.pdf, breqn.ins, breqn.drv. |

98 | |

99 | \endpreamble |

100 | |

101 | \generate{% |

102 | \file{breqn.ins}{\from{breqn.dtx}{install}}% |

103 | \file{breqn.drv}{\from{breqn.dtx}{driver}}% |

104 | \usedir{tex/latex/mh}% |

105 | \file{breqn.sty}{\from{breqn.dtx}{package}}% |

106 | } |

107 | |

108 | \obeyspaces |

109 | \Msg{************************************************************************} |

110 | \Msg{*} |

111 | \Msg{* To finish the installation you have to move the following} |

112 | \Msg{* file into a directory searched by TeX:} |

113 | \Msg{*} |

114 | \Msg{* breqn.sty} |

115 | \Msg{*} |

116 | \Msg{* To produce the documentation run the file `breqn.drv'} |

117 | \Msg{* through LaTeX.} |

118 | \Msg{*} |

119 | \Msg{* Happy TeXing!} |

120 | \Msg{*} |

121 | \Msg{************************************************************************} |

122 | |

123 | \endbatchfile |

124 | %</install> |

125 | %<*ignore> |

126 | \fi |

127 | %</ignore> |

128 | %<*driver> |

129 | \NeedsTeXFormat{LaTeX2e} |

130 | \ProvidesFile{breqn.drv}% |

131 | [2007/12/02 v0.95 breqn (MH)] |

132 | \documentclass{ltxdoc} |

133 | |

134 | \usepackage{verbatim} |

135 | |

136 | \makeatletter |

137 | |

138 | {\catcode`\%=12 |

139 | \long\gdef\@gobble@percent@space#1{\ifx #1%\expandafter\@gobble\else\expandafter#1\fi}} |

140 | |

141 | |

142 | \AtBeginDocument{\def\verbatim@processline{\expandafter\check@percent |

143 | \the\verbatim@line\par}} |

144 | \newwrite\tmp@out |

145 | \newcounter{xio} |

146 | \newenvironment{xio}{% example input and output |

147 | \par\addvspace\bigskipamount |

148 | \hbox{\itshape |

149 | \refstepcounter{xio}\kern-\p@ Example \thexio}\@nobreaktrue |

150 | \immediate\openout\tmp@out\jobname.tmp \relax |

151 | \begingroup |

152 | \let\do\@makeother\dospecials\catcode`\^^M\active |

153 | \def\verbatim@processline{ |

154 | \immediate\write\tmp@out{\expandafter\@gobble@percent@space |

155 | \the\verbatim@line}}% |

156 | \verbatim@start |

157 | }{% |

158 | \immediate\closeout\tmp@out |

159 | \@verbatim\frenchspacing\@vobeyspaces |

160 | \@@input \jobname.tmp \relax |

161 | \endgroup |

162 | \par\medskip |

163 | \noindent\ignorespaces |

164 | \@@input \jobname.tmp \relax |

165 | \par\medskip |

166 | } |

167 | \makeatother |

168 | |

169 | \hfuzz2pc \vbadness9999 \hbadness5000 |

170 | \def\AmS{{\protect\usefont{OMS}{cmsy}{m}{n}% |

171 | A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}} |

172 | \def\latex/{{\protect\LaTeX}} |

173 | \def\amslatex/{{\protect\AmS-\protect\LaTeX}} |

174 | \def\tex/{{\protect\TeX}} |

175 | \def\amstex/{{\protect\AmS-\protect\TeX}} |

176 | |

177 | \newcommand{\ntt}{\normalfont\ttfamily} |

178 | \chardef\ttbackslash=92 |

179 | \DeclareRobustCommand{\cs}[1]{{\ntt\ttbackslash#1}} |

180 | \let\cn=\cs |

181 | \DeclareRobustCommand{\pkg}[1]{{\ntt#1}} |

182 | \let\opt=\pkg \let\env=\pkg \let\fn=\pkg |

183 | |

184 | \newcommand\dash{\textemdash} |

185 | \newcommand\dbslash[1]{\texttt{\string\\}} |

186 | \newcommand\thepkg[1]{the \pkg{breqn} package} |

187 | |

188 | \providecommand\dotsc{\ldots} |

189 | \providecommand\eqref[1]{(\ref{#1})} |

190 | |

191 | \providecommand{\qq}[1]{\textquotedblleft#1\textquotedblright} |

192 | |

193 | |

194 | \usepackage[cmbase]{flexisym} |

195 | \usepackage{breqn} |

196 | |

197 | \begin{document} |

198 | \DocInput{breqn.dtx} |

199 | \end{document} |

200 | %</driver> |

201 | % \fi |

202 | % |

203 | % \title{The \textsf{breqn} package} |

204 | % \date{2007/12/02 v0.95} |

205 | % \author{Morten H\o gholm \\\texttt{mh.ctan@gmail.com}} |

206 | % |

207 | % \maketitle |

208 | % |

209 | % \part*{User's guide} |

210 | % |

211 | % |

212 | % |

213 | % \section{To do} |

214 | % |

215 | % \begin{itemize} |

216 | % \item Handling of QED |

217 | % \item Space between \verb'\end{dmath}' and following punctuation will |

218 | % prevent the punctuation from being drawn into the equation. |

219 | % \item Overriding the equation layout |

220 | % \item Overriding the placement of the equation number |

221 | % \item \qq{alignid} option for more widely separated equations where |

222 | % shared alignment is desired (requires two passes) |

223 | % \item Or maybe provide an \qq{alignwidths} option where you give |

224 | % lhs/rhs width in terms of ems? And get feedback later on discrepancies |

225 | % with the actual measured contents? |

226 | % \item \cn{intertext} not needed within dgroup! But currently there are |

227 | % limitations on floating objects within dgroup. |

228 | % \item \verb'align={1}' or 2, 3, 4 expressing various levels of demand |

229 | % for group-wide alignment. Level 4 means force alignment even if some |

230 | % lines then have to run over the right margin! Level 1, the default, |

231 | % means first break LHS-RHS equations as if it occurred by itself, then |

232 | % move them left or right within the current line width to align them if |

233 | % possible. Levels 2 and 3 mean try harder to align but give up if |

234 | % overfull lines result. |

235 | % \item Need an \cs{hshift} command to help with alignment of |

236 | % lines broken at a discretionary times sign. Also useful for adjusting |

237 | % inside-delimiter breaks. |

238 | % \end{itemize} |

239 | % |

240 | % \section{Introduction} |

241 | % |

242 | % The \pkg{breqn} package for \latex/ provides solutions to a number of |

243 | % common difficulties in writing displayed equations and getting |

244 | % high-quality output. For example, it is a well-known inconvenience that |

245 | % if an equation must be broken into more than one line, \cn{left} \dots\ |

246 | % \cn{right} constructs cannot span lines. The \pkg{breqn} package makes |

247 | % them work as one would expect whether or not there is an intervening |

248 | % line break. |

249 | % |

250 | % The single most ambitious goal of the \pkg{breqn} package, however, is |

251 | % to support automatic linebreaking of displayed equations. Such |

252 | % linebreaking cannot be done without substantial changes under the hood |

253 | % in the way math formulas are processed. For this reason, especially in |

254 | % the alpha release, users should proceed with care and keep an eye out |

255 | % for unexpected glitches or side effects. |

256 | % |

257 | % \section{Principal features} |

258 | % The principal features of the \pkg{breqn} package are: |

259 | % \begin{description} |

260 | % |

261 | % \item[semantically oriented structure] The way in which compound |

262 | % displayed formulas are subdivided matches the logical structure more |

263 | % closely than, say, the standard \env{eqnarray} environment. Separate |

264 | % equations in a group of equations are written as separate environments |

265 | % instead of being bounded merely by \dbslash/ commands. Among other |

266 | % things, this clears up a common problem of wrong math symbol spacing at |

267 | % the beginning of continuation lines. It also makes it possible to |

268 | % specify different vertical space values for the space between lines of a |

269 | % long, broken equation and the space between separate equations in a |

270 | % group of equations. |

271 | % |

272 | % \item[automatic line breaking] Overlong equations will be broken |

273 | % automatically to the prevailing column width, and continuation lines |

274 | % will be indented following standard conventions. |

275 | % |

276 | % \item[line breaks within delimiters] Line breaks within \cn{left} \dots\ |

277 | % \cn{right} delimiters work in a natural way. Line breaks can be |

278 | % forbidden below a given depth of delimiter nesting through a package |

279 | % option. |

280 | % |

281 | % \item[mixed math and text] Display equations that contain mixed |

282 | % math and text, or even text only, are handled naturally by means of a |

283 | % \env{dseries} environment that starts out in text mode instead of math |

284 | % mode. |

285 | % |

286 | % \item[ending punctuation] The punctuation at the end of a displayed |

287 | % equation can be handled in a natural way that makes it easier to promote |

288 | % or demote formulas from\slash to inline math, and to apply special |

289 | % effects such as adding space before the punctuation. |

290 | % |

291 | % \item[flexible numbering] Equation numbering is handled in a natural |

292 | % way, with all the flexibility of the \pkg{amsmath} package and with no |

293 | % need for a special \cn{nonumber} command. |

294 | % |

295 | % \item[special effects] It is easy to apply special effects to individual |

296 | % displays, e.g., changing the type size or adding a frame. |

297 | % |

298 | % \item[using available space] Horizontal shrink is made use of |

299 | % whenever feasible. With most other equation macros it is frozen when it |

300 | % occurs between \cn{left} \dots\ \cn{right} delimiters, or in any sort of |

301 | % multiline structure, so that some expressions require two lines that would |

302 | % otherwise fit on one. |

303 | % |

304 | % \item[high-quality spacing] The \cn{abovedisplayshortskip} is used when |

305 | % applicable (other equation macros fail to apply it in equations of more |

306 | % than one line). |

307 | % |

308 | % \item[abbreviations] Unlike the \pkg{amsmath} equation environments, the |

309 | % \pkg{breqn} environments can be called through user-defined abbreviations |

310 | % such as \cn{beq} \dots\ \cn{eeq}. |

311 | % |

312 | % \end{description} |

313 | % |

314 | % \section{Shortcomings of the package} |

315 | % The principal known deficiencies of the \pkg{breqn} package are: |

316 | % |

317 | % \subsection{Incompatibilities} As it pushes the envelope |

318 | % of what is possible within the context of \latex/2e, \thepkg/ will tend |

319 | % to break other packages when used in combination with them, or to fail |

320 | % itself, when there are any areas of internal overlap; successful use may |

321 | % in some cases depend on package loading order. |

322 | % |

323 | % \subsection{Indention of delimited fragments} When line breaks within |

324 | % delimiters are involved, the automatic indention of continuation lines |

325 | % is likely to be unsatisfactory and need manual adjustment. I don't see |

326 | % any easy way to provide a general solution for this, though I have some |

327 | % ideas on how to attain partial improvements. |

328 | % |

329 | % \subsection{Math symbol subversion} |

330 | % In order for automatic line breaking to work, the operation of all the |

331 | % math symbols of class 2, 3, 4, and 5 must be altered (relations, binary |

332 | % operators, opening delimiters, closing delimiters). This is done by an |

333 | % auxiliary package \pkg{flexisym}. As long as you stick to the advertised |

334 | % \latex/ interface for defining math symbols (\cn{DeclareMathSymbol}), |

335 | % things should work OK most of the time. Any more complex math symbol |

336 | % setup is quite likely to quarrel with the \pkg{flexisym} package. |

337 | % See Section~\ref{flexisym} for further information. |

338 | % |

339 | % \subsection{Subscripts and superscripts} |

340 | % |

341 | % Because of the changes to math symbols of class 2--5, writing certain |

342 | % combinations such as \verb'^+' or \verb'_\pm' or \verb'^\geq' without |

343 | % braces would lead to error messages; (The problem described here |

344 | % already exists in standard \latex/ to a lesser extent, as you may know |

345 | % if you ever tried \verb'^\neq' or \verb'^\cong'; and indeed there are |

346 | % no examples in the \latex/ book to indicate any sanction for omitting |

347 | % braces around a subscript or superscript.) |

348 | % |

349 | % The \pkg{flexisym} package therefore calls, as of version 0.92, another |

350 | % package called \pkg{mathstyle} which turns \verb'^' and \verb'_' into |

351 | % active characters. This is something that I believe is desirable in any |

352 | % case, in the long run, because having a proper mathstyle variable |

353 | % eliminates some enormous burdens that affect almost any |

354 | % nontrivial math macros, as well as many other things where the |

355 | % connection is not immediately obvious, e.g., the \latex/ facilities for |

356 | % loading fonts on demand. |

357 | % |

358 | % Not that this doesn't introduce new and interesting problems of its |

359 | % own---for example, you don't want to put usepackage statements |

360 | % after flexisym for any package that refers to, e.g., \verb'^^J' or |

361 | % \verb'^^M' |

362 | % internally (too bad that the \latex/ package loading code does not |

363 | % include automatic defenses to ensure normal catcodes in the interior of |

364 | % a package; but it only handles the \verb'@' character). |

365 | % |

366 | % But I took a random AMS journal article, with normal end-user kind of |

367 | % \latex/ writing, did some straightforward substitutions to change all |

368 | % the equations into dmath environments, and ran it with active math |

369 | % sub/sup: everything worked OK. This suggests to me that it can work in |

370 | % the real world, without an impossible amount of compatibility work. |

371 | % |

372 | % \section{Incomplete} |

373 | % In addition, in the \textbf{alpha release [1997/10/30]} the following |

374 | % gaps remain to be filled in: |

375 | % \begin{description} |

376 | % \item[documentation] |

377 | % The documentation could use amplification, especially more |

378 | % illustrations, and I have undoubtedly overlooked more than a few errors. |

379 | % |

380 | % \item[group alignment] The algorithm for doing alignment |

381 | % of mathrel symbols across equations in a \env{dgroup} environment |

382 | % needs work. Currently the standard and \opt{noalign} alternatives |

383 | % produce the same output. |

384 | % |

385 | % \item[single group number] When a \env{dgroup} has a group number and |

386 | % the individual equations are unnumbered, the handling and placement of |

387 | % the group number aren't right. |

388 | % |

389 | % \item[group frame] Framing a group doesn't work, you might be able to |

390 | % get frames on the individual equations at best. |

391 | % |

392 | % \item[group brace] The \opt{brace} option for \env{dgroup} is intended |

393 | % to produce a large brace encompassing the whole group. This hasn't been |

394 | % implemented yet. |

395 | % |

396 | % \item[darray environment] The \env{darray} environment is unfinished. |

397 | % |

398 | % \item[dseries environment] The syntax and usage for the \env{dseries} |

399 | % environment are in doubt and may change. |

400 | % |

401 | % \item[failure arrangements] When none of the line-breaking passes for a |

402 | % \env{dmath} environment succeeds\dash i.e., at least one line is |

403 | % overfull\dash the final arrangement is usually rather poor. A better |

404 | % fall-back arrangement in the failure case is needed. |

405 | % |

406 | % \end{description} |

407 | % |

408 | % \section{Package options} |

409 | % |

410 | % Many of the package options for \thepkg/ are the same as options of the |

411 | % \env{dmath} or \env{dgroup} environments, and some of them require an |

412 | % argument, which is something that cannot be done through the normal |

413 | % package option mechanism. Therefore most of the \pkg{breqn} package |

414 | % options are designed to be set with a \cn{setkeys} command after the |

415 | % package is loaded. For example, to load the package and set the |

416 | % maximum delimiter nesting depth for line breaks to~1: |

417 | % \begin{verbatim} |

418 | % \usepackage{breqn} |

419 | % \setkeys{breqn}{breakdepth={1}} |

420 | % \end{verbatim} |

421 | % |

422 | % See the discussion of environment options, Section~\ref{envopts}, for |

423 | % more information. |

424 | % |

425 | % One package option that may be of interest to \tex/nicians is the |

426 | % \opt{debug} option; this activates some debugging statements embedded in |

427 | % the code of the alpha release which trace measuring activities related |

428 | % to line breaking. |

429 | % |

430 | % \section{Environments and commands} |

431 | % \subsection{Environments} |

432 | % All of the following environments take an optional argument for |

433 | % applying local effects such as changing the typesize or adding a |

434 | % frame to an individual equation. |

435 | % |

436 | % \begin{description} |

437 | % \item[\env{dmath}] Like \env{equation} but supports line breaking and variant |

438 | % numbers. |

439 | % |

440 | % \item[\env{dmath*}] Unnumbered; like \env{displaymath} but supports line |

441 | % breaking |

442 | % |

443 | % \item[\env{dseries}] Like \env{equation} but starts out in text mode; |

444 | % intended for series of mathematical expressions of the form `A, B, and |

445 | % C'. As a special feature, if you use |

446 | % \begin{verbatim} |

447 | % \begin{math} ... \end{math} |

448 | % \end{verbatim} |

449 | % for each expression in the series, a suitable amount of inter-expression |

450 | % space will be automatically added. This is a small step in the direction of |

451 | % facilitating conversion of display math to inline math, and vice versa: If |

452 | % you write a display as |

453 | % \begin{verbatim} |

454 | % \begin{dseries} |

455 | % \begin{math}A\end{math}, |

456 | % \begin{math}B\end{math}, |

457 | % and |

458 | % \begin{math}C\end{math}. |

459 | % \end{dseries} |

460 | % \end{verbatim} |

461 | % then conversion to inline form is simply a matter of removing the |

462 | % \verb'\begin{dseries}' and \verb'\end{dseries}' lines; the contents of the |

463 | % display need no alterations. |

464 | % |

465 | % It would be nice to provide the same feature for \verb'$' notation but |

466 | % there is no easy way to do that because the \verb'$' function has no |

467 | % entry point to allow changing what happens before math mode is entered. |

468 | % Making it work would therefore require turning \verb'$' into an active |

469 | % character, something that I hesitate to do in a \latex/2e context. |

470 | % |

471 | % \item[\env{dseries*}] Unnumbered variant of \env{dseries} |

472 | % |

473 | % \item[\env{dgroup}] Like the \env{align} environment of \pkg{amsmath}, |

474 | % but with each constituent equation wrapped in a \env{dmath}, |

475 | % \env{dmath*}, \env{dseries}, or \env{dseries*} environment instead of being |

476 | % separated by \dbslash/. The equations are numbered with a group number. |

477 | % When the constituent environments are the numbered forms (\env{dmath} or |

478 | % \env{dseries}) they automatically switch to `subequations'-style |

479 | % numbering, i.e., something like (3a), (3b), (3c), \dots, depending on |

480 | % the current form of non-grouped equation numbers. See also |

481 | % \env{dgroup*}. |

482 | % |

483 | % \item[\env{dgroup*}] Unnumbered variant of \env{dgroup}. If the |

484 | % constituent environments are the numbered forms, they get normal |

485 | % individual equation numbers, i.e., something like (3), (4), (5), \dots~. |

486 | % |

487 | % \item[\env{darray}] Similar to \env{eqnarray} but with an argument like |

488 | % \env{array} for giving column specs. Automatic line breaking is not |

489 | % done here. |

490 | % |

491 | % \item[\env{darray*}] Unnumbered variant of \env{darray}, rather like |

492 | % \env{array} except in using \cn{displaystyle} for all column |

493 | % entries. |

494 | % |

495 | % \item[\env{dsuspend}] Suspend the current display in order to print some |

496 | % text, without loss of the alignment. There is also a command form of |

497 | % the same thing, \cn{intertext}. |

498 | % \end{description} |

499 | % |

500 | % \subsection{Commands} |

501 | % |

502 | % The commands provided by \thepkg/ are: |

503 | % \begin{description} |

504 | % \item[\cn{condition}] This command is used for |

505 | % a part of a display which functions as a condition on the main |

506 | % assertion. For example: |

507 | % \begin{verbatim} |

508 | % \begin{dmath} |

509 | % f(x)=\frac{1}{x} \condition{for $x\neq 0$} |

510 | % \end{dmath}. |

511 | % \end{verbatim} |

512 | % \begin{dmath} |

513 | % f(x)=\frac{1}{x} \condition{for $x\neq 0$} |

514 | % \end{dmath}. |

515 | % The \cn{condition} command automatically switches to text mode (so that |

516 | % interword spaces function the way they should), puts in a comma, and |

517 | % adds an appropriate amount of space. To facilitate promotion\slash |

518 | % demotion of formulas, \cn{condition} \qq{does the right thing} if used |

519 | % outside of display math. |

520 | % |

521 | % To substitute a different punctuation mark instead of the default comma, |

522 | % supply it as an optional argument for the \cn{condition} command: |

523 | % \begin{verbatim} |

524 | % \condition[;]{...} |

525 | % \end{verbatim} |

526 | % (Thus, to get no punctuation: \verb'\condition[]{...}'.) |

527 | % |

528 | % For conditions that contain no text, you can use the starred form of the |

529 | % command, which means to stay in math mode: |

530 | % \begin{verbatim} |

531 | % \begin{dmath} |

532 | % f(x)=\frac{1}{x} \condition*{x\neq 0} |

533 | % \end{dmath}. |

534 | % |

535 | % If your material contains a lot of conditions like these, you might like |

536 | % to define shorter abbreviations, e.g., |

537 | % \begin{verbatim} |

538 | % \newcommand{\mc}{\condition*}% math condition |

539 | % \newcommand{\tc}{\condition}% text condition |

540 | % \end{verbatim} |

541 | % But \thepkg/ refrains from predefining such abbreviations in order that |

542 | % they may be left to the individual author's taste. |

543 | % |

544 | % \item[\cn{hiderel}] In a compound equation it is sometimes desired to |

545 | % use a later relation symbol as the alignment point, rather than the |

546 | % first one. To do this, mark all the relation symbols up to the desired |

547 | % one with \cn{hiderel}: |

548 | % \begin{verbatim} |

549 | % T(n) \hiderel{\leq} T(2^n) \leq c(3^n - 2^n) ... |

550 | % \end{verbatim} |

551 | % \end{description} |

552 | % |

553 | % \section{Various environment options}\label{envopts} |

554 | % |

555 | % The following options are recognized for the \env{dmath}, \env{dgroup}, |

556 | % \env{darray}, and \env{dseries} environments; some of the options do not |

557 | % make sense for all of the environments, but if an option is used where |

558 | % not applicable it is silently ignored rather than treated as an error. |

559 | % |

560 | % \begin{verbatim} |

561 | % \begin{dmath}[style={\small}] |

562 | % \begin{dmath}[number={BV}] |

563 | % \begin{dmath}[label={xyz}] |

564 | % \begin{dmath}[relindent={1em}] |

565 | % \begin{dmath}[compact] |

566 | % \begin{dmath}[spread={1pt}] |

567 | % \begin{dmath}[frame] |

568 | % \begin{dmath}[frame={1pt},framesep={2pt}] |

569 | % \begin{dmath}[background={red}] |

570 | % \begin{dmath}[color={purple}] |

571 | % \begin{dmath}[breakdepth={0}] |

572 | % \end{verbatim} |

573 | % |

574 | % Use the \opt{style} option to change the type size of an individual |

575 | % equation. This option can also serve as a catch-all option for |

576 | % altering the equation style in other ways; the contents are simply |

577 | % executed directly within the context of the equation. |

578 | % |

579 | % Use the \opt{number} option if you want the number for a particular |

580 | % equation to fall outside of the usual sequence. If this option is used |

581 | % the equation counter is not incremented. If for some reason you need to |

582 | % increment the counter and change the number at the same time, use the |

583 | % \opt{style} option in addition to the \opt{number} option: |

584 | % \begin{verbatim} |

585 | % style={\refstepcounter{equation}} |

586 | % \end{verbatim} |

587 | % |

588 | % Use of the normal \cn{label} command instead of the \opt{label} option |

589 | % works, I think, most of the time (untested). |

590 | % |

591 | % Use the \opt{relindent} option to specify something other than the |

592 | % default amount for the indention of relation symbols. The default is |

593 | % 2em. |

594 | % |

595 | % Use the \opt{compact} option in compound equations to inhibit line |

596 | % breaks at relation symbols. By default a line break will be taken before |

597 | % each relation symbol except the first one. With the \opt{compact} option |

598 | % \latex/ will try to fit as much material as possible on each line, but |

599 | % breaks at relation symbols will still be preferred over breaks at binary |

600 | % operator symbols. |

601 | % |

602 | % Use the \opt{spread} option to increase (or decrease) the amount of |

603 | % interline space in an equation. See the example given above. |

604 | % |

605 | % Use the \opt{frame} option to produce a frame around the body of the |

606 | % equation. The thickness of the frame can optionally be specified by |

607 | % giving it as an argument of the option. The default thickness is |

608 | % \cn{fboxrule}. |

609 | % |

610 | % Use the \opt{framesep} option to change the amount of space separating |

611 | % the frame from what it encloses. The default space is \cn{fboxsep}. |

612 | % |

613 | % Use the \opt{background} option to produce a colored background for the |

614 | % equation body. The \pkg{breqn} package doesn't automatically load the |

615 | % \pkg{color} package, so this option won't work unless you remember |

616 | % to load the \pkg{color} package yourself. |

617 | % |

618 | % Use the \opt{color} option to specify a different color for the contents |

619 | % of the equation. Like the \opt{background} option, this doesn't work if |

620 | % you forgot to load the \pkg{color} package. |

621 | % |

622 | % Use the \opt{breakdepth} option to change the level of delimiter nesting |

623 | % to which line breaks are allowed. To prohibit line breaks within |

624 | % delimiters, set this to 0: |

625 | % \begin{verbatim} |

626 | % \begin{dmath}[breakdepth={0}] |

627 | % \end{verbatim} |

628 | % The default value for breakdepth is 2. Even when breaks are allowed |

629 | % inside delimiters, they are marked as less desirable than breaks outside |

630 | % delimiters. Most of the time a break will not be taken within delimiters |

631 | % until the alternatives have been exhausted. |

632 | % |

633 | % Options for the \env{dgroup} environment: all of the above, and also |

634 | % \begin{verbatim} |

635 | % \begin{dgroup}[noalign] |

636 | % \begin{dgroup}[brace] |

637 | % \end{verbatim} |

638 | % |

639 | % By default the equations in a \env{dgroup} are mutually aligned on their |

640 | % relation symbols ($=$, $<$, $\geq$, and the like). With the |

641 | % \opt{noalign} option each equation is placed individually without |

642 | % reference to the others. |

643 | % |

644 | % The \opt{brace} option means to place a large brace encompassing the |

645 | % whole group on the same side as the equation number. |

646 | % |

647 | % Options for the \env{darray} environment: all of the above (where |

648 | % sensible), and also |

649 | % \begin{verbatim} |

650 | % \begin{darray}[cols={lcr@{\hspace{2em}}lcr}] |

651 | % \end{verbatim} |

652 | % The value of the \opt{cols} option for the darray environment should be |

653 | % a series of column specs as for the \env{array} environment, with the |

654 | % following differences: |

655 | % \begin{itemize} |

656 | % \item For l, c, and r what you get is not text, but math, and |

657 | % displaystyle math at that. To get text you must use a 'p' column |

658 | % specifier, or put an \cn{mbox} in each of the individual cells. |

659 | % |

660 | % \item Vertical rules don't connect across lines. |

661 | % \end{itemize} |

662 | % |

663 | % \section{The \pkg{flexisym} package}\label{flexisym} |

664 | % |

665 | % The \pkg{flexisym} package does some radical changes in the setup for |

666 | % math symbols to allow their definitions to change dynamically throughout |

667 | % a document. The \pkg{breqn} package uses this to make symbols of classes |

668 | % 2, 3, 4, 5 run special functions inside an environment such as |

669 | % \env{dmath} that provide the necessary support for automatic line |

670 | % breaking. |

671 | % |

672 | % The method used to effect these changes is to change the definitions of |

673 | % \cn{DeclareMathSymbol} and \cn{DeclareMathDelimiter}, and then |

674 | % re-execute the standard set of \latex/ math symbol definitions. |

675 | % Consequently, additional mathrel and mathbin symbols defined by other |

676 | % packages will get proper line-breaking behavior if the other package is |

677 | % loaded after the \pkg{flexisym} package and the symbols are defined |

678 | % through the standard interface. |

679 | % |

680 | % \section{Caution! Warning!} |

681 | % Things to keep in mind when writing documents with \thepkg/: |

682 | % \begin{itemize} |

683 | % |

684 | % \item The notation $:=$ must be written with the command \cs{coloneq}. |

685 | % Otherwise the $:$ and the $=$ will be treated as two separate relation |

686 | % symbols with an \qq{empty RHS} between them, and they will be printed |

687 | % on separate lines. |

688 | % |

689 | % \item Watch out for constructions like \verb'^+' where a single binary |

690 | % operator or binary relation symbol is subscripted or superscripted. When |

691 | % the \pkg{breqn} or \pkg{flexisym} package is used, braces are mandatory |

692 | % in such constructions: \verb'^{+}'. This applies for both display and |

693 | % in-line math. |

694 | % |

695 | % \item If you want \latex/ to make intelligent decisions about line |

696 | % breaks when vert bars are involved, use proper pairing versions of the |

697 | % vert-bar symbols according to context: \verb'\lvert n\rvert' instead of |

698 | % \verb'|n|'. With the nondirectional \verb'|' there is no way for \latex/ |

699 | % to reliably deduce which potential breakpoints are inside delimiters |

700 | % (more highly discouraged) and which are not. |

701 | % |

702 | % \item If you use the \pkg{german} package or some other package that |

703 | % turns double quote \verb'"' into a special character, you may encounter |

704 | % some problems with named math symbols of type mathbin, mathrel, |

705 | % mathopen, or mathclose in moving arguments. For example, \cn{leq} in a |

706 | % section title will be written to the \fn{.aux} file as something like |

707 | % \verb'\mathchar "3214'. This situation probably ought to be improved, |

708 | % but for now use \cn{protect}. |

709 | % |

710 | % \item Watch out for the \texttt{[} character at the beginning of a |

711 | % \env{dmath} or similar environment, if it is supposed to be interpreted |

712 | % as mathematical content rather than the start of the environment's |

713 | % optional argument. |

714 | % |

715 | % This is OK: |

716 | % \begin{verbatim} |

717 | % \begin{dmath} |

718 | % [\lambda,1]... |

719 | % \end{dmath} |

720 | % \end{verbatim} |

721 | % This will not work as expected: |

722 | % \begin{verbatim} |

723 | % \begin{dmath}[\lambda,1]...\end{dmath} |

724 | % \end{verbatim} |

725 | % |

726 | % \item Watch out for unpaired delimiter symbols (in display math only): |

727 | % \begin{verbatim} |

728 | % ( ) [ ] \langle \rangle \{ \} \lvert \rvert ... |

729 | % \end{verbatim} |

730 | % If an open delimiter is used without a close delimiter, or vice versa, |

731 | % it is normally harmless but may adversely affect line breaking. This is only |

732 | % for symbols that have a natural left or right directionality. Unpaired |

733 | % \cn{vert} and so on are fine. |

734 | % |

735 | % When a null delimiter is used as the other member of the pair |

736 | % (\verb'\left.' or \verb'\right.') this warning doesn't apply. |

737 | % |

738 | % \item If you inadvertently apply \cn{left} or \cn{right} to something |

739 | % that is not a delimiter, the error messages are likely to be a bit |

740 | % more confusing than usual. The normal \latex/ response to an error such |

741 | % as |

742 | % \begin{verbatim} |

743 | % \left + |

744 | % \end{verbatim} |

745 | % is an immediate message |

746 | % \begin{verbatim} |

747 | % ! Missing delimiter (. inserted). |

748 | % \end{verbatim} |

749 | % When \thepkg/ is in use, \latex/ will fail to realize anything is wrong |

750 | % until it hits the end of the math formula, or a closing delimiter |

751 | % without a matching opening delimiter, and then the first message is an |

752 | % apparently pointless |

753 | % \begin{verbatim} |

754 | % ! Missing \endgroup inserted. |

755 | % \end{verbatim} |

756 | % |

757 | % \end{itemize} |

758 | % |

759 | % \section{Examples} |

760 | % |

761 | % \renewcommand\theequation{\thesection.\arabic{equation}} |

762 | % % Knuth, SNA p74 |

763 | % \begin{xio} |

764 | % Replace $j$ by $h-j$ and by $k-j$ in these sums to get [cf.~(26)] |

765 | % \begin{dmath}[label={sna74}] |

766 | % \frac{1}{6} \left(\sigma(k,h,0) +\frac{3(h-1)}{h}\right) |

767 | % +\frac{1}{6} \left(\sigma(h,k,0) +\frac{3(k-1)}{k}\right) |

768 | % =\frac{1}{6} \left(\frac{h}{k} +\frac{k}{h} +\frac{1}{hk}\right) |

769 | % +\frac{1}{2} -\frac{1}{2h} -\frac{1}{2k}, |

770 | % \end{dmath} |

771 | % which is equivalent to the desired result. |

772 | % \end{xio} |

773 | % |

774 | % % Knuth, SNA 4.6.2, p387 |

775 | % \begin{xio} |

776 | % \newcommand\mx[1]{\begin{math}#1\end{math}}% math expression |

777 | % % |

778 | % Now every column which has no circled entry is completely zero; |

779 | % so when $k=6$ and $k=7$ the algorithm outputs two more vectors, |

780 | % namely |

781 | % \begin{dseries}[frame] |

782 | % \mx{v^{[2]} =(0,5,5,0,9,5,1,0)}, |

783 | % \mx{v^{[3]} =(0,9,11,9,10,12,0,1)}. |

784 | % \end{dseries} |

785 | % From the form of the matrix $A$ after $k=5$, it is evident that |

786 | % these vectors satisfy the equation $vA =(0,\dotsc,0)$. |

787 | % \end{xio} |

788 | % |

789 | % \begin{xio} |

790 | % \begin{dmath*} |

791 | % T(n) \hiderel{\leq} T(2^{\lceil\lg n\rceil}) |

792 | % \leq c(3^{\lceil\lg n\rceil} |

793 | % -2^{\lceil\lg n\rceil}) |

794 | % <3c\cdot3^{\lg n} |

795 | % =3c\,n^{\lg3} |

796 | % \end{dmath*}. |

797 | % \end{xio} |

798 | % |

799 | % \begin{xio} |

800 | % The reduced minimal Gr\"obner basis for $I^q_3$ consists of |

801 | % \begin{dgroup*} |

802 | % \begin{dmath*} |

803 | % H_1^3 = x_1 + x_2 + x_3 |

804 | % \end{dmath*}, |

805 | % \begin{dmath*} |

806 | % H_2^2 = x_1^2 + x_1 x_2 + x_2^2 - q_1 - q_2 |

807 | % \end{dmath*}, |

808 | % \begin{dsuspend} |

809 | % and |

810 | % \end{dsuspend} |

811 | % \begin{dmath*} |

812 | % H_3^1 = x_1^3 - 2x_1 q_1 - x_2 q_1 |

813 | % \end{dmath*}. |

814 | % \end{dgroup*} |

815 | % \end{xio} |

816 | % |

817 | % |

818 | % |

819 | % \StopEventually{} |

820 | % \part*{Implementation} |

821 | % |

822 | % |

823 | % |

824 | % \begin{macrocode} |

825 | %<*package> |

826 | \NeedsTeXFormat{LaTeX2e} |

827 | \ProvidesPackage{breqn}[2007/12/02 v0.95] |

828 | |

829 | \edef\breqnpopcats{% |

830 | \catcode\number`\"=\number\catcode`\" |

831 | \relax |

832 | } |

833 | \catcode`\^=7 \catcode`\_=8 \catcode`\"=12 \relax |

834 | \DeclareOption{debug}{} |

835 | \DeclareOption{mathstyleoff}{% |

836 | \PassOptionsToPackage{mathstyleoff}{flexisym}% |

837 | } |

838 | \ProcessOptions\relax |

839 | \@ifpackageloaded{flexisym}{}{% |

840 | \RequirePackage[cmbase]{flexisym}[1997/01/01] |

841 | % Reiterate this here, for now, until I have a chance to better |

842 | % sort things out. [mjd,2002-05-29] |

843 | \edef\breqnpopcats{\breqnpopcats |

844 | \catcode\number`\^=\number\catcode`\^ |

845 | \catcode\number`\_=\number\catcode`\_ |

846 | }% |

847 | \catcode`\^=7 \catcode`\_=8 \catcode`\"=12 \relax |

848 | } |

849 | \RequirePackage{keyval}\relax |

850 | \@ifundefined{options}{% |

851 | \newcommand{\options}[2]{% |

852 | \expandafter\options@a\csname opt@#1.sty\endcsname{#2}% |

853 | \setkeys{#1}{#2}% |

854 | } |

855 | \def\options@a#1#2{% |

856 | \edef\@tempa{\options@b#2,\@empty\@nil}% |

857 | \ifx#1\relax \let#1\@empty\fi |

858 | \xdef#1{#1\ifx#1\@empty\@xp\@gobble\@tempa\@empty\else\@tempa \fi}% |

859 | } |

860 | \def\options@b#1,#2#3\@nil{% |

861 | \options@c#1 \@nil |

862 | \ifx#2\@empty \else\options@b#2#3\@nil\fi |

863 | } |

864 | \def\options@c#1 #2\@nil{\options@d#1=\@nil} |

865 | \def\options@d#1=#2\@nil{\ifx\@empty #1\@empty\else,\fi#1} |

866 | }{}% end @ifundefined test |

867 | \let\@nx\noexpand |

868 | \let\@xp\expandafter |

869 | \@ifundefined{@emptytoks}{\newtoks\@emptytoks}{} |

870 | \chardef\f@ur=4 |

871 | \newcount\inf@bad \inf@bad=1000000 |

872 | \newcount\maxint \maxint=2147483647 |

873 | \let\int@a=\@tempcnta |

874 | \let\int@b=\@tempcntb |

875 | \let\int@c=\count@ |

876 | \let\dim@a\@tempdima |

877 | \let\dim@b\@tempdimb |

878 | \let\dim@c\@tempdimc |

879 | \let\dim@d\dimen@ |

880 | \let\dim@e\dimen@ii |

881 | \let\dim@A\dimen@i |

882 | \let\skip@a\@tempskipa |

883 | \let\skip@b\@tempskipb |

884 | \let\skip@c\skip@ |

885 | \let\toks@a\@temptokena |

886 | \let\toks@b\toks@ |

887 | \toksdef\toks@c=2 |

888 | \toksdef\toks@d=4 |

889 | \toksdef\toks@e=6 |

890 | \toksdef\toks@f=8 |

891 | \def\abs@num#1{\ifnum#1<\z@-\fi#1} |

892 | \def\@ifnext#1#2#3{% |

893 | \let\@tempd= #1\def\@tempa{#2}\def\@tempb{#3}% |

894 | \futurelet\@tempc\@ifnexta |

895 | } |

896 | \def\@ifnexta{\ifx\@tempc\@tempd \let\@tempb\@tempa \fi \@tempb} |

897 | \def\@ifstar#1#2{% |

898 | \let\@tempd*\def\@tempa*{#1}\def\@tempb{#2}% |

899 | \futurelet\@tempc\@ifnexta |

900 | } |

901 | \def\@optarg#1#2{\@ifnext[{#1}{#1[#2]}} |

902 | \def\@True{00} |

903 | \def\@False{01} |

904 | \def\@Not#1{0\ifcase#11 \or\@xp 1\else \@xp 0\fi} |

905 | \def\@And#1#2{0\ifcase#1#2 \@xp 0\else \@xp 1\fi} |

906 | \def\@Or#1#2{0\ifnum#1#2<101 \@xp 0\else \@xp 1\fi} |

907 | \def\freeze@glue#1{#11#1\relax} |

908 | \def\z@rule{\vrule\@width\z@}% no \relax ! use with care |

909 | \def\keep@glue{\z@rule\relax} |

910 | % usage: \message{H\replicate{5}{i h}ow de doo dee!} |

911 | \begingroup \catcode`\&=11 |

912 | \gdef\replicate#1{% |

913 | \csname &\expandafter\replicate@a\romannumeral\number\number#1 000q\endcsname |

914 | } |

915 | \endgroup |

916 | \long\def\replicate@a#1#2\endcsname#3{#1\endcsname{#3}#2} |

917 | \begingroup \catcode`\&=11 |

918 | \long\gdef\&m#1#2{#1\csname \endcsname{#1}} |

919 | \endgroup |

920 | \@xp\let\csname\string &q\endcsname\@gobble |

921 | \g@addto@macro\mathchars@reset{% |

922 | \let\@symRel\@secondoftwo \let\@symBin\@secondoftwo |

923 | \let\@symDeL\@secondoftwo \let\@symDeR\@secondoftwo |

924 | \let\@symDeB\@secondoftwo |

925 | } |

926 | \def\eq@cons#1#2{% |

927 | \begingroup \let\@elt\relax \xdef#1{\@elt{#2}#1}\endgroup |

928 | } |

929 | \providecommand{\@saveprimitive}[2]{% |

930 | \begingroup |

931 | \edef\@tempa{\string#1}\edef\@tempb{\meaning#1}% |

932 | \ifx\@tempa\@tempb \global\let#2#1% |

933 | \else |

934 | \edef\@tempb{\meaning#2}% |

935 | \ifx\@tempa\@tempb |

936 | \else \@saveprimitive@a#1#2% |

937 | \fi |

938 | \fi |

939 | \endgroup |

940 | } |

941 | \def\@saveprimitive@a#1#2{% |

942 | \begingroup |

943 | \def\@tempb##1#1##2{\edef\@tempb{##2}\@car{}}% |

944 | \@tempb\nullfont{select font nullfont}% |

945 | \topmark{\string\topmark:}% |

946 | \firstmark{\string\firstmark:}% |

947 | \botmark{\string\botmark:}% |

948 | \splitfirstmark{\string\splitfirstmark:}% |

949 | \splitbotmark{\string\splitbotmark:}% |

950 | #1{\string#1}% |

951 | \edef\@tempa{\expandafter\strip@prefix\meaning\@tempb}% |

952 | \edef\@tempb{\meaning#1}% |

953 | \ifx\@tempa\@tempb \global\let#2#1% |

954 | \else |

955 | \PackageError{breqn}% |

956 | {Unable to properly define \string#2; primitive |

957 | \noexpand#1no longer primitive}\@eha |

958 | \fi |

959 | \fi |

960 | \endgroup |

961 | } |

962 | \begingroup \catcode`\$=3 % just to make sure |

963 | \global\let\@@math=$ \gdef\@@display{$$} |

964 | \endgroup |

965 | \let\@@endmath=\@@math |

966 | \let\@@enddisplay=\@@display |

967 | \@saveprimitive\vadjust\@@vadjust |

968 | \@saveprimitive\insert\@@insert |

969 | \@saveprimitive\mark\@@mark |

970 | \let\debug=\begingroup |

971 | \let\gubed=\endgroup |

972 | \def\debugmsg{\message{|= \iffalse}\fi |

973 | \@xp\@gobble\string |

974 | } |

975 | \def\debugwr#1{\immediate\write\sixt@@n{|= #1}} |

976 | \def\debug@box#1{% |

977 | \batchmode{\showboxbreadth\maxdimen\showboxdepth99\showbox#1}% |

978 | \errorstopmode |

979 | } |

980 | \def\eqinfo{% |

981 | \debug@box\EQ@copy |

982 | \wlog{||= EQ@copy: \the\wd\EQ@copy\space x |

983 | \the\ht\EQ@copy+\the\dp\EQ@copy |

984 | }% |

985 | } |

986 | \def\debug@para{% |

987 | \debugwr{\hsize\the\hsize, \parfillskip\the\parfillskip}% |

988 | \debugmsg{\leftskip\the\leftskip, \rightskip\the\rightskip}% |

989 | \debugmsg{\linepenalty\the\linepenalty, \adjdemerits\the\adjdemerits}% |

990 | \debugmsg{\pretolerance\the\pretolerance, \tolerance\the\tolerance, |

991 | \parindent\the\parindent}% |

992 | } |

993 | \@ifpackagewith{breqn}{debug}{}{% |

994 | \let\debug\iffalse \let\gubed\fi |

995 | \let\debugmsg\@gobble \let\debug@lines\relax \let\debug@para\relax |

996 | \let\debugwr\@gobble |

997 | \let\debug@box\@gobble \let\debug@push\@gobbletwo |

998 | } |

999 | \@ifundefined{listwidth}{\newdimen\listwidth}{} |

1000 | \listwidth=\z@ |

1001 | \def\do#1#2{\begingroup |

1002 | \def\?##1#1##2##3##4##5\@nil{\endgroup##2##3\afterassignment\do##4}% |

1003 | \?C\newcount#2#2D\newdimen#2#2S\newskip#2#2U\newmuskip#2#2% |

1004 | K\newtoks#2#2F\newif#2{\z@\z@}T\newif#2{\let#2\iftrue}% |

1005 | B\newbox#2{\z@\z@}d{\newcommand#2{}}{}{\def#2}% |

1006 | Q\relax\@gobbletwo\relax \@nil}% |

1007 | \do % def, Count, Dimen, Skip, mUskip, toKs, Box, False, True |

1008 | d\eqfontsize{} % Inherit from context |

1009 | d\eqcolor{black} % Default to black |

1010 | D\eqnumsep=9pt % Min space between equ number and body |

1011 | D\eqmargin=8pt % For `multline' gap emulation |

1012 | d\eqindent{C}% % C or I, centered or indented |

1013 | d\eqnumside{R}% % R or L, right or left |

1014 | d\eqnumplace{M}% % M or T or B, middle top or bottom |

1015 | d\eqnumfont{\upshape}% % Upright even when surrounding text is slanted |

1016 | d\eqnumform#1{(#1\@@italiccorr)} % Add parens |

1017 | d\eqnumsize{} % Allow numbers to have different typesize ... |

1018 | d\eqnumcolor{} % ... or color than eq body e.g. \color{blue} |

1019 | S\eqlinespacing=14pt plus2pt % Base-to-base space between lines |

1020 | S\eqlineskip=3pt plus2pt % Min space if eqlinespacing too small |

1021 | D\eqlineskiplimit=2pt % Threshold for switching to eqlineskip |

1022 | U\eqbinoffset=15mu minus-3mu % Offset from mathrel alignment pt for mathbins |

1023 | U\eqdelimoffset=2mu % Additional offset for break inside delims |

1024 | D\eqindentstep=8pt % Indent used when LHS wd is n/a or too large |

1025 | d\eqcompactzone{5em} % Force compact unless RHS max exceeds this |

1026 | K\eqstyle={} % Customization hook |

1027 | C\eqbreakdepth=2 % Allow breaks within delimiters to this depth |

1028 | C\eqlinepenalty=199 % No page breaks between equation lines |

1029 | C\eqinterlinepenalty=10000 % No page breaks between equation lines |

1030 | C\intereqpenalty=\@M % Pagebreak penalty between equations |

1031 | S\intereqskip=3pt plus2pt % Additional vert space between equations |

1032 | C\prerelpenalty=-\@M % Linebreak penalty before mathrel symbols |

1033 | C\prebinoppenalty=888 % Linebreak penalty before mathbins |

1034 | U\Dmedmuskip=4mu minus 3mu % medmuskip in displays |

1035 | U\Dthickmuskip=5mu minus 2mu % thickmuskip in displays |

1036 | Q\relax % End of assignments |

1037 | \do % def, Dimen, Skip, mUskip, toKs, Box, False, True |

1038 | d\eq@number{} % Internal variable |

1039 | S\eqleftskip=\@centering % Space on the left |

1040 | S\eqrightskip=\@centering % Space on the right |

1041 | S\eq@vspan=\z@skip % Glue used to vcenter the eq number |

1042 | U\eq@binoffset=\eqbinoffset % Roughly, \eqbinoffset + \eqdelimoffset |

1043 | B\EQ@box % Storage for equation body |

1044 | B\EQ@copy % For eq body sans vadjust/insert/mark material |

1045 | B\EQ@numbox % For equation number |

1046 | %%B\EQ@vimbox % Vadjust, insert, or mark material |

1047 | %%B\EQ@vimcopy % Spare copy of same |

1048 | %%B\eq@impinging % Temporary box for measuring number placement |

1049 | T\if@eq@number % Number present or not? |

1050 | C\eq@lines=\z@ % Internal counter, actual number of lines |

1051 | C\eq@curline=\z@ % Loop counter |

1052 | C\eq@badness=\z@ % Used in testing for overfull lines |

1053 | C\EQ@vims=\z@ % For bookkeeping |

1054 | Q\relax |

1055 | \newdimen\eq@dp \newdimen\eq@sidespace |

1056 | \newdimen\eq@wdL \newdimen\grp@wdL \newdimen\grp@bodywidth |

1057 | \newdimen\eq@bodywidth \newdimen\eq@wdRmax \newdimen\eq@firstht |

1058 | \newdimen\eq@indentstep \newdimen\eq@linewidth \newdimen\eq@freewidth |

1059 | \newdimen\grp@linewidth |

1060 | \def\do#1#2{\if Q#1\relax \else\@xp\do\fi}\do |

1061 | D\eq@bodywidth % Total width for framing |

1062 | D\eq@wdL % Width of the left-hand-side |

1063 | D\eq@sidespace % Min leftover space for centering |

1064 | D\grp@wdL % Max width of LHS's in a group |

1065 | D\grp@bodywidth % Max width of all equations in a group |

1066 | D\eq@firstht % Height of first line |

1067 | D\eq@dp % Depth of last line |

1068 | D\eq@indentstep % Indent amount when LHS is not present |

1069 | D\eq@linewidth % Width actually used for display |

1070 | D\grp@linewidth % Max eq@linewidth over a group |

1071 | D\eq@freewidth % eq@linewidth - space for number |

1072 | Q\relax |

1073 | \eq@indentstep=\maxdimen |

1074 | \eq@sidespace=\maxdimen |

1075 | \let\given@sidespace\@empty |

1076 | \def\eq@overrun{0pt} |

1077 | \@ifpackagewith{amsmath}{leqno}{% |

1078 | \@ifpackagewith{amsmath}{reqno}{}{\def\eqnumside{L}}% |

1079 | }{% |

1080 | \def\@tempa#1,leqno.clo,#2#3\@nil{% |

1081 | \ifx @#2\relax\else \def\eqnumside{L}\fi |

1082 | }% |

1083 | \@xp\@tempa\@filelist,leqno.clo,@\@nil |

1084 | \if L\eqnumside |

1085 | \else |

1086 | \@ifundefined{iftagsleft@}{}{% |

1087 | \edef\eqnumside{% |

1088 | \if TT\csname fi\endcsname\csname iftagsleft@\endcsname |

1089 | L\else R\fi |

1090 | }% |

1091 | } |

1092 | \fi |

1093 | } |

1094 | \@ifpackagewith{amsmath}{fleqn}{% |

1095 | \def\eqindent{I}% |

1096 | }{% |

1097 | \def\@tempa#1,fleqn.clo,#2#3\@nil{% |

1098 | \ifx @#2\relax\else \def\eqindent{I}\fi |

1099 | }% |

1100 | \@xp\@tempa\@filelist,fleqn.clo,@\@nil |

1101 | \if I\eqindent |

1102 | \else |

1103 | \@ifundefined{if@fleqn}{}{% |

1104 | \edef\eqindent{% |

1105 | \if TT\csname fi\endcsname\csname if@fleqn\endcsname |

1106 | I\else C\fi |

1107 | }% |

1108 | }% |

1109 | \fi |

1110 | } |

1111 | \if I\eqindent |

1112 | \@ifundefined{mathindent}{% |

1113 | \newdimen\mathindent |

1114 | }{% |

1115 | \@ifundefined{@mathmargin}{}{% |

1116 | \mathindent\@mathmargin |

1117 | }% |

1118 | } |

1119 | \fi |

1120 | \let\EQ@hasLHS=\@False |

1121 | \let\EQ@QED=\@empty |

1122 | \def\mark@lhs#1{% |

1123 | \ifnum\lr@level<\@ne |

1124 | \let\mark@lhs\relax |

1125 | \global\let\EQ@hasLHS=\@True |

1126 | \global\let\EQ@prebin@space\EQ@prebin@space@a |

1127 | \mark@lhs@a |

1128 | \penalty9999 % instead of normal \rel@break |

1129 | % else no penalty = forbid break |

1130 | \fi |

1131 | } |

1132 | \def\mark@lhs@a{% |

1133 | \mskip\thickmuskip \@@vadjust{\penalty\tw@}\penalty-\@Mi\@@vadjust{}% |

1134 | } |

1135 | \newcommand\hiderel[1]{\mathrel{\advance\lr@level\@ne#1}} |

1136 | \let\m@@Bin\m@Bin |

1137 | \let\m@@Rel\m@Rel |

1138 | \let\EQ@prebin@space\relax |

1139 | \def\EQ@prebin@space@a{\mskip-\eq@binoffset \keep@glue \mskip\eq@binoffset} |

1140 | \def\bin@break{\ifnum\lastpenalty=\z@\penalty\prebinoppenalty\fi |

1141 | \EQ@prebin@space} |

1142 | \def\rel@break{% |

1143 | \ifnum\abs@num\lastpenalty <\abs@num\prerelpenalty |

1144 | \penalty\prerelpenalty |

1145 | \fi |

1146 | } |

1147 | \def\d@@Bin{\bin@break \m@@Bin} |

1148 | \def\d@@Rel{\mark@lhs \rel@break \m@@Rel} |

1149 | \let\m@@symRel\@symRel \def\d@@symRel{\mark@lhs \rel@break \m@@symRel} |

1150 | \let\m@@symBin\@symBin \def\d@@symBin{\bin@break \m@@symBin} |

1151 | \let\m@@symDel\@symDel |

1152 | \let\m@@symDeR\@symDeR |

1153 | \let\m@@symDeB\@symDeB |

1154 | \let\m@@symDeA\@symDeA |

1155 | \global\everydisplay\expandafter{\the\everydisplay \display@setup} |

1156 | \def\display@setup{% |

1157 | \medmuskip\Dmedmuskip \thickmuskip\Dthickmuskip |

1158 | \let\m@Bin\d@@Bin \let\m@Rel\d@@Rel |

1159 | \let\@symRel\d@@symRel \let\@symBin\d@@symBin |

1160 | \let\m@DeL\d@@DeL \let\m@DeR\d@@DeR \let\m@DeB\d@@DeB |

1161 | \let\m@DeA\d@@DeA |

1162 | \let\@symDeL\d@@symDeL \let\@symDeR\d@@symDeR |

1163 | \let\@symDeB\d@@symDeB \let\@symDeA\d@@symDeA |

1164 | \let\left\eq@left \let\right\eq@right \global\lr@level\z@ |

1165 | \everyhbox{\everyhbox\@emptytoks |

1166 | \let\display@setup\relax \textmath@setup \let\textmath@setup\relax |

1167 | }% |

1168 | \everyvbox{\everyvbox\@emptytoks |

1169 | \let\display@setup\relax \textmath@setup \let\textmath@setup\relax |

1170 | }% |

1171 | } |

1172 | \def\textmath@setup{% |

1173 | \let\m@Bin\m@@Bin \let\m@Rel\m@@Rel |

1174 | \let\@symRel\m@@symRel \let\@symBin\m@@symBin |

1175 | \let\m@DeL\m@@DeL \let\m@DeR\m@@DeR \let\m@DeB\m@@DeB |

1176 | \let\m@DeA\m@@DeA |

1177 | \let\@symDeL\m@@symDeL \let\@symDeR\m@@symDeR |

1178 | \let\@symDeB\m@@symDeB \let\@symDeA\m@@symDeA |

1179 | \let\left\@@left \let\right\@@right |

1180 | } |

1181 | \@ifundefined{@displaytrue}{% |

1182 | \@xp\newif\csname if@display\endcsname |

1183 | \everydisplay\@xp{\the\everydisplay \@displaytrue} |

1184 | }{} |

1185 | % \begin{dmath}[label={xyz}] |

1186 | \define@key{breqn}{label}{\def\next@label{\label{#1}}} |

1187 | \global\let\next@label\@empty |

1188 | % \begin{dmath}[number={\nref{foo}\textprime}] |

1189 | \define@key{breqn}{number}{\def\eq@number{#1}% |

1190 | \let\@currentlabel\eq@number |

1191 | } |

1192 | % \begin{dmath}[shiftnumber] |

1193 | \define@key{breqn}{shiftnumber}{\let\eq@shiftnumber\@True} |

1194 | % \begin{dmath}[holdnumber] |

1195 | \define@key{breqn}{holdnumber}{\let\eq@holdnumber\@True} |

1196 | % \begin{dmath}[density={.5}] |

1197 | \define@key{breqn}{density}{\def\eq@density@factor{#1}} |

1198 | % \begin{dmath}[indentstep={1em}] |

1199 | \define@key{breqn}{indentstep}{\eqindentstep#1\relax} |

1200 | % \begin{dmath}[compact] |

1201 | \define@key{breqn}{compact}[-99]{\prerelpenalty=#1\relax} |

1202 | % \begin{dmath}[layout={S}]% |

1203 | \define@key{breqn}{layout}[?]{% |

1204 | \edef\eq@layout{\@car#1?\@nil}% |

1205 | } |

1206 | % \begin{dmath}[spread={1pt}] |

1207 | \define@key{breqn}{spread}{% |

1208 | \advance\eqlinespacing#1% |

1209 | \advance\eqlineskip#1\eqlineskiplimit\eqlineskip |

1210 | } |

1211 | \define@key{breqn}{sidespace}{% |

1212 | \dimen@#1\relax % error checking |

1213 | \def\given@sidespace{#1}% |

1214 | } |

1215 | % \begin{dmath}[style={\small}] |

1216 | \define@key{breqn}{style}{\eqstyle\@xp{\the\eqstyle #1}} |

1217 | % \begin{dmath}[frame] |

1218 | \define@key{breqn}{frame}[\fboxrule]{\let\eq@frame=T% |

1219 | \dim@a#1\relax\edef\eq@framewd{\the\dim@a}% |

1220 | \freeze@glue\eqlinespacing \freeze@glue\eqlineskip |

1221 | } |

1222 | \define@key{breqn}{fullframe}[]{\let\eq@frame=U% |

1223 | \freeze@glue\eqlinespacing \freeze@glue\eqlineskip |

1224 | } |

1225 | \let\eq@frame=F % no frame |

1226 | \def\eq@framewd{\fboxrule} |

1227 | \define@key{breqn}{framesep}[\fboxsep]{% |

1228 | \ifx\eq@frame=F\let\eq@frame=T\fi |

1229 | \dim@a#1\relax \edef\eq@framesep{\the\dim@a}% |

1230 | \freeze@glue\eqlinespacing \freeze@glue\eqlineskip |

1231 | } |

1232 | \def\eq@framesep{\fboxsep} |

1233 | % \begin{dmath}[background={red}] |

1234 | \define@key{breqn}{background}{\def\eq@background{#1}% |

1235 | \freeze@glue\eqlinespacing \freeze@glue\eqlineskip |

1236 | } |

1237 | % |

1238 | % \begin{dmath}[color={purple}] |

1239 | \define@key{breqn}{color}{\def\eq@foreground{#1}} |

1240 | % \begin{dmath}[center] |

1241 | \define@key{breqn}{center}[]{\let\eq@centerlines\@True} |

1242 | \let\eq@centerlines\@False |

1243 | % \begin{dgroup}[noalign] |

1244 | \define@key{breqn}{noalign}[]{\let\grp@align\@False} |

1245 | \let\grp@align\@True % default |

1246 | % \begin{dgroup}[breakdepth={2}] |

1247 | \define@key{breqn}{breakdepth}{\eqbreakdepth#1\relax} |

1248 | % \begin{darray}[cols={lcrlcr}] |

1249 | \define@key{breqn}{cols}{\global\let\@preamble\@empty |

1250 | \darray@mkpream#1\@percentchar |

1251 | } |

1252 | \newenvironment{dmath}{\@eq@numbertrue \@optarg\@dmath{}}{} |

1253 | \def\@dmath[#1]{% |

1254 | \if\eq@group\else\eq@prelim\fi |

1255 | \setkeys{breqn}{#1}% |

1256 | \the\eqstyle |

1257 | \eq@setnumber |

1258 | \begingroup |

1259 | \eq@setup@a |

1260 | \eq@startup |

1261 | } |

1262 | \def\enddmath#1{\check@punct@or@qed} |

1263 | \def\end@dmath{% |

1264 | \eq@capture |

1265 | \endgroup |

1266 | \EQ@setwdL |

1267 | \eq@measure |

1268 | \if\eq@group \grp@push \else \eq@finish\fi |

1269 | } |

1270 | \newenvironment{dmath*}{% |

1271 | \@eq@numberfalse \@optarg\@dmath{}% |

1272 | }{} |

1273 | \@namedef{end@dmath*}{\end@dmath} |

1274 | \@namedef{enddmath*}#1{\check@punct@or@qed} |

1275 | \def\eq@prelim{% |

1276 | \if@noskipsec \leavevmode \fi |

1277 | \if@inlabel \leavevmode \global\@inlabelfalse \fi |

1278 | \if@nobreak \global\@nobreakfalse \predisplaypenalty\@M \fi |

1279 | \everypar\@emptytoks |

1280 | \noindent |

1281 | \eq@nulldisplay |

1282 | \par %% \eq@saveparinfo %% needs work |

1283 | \let\intertext\breqn@intertext |

1284 | } |

1285 | \def\breqn@parshape@warning{% |

1286 | \PackageWarning{breqn}{% |

1287 | Complex paragraph shape cannot be followed by this equation}% |

1288 | } |

1289 | \let\eq@prevshape\@empty |

1290 | \def\eq@saveparinfo{% |

1291 | \count@\prevgraf \advance\count@-\thr@@ % for the null display |

1292 | \edef\eq@prevshape{\prevgraf\the\count@\space}% |

1293 | \ifcase\parshape |

1294 | % case 0: no action required |

1295 | \or \edef\eq@prevshape{\eq@prevshape |

1296 | \parshape\@ne\displayindent\displaywidth\relax |

1297 | }% |

1298 | \else |

1299 | \breqn@parshape@warning |

1300 | \fi |

1301 | } |

1302 | \def\eq@setnumber{% |

1303 | \debugwr{=====================================================}% |

1304 | \if@eq@number |

1305 | \ifx\eq@number\@empty |

1306 | \stepcounter{equation}\let\eq@number\theequation |

1307 | \fi |

1308 | \fi |

1309 | \ifx\eq@number\@empty |

1310 | \else |

1311 | \set@label{equation}\eq@number |

1312 | \global\sbox\EQ@numbox{% |

1313 | \next@label \global\let\next@label\@empty |

1314 | \eqnumcolor\eqnumsize |

1315 | \eqnumfont{\eqnumform{\eq@number}}% |

1316 | \debug \typeout{|= Eq number (\eq@number) |

1317 | placement '\eqnumside\eqnumplace'}% |

1318 | \gubed |

1319 | }% |

1320 | \@eq@numbertrue % locally true |

1321 | \debugwr{Eq number width: \the\wd\EQ@numbox\space |

1322 | (ht/dp: \the\ht\EQ@numbox+\the\dp\EQ@numbox)}% |

1323 | \debugwr{Eq number sep: \the\eqnumsep}% |

1324 | \fi |

1325 | } |

1326 | \def\eq@finish{% |

1327 | \begingroup |

1328 | \csname eq@\eqindent \if@eq@number\eqnumside\eqnumplace\fi\endcsname |

1329 | \ifnum\eq@lines=\prevgraf |

1330 | \else |

1331 | \debug |

1332 | \batchmode\showboxbreadth\maxdimen\showboxdepth99\showlists\errorstopmode |

1333 | \gubed |

1334 | \debugmsg{% |

1335 | prevgraf \the\prevgraf\space != eq@lines \the\eq@lines?}% |

1336 | \fi |

1337 | \endgroup |

1338 | \eq@botspace |

1339 | } |

1340 | \def\peek@branch#1#2{% |

1341 | \let\peek@b#1\let\peek@space#2\futurelet\@let@token\peek@a |

1342 | } |

1343 | \def\peek@skipping@spaces#1{\peek@branch#1\peek@skip@space} |

1344 | \def\peek@a{% |

1345 | \ifx\@let@token\@sptoken \expandafter\peek@space |

1346 | \else \expandafter\peek@b\fi |

1347 | } |

1348 | \lowercase{\def\peek@skip@space} {\futurelet\@let@token\peek@a}% |

1349 | \def\check@punct{\futurelet\@let@token\check@punct@a} |

1350 | \def\check@punct@a{% |

1351 | \edef\@tempa{% |

1352 | \ifx\@let@token\@sptoken\@nx\finish@end |

1353 | \else\ifx\@let@token ,\@nx\check@qed |

1354 | \else\ifx\@let@token .\@nx\check@qed |

1355 | \else\check@punct@b % check the less common possibilities |

1356 | \fi\fi\fi |

1357 | }% |

1358 | \@tempa |

1359 | } |

1360 | \begingroup |

1361 | \toks@a{% |

1362 | \ifx\@let@token ;\@nx\check@qed |

1363 | \else\ifx\@let@token ?\@nx\check@qed |

1364 | \else\ifx\@let@token !\@nx\check@qed |

1365 | } |

1366 | \toks@c{\fi\fi\fi}% matching with \toks@a |

1367 | \catcode`\.=\active \catcode`\,=\active \catcode`\;=\active |

1368 | \catcode`\?=\active \catcode`\!=\active |

1369 | \toks@b{ |

1370 | \else\ifx\@let@token ,\@nx\check@qed |

1371 | \else\ifx\@let@token .\@nx\check@qed |

1372 | \else\ifx\@let@token ;\@nx\check@qed |

1373 | \else\ifx\@let@token ?\@nx\check@qed |

1374 | \else\ifx\@let@token !\@nx\check@qed |

1375 | \else\@nx\finish@end |

1376 | \fi\fi\fi\fi\fi |

1377 | } |

1378 | \xdef\check@punct@b{% |

1379 | \the\toks@a\the\toks@b\the\toks@c |

1380 | } |

1381 | \endgroup |

1382 | \let\found@punct\@empty |

1383 | \def\check@qed#1{% |

1384 | \gdef\found@punct{#1}% |

1385 | \peek@skipping@spaces\check@qed@a |

1386 | } |

1387 | \def\check@qed@a{% |

1388 | \ifx\end\@let@token \@xp\check@qed@b |

1389 | \else \@xp\finish@end |

1390 | \fi |

1391 | } |

1392 | \def\check@qed@b#1#2{% |

1393 | \@ifundefined{#2qed}{}{% |

1394 | \toks@\@xp{\found@punct\csname#2qed\endcsname}% |

1395 | \xdef\found@punct{\the\toks@}% |

1396 | }% |

1397 | \finish@end |

1398 | \end{#2}% |

1399 | } |

1400 | \def\@tempa#1\endcsname#2\@nil{\def\latex@end##1{#2}} |

1401 | \expandafter\@tempa\end{#1}\@nil |

1402 | \def\end#1{\csname end#1\endcsname \latex@end{#1}}% |

1403 | \def\check@punct@or@qed#1{% |

1404 | \def\finish@end{\csname end@#1\endcsname\latex@end{#1}}% |

1405 | \check@punct |

1406 | } |

1407 | \newcommand\eqpunct[1]{\thinspace#1} |

1408 | \providecommand\set@label[2]{\protected@edef\@currentlabel{#2}} |

1409 | \def\eq@topspace#1{% |

1410 | \begingroup |

1411 | \global\let\EQ@shortskips\@False |

1412 | \if\@And{\eq@group}{\@Not\GRP@top}% |

1413 | \parskip\intereqskip \penalty\intereqpenalty |

1414 | \else |

1415 | \eq@setdisplayskips |

1416 | \fi |

1417 | \ifx F\eq@frame |

1418 | \else |

1419 | \advance\parskip\eq@framesep \advance\parskip\eq@framewd\relax |

1420 | \fi |

1421 | #1% |

1422 | \endgroup |

1423 | } |

1424 | \def\eq@setdisplayskips{% |

1425 | \if \if@eq@number\eqnumside \else F\fi L% |

1426 | \parskip\abovedisplayskip |

1427 | \else |

1428 | \afterassignment\eq@firstindent % sets \dim@a |

1429 | \int@a\eq@parshape \relax |

1430 | \debugwr{first indent \the\dim@a, predisplaysize \the\predisplaysize}% |

1431 | \advance\dim@a-2em % standard TeX value |

1432 | \ifdim\dim@a>\predisplaysize |

1433 | \global\let\EQ@shortskips\@True |

1434 | \parskip\abovedisplayshortskip |

1435 | \aftergroup\belowdisplayskip\aftergroup\belowdisplayshortskip |

1436 | \else |

1437 | \parskip\abovedisplayskip |

1438 | \fi |

1439 | \debugwr{parskip \the\parskip}% |

1440 | \fi |

1441 | } |

1442 | \def\eq@firstindent#1 #2 #3\relax{\dim@a#2\relax} |

1443 | \def\eq@botspace{% |

1444 | \penalty\postdisplaypenalty |

1445 | \ifx F\eq@frame |

1446 | \else |

1447 | \advance\belowdisplayskip\eq@framesep |

1448 | \advance\belowdisplayskip\eq@framewd\relax |

1449 | \fi |

1450 | \vskip\belowdisplayskip |

1451 | \@endpetrue % kill parindent if current paragraph continues |

1452 | \global\@ignoretrue % ignore following spaces |

1453 | \eq@resume@parshape |

1454 | } |

1455 | \def\eq@resume@parshape{} |

1456 | \def\eq@startup{% |

1457 | \global\let\EQ@hasLHS\@False |

1458 | \global\let\found@punct\@empty |

1459 | \setbox\z@\vbox\bgroup |

1460 | \noindent \@@math \displaystyle |

1461 | \penalty-\@Mi |

1462 | } |

1463 | \def\eq@setup@a{% |

1464 | \everymath\everydisplay |

1465 | %\let\@newline\eq@newline % future possibility? |

1466 | \let\\\eq@newline |

1467 | \let\insert\eq@insert \let\mark\eq@mark \let\vadjust\eq@vadjust |

1468 | \hsize\maxdimen \pretolerance\@M |

1469 | \linepenalty\@m |

1470 | \rightskip\z@\@plus\@M\p@ \leftskip\z@skip \parfillskip\z@skip |

1471 | \clubpenalty\@ne \widowpenalty\z@ \interlinepenalty\z@ |

1472 | \global\let\EQ@prebin@space\relax |

1473 | \binoppenalty\@M \relpenalty\@M |

1474 | } |

1475 | \def\eq@unclosed@left{% |

1476 | \PackageError{breqn}{% |

1477 | Delimiter mismatch---not enough closing delimiters% |

1478 | }{% |

1479 | Or perhaps too many open delimiters, somewhere in this |

1480 | equation.\MessageBreak |

1481 | \@ehc |

1482 | }% |

1483 | } |

1484 | \def\eq@capture{% |

1485 | \ifnum\lr@level>\z@ \eq@unclosed@left \global\lr@level\z@ \fi |

1486 | \ifnum\lastpenalty>-\@M \penalty-\@Mi \fi |

1487 | \keep@glue\@@endmath |

1488 | \eq@addpunct |

1489 | \@@par |

1490 | \eq@wdL\z@ |

1491 | \global\let\EQ@setwdL\@empty |

1492 | \global\let\EQ@thickmuskip\@empty |

1493 | \debug |

1494 | \batchmode\showboxbreadth\maxdimen\showboxdepth99\showlists\errorstopmode |

1495 | \gubed |

1496 | \setbox\tw@\lastbox |

1497 | \global\setbox\EQ@box\hbox{\unhbox\tw@\unskip\unskip\unpenalty}% |

1498 | \unskip\unpenalty |

1499 | \global\setbox\EQ@copy\copy\EQ@box |

1500 | %% \global\setbox\EQ@vimcopy\copy\EQ@vimbox |

1501 | \clubpenalty\z@ |

1502 | \eq@repack % recursive |

1503 | \setbox\tw@\lastbox |

1504 | \global\setbox\EQ@box\hbox{\unhcopy\tw@\unskip\unpenalty \unhbox\EQ@box}% |

1505 | \global\setbox\EQ@copy\hbox{\unhbox\tw@\unskip\unpenalty \unhbox\EQ@copy}% |

1506 | \debug |

1507 | \batchmode\showbox\EQ@copy \showthe\eq@wdL\errorstopmode |

1508 | \gubed |

1509 | \egroup % end vbox started earlier |

1510 | } |

1511 | \def\eq@addpunct{% |

1512 | \ifx\found@punct\@empty |

1513 | \else \eqpunct{\found@punct}% |

1514 | \fi |

1515 | \EQ@afterspace |

1516 | } |

1517 | \global\let\EQ@afterspace\@empty |

1518 | \global\let\EQ@setwdL\@empty |

1519 | \global\let\EQ@thickmuskip\@empty |

1520 | \def\eq@LHS@check{% |

1521 | \if\EQ@hasLHS |

1522 | \setbox\z@\hbox{\unhcopy\EQ@copy\setbox\tw@\lastbox |

1523 | \EQ@thickmuskip}% |

1524 | \eq@wdL\wd\z@ |

1525 | \xdef\EQ@setwdL{\eq@wdL\the\eq@wdL\relax}% |

1526 | \debugwr{Changed wdL to \the\eq@wdL}% |

1527 | \fi |

1528 | } |

1529 | \def\eq@repack{% |

1530 | \ifcase\lastpenalty |

1531 | % case 0: normal case |

1532 | \setbox\tw@\lastbox |

1533 | \eq@repacka\EQ@copy \eq@repacka\EQ@box |

1534 | \unskip |

1535 | \or % case 1: finished recursing |

1536 | \unpenalty |

1537 | \setbox\tw@\lastbox |

1538 | \eq@repacka\EQ@copy \eq@repacka\EQ@box |

1539 | \eq@LHS@check |

1540 | \@xp\@gobble |

1541 | \or % case 2: save box width = LHS width |

1542 | \unpenalty |

1543 | \setbox\tw@\lastbox |

1544 | \setbox\z@\copy\tw@ \setbox\z@\hbox{\unhbox\z@\unskip\unpenalty}% |

1545 | \advance\eq@wdL\wd\z@ |

1546 | \xdef\EQ@setwdL{\eq@wdL\the\eq@wdL\relax}% |

1547 | \global\setbox\EQ@copy\hbox{% |

1548 | \hbox{\unhcopy\tw@\unskip\unpenalty |

1549 | \xdef\EQ@thickmuskip{\hskip\the\lastskip\relax}% |

1550 | \unskip}% |

1551 | \box\EQ@copy |

1552 | }% |

1553 | \global\setbox\EQ@box\hbox{% |

1554 | \hbox{\unhbox\tw@\unskip\unpenalty\unskip}% |

1555 | \box\EQ@box |

1556 | }% |

1557 | \unskip |

1558 | \or % case 3: unpack left-right box |

1559 | \unpenalty |

1560 | \eq@lrunpack |

1561 | \else |

1562 | \breqn@repack@err |

1563 | \fi |

1564 | \eq@repack % RECURSE |

1565 | } |

1566 | \def\breqn@repack@err{% |

1567 | \PackageError{breqn}{eq@repack penalty neq 0,1,2,3}\relax |

1568 | } |

1569 | \def\eq@repacka#1{% |

1570 | \global\setbox#1\hbox{\unhcopy\tw@ \unskip |

1571 | \count@-\lastpenalty |

1572 | \ifnum\count@<\@M \else \advance\count@-\@M \fi |

1573 | \unpenalty |

1574 | \ifx\EQ@copy#1\ifnum\count@>\thr@@ \count@\@ne\fi\fi |

1575 | \ifcase\count@ |

1576 | % case 0, normal line break |

1577 | \penalty-\@M % put back the linebreak penalty |

1578 | \or % case 1, do nothing (end of equation) |

1579 | \relax |

1580 | \or % case 2, no-op (obsolete case) |

1581 | \or % case 3, transfer vspace and/or penalty |

1582 | \ifx#1\EQ@box \eq@revspace \else \eq@revspaceb \fi |

1583 | \or % case 4, put back an insert |

1584 | \eq@reinsert |

1585 | \or % case 5, put back a mark |

1586 | \eq@remark |

1587 | \or % case 6, put back a vadjust |

1588 | \eq@readjust |

1589 | \else % some other break penalty |

1590 | \penalty-\count@ |

1591 | \fi |

1592 | \unhbox#1}% |

1593 | } |

1594 | \def\eq@nulldisplay{% |

1595 | \begingroup \frozen@everydisplay\@emptytoks |

1596 | \@@display |

1597 | \predisplaypenalty\@M \postdisplaypenalty\@M |

1598 | \abovedisplayskip\z@skip \abovedisplayshortskip\z@skip |

1599 | \belowdisplayskip\z@skip \belowdisplayshortskip\z@skip |

1600 | \xdef\EQ@displayinfo{% |

1601 | \prevgraf\the\prevgraf \predisplaysize\the\predisplaysize |

1602 | \displaywidth\the\displaywidth \displayindent\the\displayindent |

1603 | \listwidth\the\linewidth |

1604 | \ifdim\displayindent>\z@ |

1605 | \advance\listwidth\the\leftmargin |

1606 | \advance\listwidth\the\rightmargin |

1607 | \fi |

1608 | \relax}% |

1609 | \halign{##\cr}% |

1610 | \@@enddisplay |

1611 | \par |

1612 | \endgroup |

1613 | \EQ@displayinfo |

1614 | } |

1615 | \def\eq@newline{% |

1616 | \@ifstar{\eq@newlinea\@M}{\eq@newlinea\eqinterlinepenalty}} |

1617 | \def\eq@newlinea#1{% |

1618 | \@ifnext[{\eq@newlineb{#1}}{\eq@newlineb{#1}[\maxdimen]}} |

1619 | \def\eq@newlineb#1[#2]{\penalty-\@M} |

1620 | \def\eq@revspace{% |

1621 | \global\setbox\EQ@vimbox\vbox{\unvbox\EQ@vimbox |

1622 | \unpenalty |

1623 | \global\setbox\@ne\lastbox}% |

1624 | \@@vadjust{\unvbox\@ne}% |

1625 | \penalty-\@M |

1626 | } |

1627 | \def\eq@revspaceb{% |

1628 | \global\setbox\EQ@vimcopy\vbox{\unvbox\EQ@vimcopy |

1629 | \unpenalty |

1630 | \global\setbox\@ne\lastbox}% |

1631 | \@@vadjust{\unvbox\@ne}% |

1632 | \penalty-\@M |

1633 | } |

1634 | \def\eq@break#1{\penalty-1000#1 \keep@glue} |

1635 | \let\@parshape\@empty |

1636 | \def\eq@measure{% |

1637 | \ifdim\eq@indentstep=\maxdimen \eq@indentstep\eqindentstep \fi |

1638 | \ifdim\eq@linewidth=\z@ \else \edef\eq@linewidths{{\the\eq@linewidth}}\fi |

1639 | \eqrightskip \z@\@plus.2\columnwidth |

1640 | \begingroup \eq@params |

1641 | \leftskip\z@skip |

1642 | \debug\eqinfo\gubed |

1643 | \global\EQ@continue{\eq@trial}% |

1644 | \eq@trial % uses \eq@linewidths |

1645 | \eq@failout % will be a no-op if the trial succeeded |

1646 | \endgroup |

1647 | \EQ@trial |

1648 | } |

1649 | \let\EQ@trial\@empty |

1650 | \newtoks\EQ@continue |

1651 | \let\EQ@widths\@empty |

1652 | \def\eq@linewidths{\displaywidth\linewidth\columnwidth} |

1653 | \def\eq@trial{% |

1654 | \ifx\@empty\eq@linewidths |

1655 | \global\EQ@continue{}% |

1656 | \else |

1657 | \iffalse{\fi \@xp\eq@trial@a \eq@linewidths}% |

1658 | \fi |

1659 | \the\EQ@continue |

1660 | } |

1661 | \def\eq@trial@a#1{% |

1662 | \dim@c#1\relax |

1663 | \debugwr{trial-A: width #1 (\the\dim@c)}% |

1664 | \ifx T\eq@frame \eq@frame@adjust\dim@c \fi |

1665 | \ifdim\dim@c>\eq@linewidth |

1666 | \eq@linewidth\dim@c \eq@freewidth\eq@linewidth |

1667 | \if@eq@number |

1668 | \advance\eq@freewidth-\eqnumsep |

1669 | \advance\eq@freewidth-\wd\EQ@numbox |

1670 | \fi |

1671 | \let\eq@trial@b\eq@trial@d |

1672 | \csname eq@try@layout@\eq@layout\endcsname |

1673 | \fi |

1674 | \edef\eq@linewidths{\iffalse}\fi |

1675 | } |

1676 | \@namedef{eq@try@layout@?}{% |

1677 | \let\eq@trial@b\eq@trial@c |

1678 | \if\EQ@hasLHS |

1679 | \debugmsg{trial-A: LHS present (\the\eq@wdL)}% |

1680 | \ifdim\eq@wdL>\eq@linewidth |

1681 | \debugwr{trial-A: LHS > linewidth}% |

1682 | \dim@a\wd\EQ@copy \advance\dim@a-\eq@wdL |

1683 | \ifdim\dim@a<.25\eq@linewidth \eq@try@layout@S |

1684 | \else \eq@try@layout@l |

1685 | \fi |

1686 | \else |

1687 | \ifdim\eq@wdL>.7\eq@linewidth |

1688 | \debugmsg{trial-A: LHS > .7 linewidth (linewidth=\the\eq@linewidth)}% |

1689 | \eq@try@layout@iS |

1690 | \else |

1691 | \debugmsg{trial-A: LHS not extraordinarily wide}% |

1692 | \eq@try@layout@L |

1693 | \fi |

1694 | \fi |

1695 | \else |

1696 | \debugwr{trial-A: No LHS here}% |

1697 | \eq@try@layout@iS |

1698 | \fi |

1699 | } |

1700 | \def\eq@trial@done{% |

1701 | \debugwr{End trial: Success!}% |

1702 | \let\eq@failout\relax |

1703 | } |

1704 | \def\eq@trial@init{\global\let\EQ@fallback\eq@nextlayout} |

1705 | \def\eq@trial@save#1{% |

1706 | \debug \def\eq@zek{^^J|== \space}\let\eq@kez\@empty\debugwr{trial info:\eq@measurements}\debugmsg{bounding box: \the\eq@bodywidth x\the\eq@vspan^^J}% |

1707 | \let\eq@zek\relax \let\eq@kez\relax |

1708 | \gubed |

1709 | \xdef#1{% |

1710 | \eq@linewidth\the\eq@linewidth \eq@freewidth\the\eq@freewidth |

1711 | \eq@lines\the\eq@lines \eq@badness\the\eq@badness |

1712 | \eq@wdL\the\eq@wdL \eq@bodywidth\the\eq@bodywidth \eq@sidespace\the\eq@sidespace |

1713 | \eq@vspan\the\eq@vspan \eq@dp\the\eq@dp \eq@firstht\the\eq@firstht |

1714 | \prerelpenalty\the\prerelpenalty % might change during processing |

1715 | \def\@nx\eq@badline{\eq@badline}% |

1716 | \def\@nx\eq@layout{\eq@layout}% |

1717 | \def\@nx\eq@parshape{\@parshape}% |

1718 | \def\@nx\eq@measurements{\eq@measurements}% |

1719 | \def\@nx\adjust@rel@penalty{\adjust@rel@penalty}% |

1720 | \def\@nx\eq@shiftnumber{\eq@shiftnumber}% |

1721 | }% |

1722 | } |

1723 | \def\eq@recalc{% |

1724 | \eq@bodywidth\z@ \eq@vspan\z@skip \eq@badness\z@ |

1725 | \eq@wdRmax\z@ |

1726 | \let\eq@zek\eq@recalc@a \eq@measurements \let\eq@zek\relax |

1727 | \ifdim\eq@bodywidth<\eq@linewidth |

1728 | \eq@sidespace\eq@linewidth \advance\eq@sidespace -\eq@bodywidth |

1729 | \divide\eq@sidespace\tw@ |

1730 | \else |

1731 | \eq@sidespace\z@ |

1732 | \fi |

1733 | } |

1734 | \def\eq@recalc@a#1x#2+#3\eq@kez{% |

1735 | \eq@firstht#2\relax |

1736 | \let\eq@zek\eq@recalc@b |

1737 | \eq@zek#1x#2+#3\eq@kez |

1738 | } |

1739 | \def\eq@recalc@b#1^^J#2,#3x#4+#5@#6\eq@kez{% |

1740 | \dim@a#3\relax |

1741 | \ifdim\dim@a>\eq@wdRmax \eq@wdRmax\dim@a\fi |

1742 | \advance\dim@a#2\relax |

1743 | \ifdim\dim@a>\eq@bodywidth \eq@bodywidth\dim@a \fi |

1744 | \eq@dp#5\relax |

1745 | \advance\eq@vspan#1\advance\eq@vspan#4\advance\eq@vspan#5\relax |

1746 | \ifnum#6>\eq@badness \eq@badness#6\relax\fi |

1747 | } |

1748 | \let\EQ@last@trial\@empty |

1749 | \def\eq@failout{% |

1750 | \debugmsg{End trial: failout}% |

1751 | \global\let\EQ@trial\EQ@last@trial |

1752 | } |

1753 | \def\eq@frame@adjust#1{% |

1754 | \dim@a\eq@framewd \advance\dim@a\eq@framesep |

1755 | \advance#1-2\dim@a |

1756 | } |

1757 | \def\eq@layout{?} |

1758 | \def\eq@try@layout@D{% |

1759 | \dim@a\eq@linewidth \advance\dim@a-\eq@indentstep |

1760 | \edef\@parshape{\parshape 2 |

1761 | 0pt \the\eq@wdL\space \the\eq@indentstep\space \the\dim@a\relax |

1762 | }% |

1763 | \def\adjust@rel@penalty{\penalty-99 }% |

1764 | \eq@trial@b{D}{\eq@try@layout@A}% |

1765 | } |

1766 | \def\eq@try@layout@A{% |

1767 | \edef\@parshape{\parshape 1 0pt \the\eq@linewidth\relax}% |

1768 | \if\EQ@hasLHS \def\adjust@rel@penalty{\penalty-99 }\fi |

1769 | \eq@trial@b{A}{}% |

1770 | } |

1771 | \def\eq@reindent@A{% |

1772 | \dim@a\eq@linewidth \advance\dim@a-\eq@bodywidth |

1773 | \edef\eq@parshape{% |

1774 | \parshape 2 |

1775 | 0pt \the\eq@bodywidth\space |

1776 | \the\dim@a\space \the\eq@bodywidth\relax |

1777 | }% |

1778 | \leftskip\z@skip |

1779 | } |

1780 | \def\eq@try@layout@L{% |

1781 | \dim@b\eq@linewidth \advance\dim@b-\eq@wdL |

1782 | \edef\@parshape{\parshape 2 0pt \the\eq@linewidth\space |

1783 | \the\eq@wdL\space \the\dim@b\relax |

1784 | }% |

1785 | \eq@trial@b{L}{\eq@try@layout@D}% |

1786 | } |

1787 | \def\eq@try@layout@iS{% |

1788 | \edef\@parshape{\parshape 1 0pt \the\eq@freewidth\relax}% |

1789 | \eq@trial@b{i}{\eq@try@layout@S}% |

1790 | } |

1791 | \def\eq@try@layout@S{% |

1792 | \dim@b\eq@linewidth \advance\dim@b-2\eqmargin \advance\dim@b-1em% |

1793 | \int@a\wd\EQ@copy \divide\int@a\dim@b |

1794 | \advance\dim@b-\int@a\eq@indentstep\relax |

1795 | \if@eq@number |

1796 | \ifdim\dim@b>15em% |

1797 | \advance\dim@b-\eqnumsep \advance\dim@b-\wd\EQ@numbox |

1798 | \fi |

1799 | \fi |

1800 | \int@b\z@ |

1801 | \def\@tempa{\dim}% |

1802 | \edef\@parshape{\parshape 2 0pt \the\dim@b\space |

1803 | \the\eqmargin\space\the\dim@b\relax}% |

1804 | \eq@trial@b{S}{\eq@try@layout@A}% |

1805 | } |

1806 | \def\eq@try@layout@l{% |

1807 | \dim@a\eq@linewidth \advance\dim@a-\eq@indentstep |

1808 | \int@a\eq@wdL \divide\int@a\dim@a |

1809 | \advance\int@a\tw@ |

1810 | \edef\@parshape{\parshape \number\int@a\space |

1811 | 0pt \the\eq@linewidth |

1812 | }% |

1813 | \advance\int@a-\tw@ |

1814 | \dim@b=2\eq@indentstep |

1815 | \dim@c\eq@linewidth \advance\dim@c-\dim@b |

1816 | \edef\@parshape{\@parshape |

1817 | \replicate{\int@a}{ \the\eq@indentstep\space\the\dim@a}% |

1818 | \space\the\dim@b\space\the\dim@c |

1819 | }% |

1820 | \eq@trial@b{l}{\eq@try@layout@A}% |

1821 | } |

1822 | \def\eq@fix@lastline{% |

1823 | \setbox\tw@\lastbox \dim@b\wd\tw@ |

1824 | \eq@dp\dp\tw@ |

1825 | \nointerlineskip\hbox to\dim@b{\unhbox\tw@ |

1826 | \skip@c\lastskip \unskip\unskip\hskip\skip@c |

1827 | }% |

1828 | } |

1829 | \def\eq@trial@b{\eq@trial@c} |

1830 | \def\eq@compact@test{% |

1831 | \debugwr{wdRmax: \the\eq@wdRmax}% |

1832 | \let\@tempa\@empty |

1833 | \if L\eq@layout |

1834 | \ifnum\prerelpenalty=-\@M % standard noncompact value |

1835 | \ifdim\eq@wdRmax>\eqcompactzone\relax |

1836 | \else |

1837 | \prerelpenalty=-99 |

1838 | \def\EQ@fallback{\endgroup |

1839 | \begingroup \@firstoftwo{\eq@try@layout@L}}% |

1840 | % This is sensitively dependent on the code that currently |

1841 | % follows! Talk about bug prone! Watch out! |

1842 | \def\@tempa##1{\csname iffalse\endcsname}% |

1843 | \eq@repack@compact |

1844 | \fi |

1845 | \fi |

1846 | \fi |

1847 | \@tempa |

1848 | } |

1849 | \def\eq@trial@c#1#2{% |

1850 | \debug\message{^^J}\gubed |

1851 | \debugwr{Trying layout "#1" with parshape^^J|== \space\@xp\@gobble\@parshape}% |

1852 | \begingroup |

1853 | \eq@trial@init |

1854 | \def\eq@layout{#1}% |

1855 | \setbox\z@\vbox{% |

1856 | \hfuzz\maxdimen |

1857 | \eq@trial@p % run the given parshape |

1858 | % \ifnum\eq@lines>\@ne \@xp\eq@compact@test \fi |

1859 | \if\@Not{\eq@badline}% |

1860 | \eq@trial@save\EQ@trial |

1861 | \if@eq@number |

1862 | \if i\eq@layout |

1863 | \else |

1864 | \if A\eq@layout \let\eq@shiftnumber\@True |

1865 | \else \eq@retry@with@number |

1866 | \fi |

1867 | \if\eq@shiftnumber |

1868 | \begingroup |

1869 | \EQ@trial |

1870 | \let\@parshape\eq@parshape \let\eq@shiftnumber\@True |

1871 | \eq@trial@save\EQ@trial |

1872 | \endgroup |

1873 | \fi |

1874 | \fi |

1875 | \fi |

1876 | \if L\eq@layout \eq@check@density |

1877 | \else |

1878 | \if\@Not{\eq@badline}% |

1879 | \aftergroup\@gobbletwo |

1880 | \global\EQ@continue{\eq@trial@done}% |

1881 | \fi |

1882 | \fi |

1883 | \else |

1884 | \eq@trial@save\EQ@last@trial |

1885 | \fi |

1886 | }% end of vbox |

1887 | \EQ@fallback{#2}% |

1888 | \endgroup |

1889 | } |

1890 | \def\eq@check@density{% |

1891 | \if\@Or{\@Not\EQ@hasLHS}{\eq@shortLHS}% |

1892 | \aftergroup\@gobbletwo % cancel the \EQ@fallback code |

1893 | \global\EQ@continue{\eq@trial@done}% |

1894 | \else |

1895 | \if\eq@dense@enough |

1896 | \aftergroup\@gobbletwo % cancel the \EQ@fallback code |

1897 | \global\EQ@continue{\eq@trial@done}% |

1898 | \fi |

1899 | \fi |

1900 | } |

1901 | \def\eq@retry@with@number{% |

1902 | \debugwr{Retry-with-number: wdT=\the\eq@bodywidth, freewidth=\the\eq@freewidth}% |

1903 | \toks@\@xp{\EQ@trial}\debugwr{EQ@trial: \the\toks@}% |

1904 | \ifdim\eq@bodywidth>\eq@freewidth \eq@retry@with@number@a \fi |

1905 | } |

1906 | \let\eq@shiftnumber\@False |

1907 | \def\eq@retry@with@number@a{% |

1908 | \adjust@for@number % depends on number placement |

1909 | \debug\message{^^J}\gubed\debugwr{Retrying (to make room for the number) with parshape^^J|== \space\@xp\@gobble\@parshape}% |

1910 | \nointerlineskip |

1911 | \edef\eq@prev@lines{\the\eq@lines}% |

1912 | \eq@trial@p |

1913 | \int@b\eq@prev@lines \advance\int@b\@ne |

1914 | \ifnum\eq@lines>\int@b |

1915 | \let\eq@shiftnumber\@True |

1916 | \else |

1917 | \if\@Not{\eq@badline}% |

1918 | \let\eq@shiftnumber\@False |

1919 | \eq@trial@save\EQ@trial |

1920 | \else |

1921 | \let\eq@shiftnumber\@True |

1922 | \fi |

1923 | \fi |

1924 | } |

1925 | \def\adjust@for@number{% |

1926 | \debugwr{eq@freewidth=\the\eq@freewidth??}% |

1927 | \dim@d\wd\EQ@numbox \advance\dim@d\eqnumsep |

1928 | \debugwr{Adjusting by +\the\dim@d}% |

1929 | \@xp\let\@xp\adjust@for@number@b |

1930 | \csname adjust@for@number@\eqnumside\eqnumplace\endcsname |

1931 | \@xp\adjust@for@number@a\@parshape\relax |

1932 | } |

1933 | \def\adjust@for@number@a#1 #2\relax{% |

1934 | \edef\@parshape{#1}% |

1935 | \adjust@for@number@b#2 @ @ \relax |

1936 | } |

1937 | \def\adjust@for@number@LT#1 #2 {% |

1938 | \ifx @#1\edef\@parshape{\@parshape\relax}% |

1939 | \@xp\@gobble |

1940 | \else |

1941 | \dim@a#1\advance\dim@a\dim@d |

1942 | \dim@b#2\advance\dim@b-\dim@d |

1943 | \edef\@parshape{\@parshape\space\the\dim@a\space\the\dim@b}% |

1944 | \fi |

1945 | \adjust@for@number@LT |

1946 | } |

1947 | \def\adjust@for@number@LM{% |

1948 | \ifnum\eq@lines>\tw@ |

1949 | \advance\dim@d\eq@bodywidth |

1950 | \advance\dim@d-\eq@linewidth |

1951 | \fi |

1952 | \debugwr{No, adjusting by +\the\dim@d\space instead}% |

1953 | \adjust@for@number@LT |

1954 | } |

1955 | \def\adjust@for@number@RM#1 #2 {% |

1956 | \ifx @#1\edef\@parshape{\@parshape\relax}% |

1957 | \@xp\@gobble |

1958 | \else |

1959 | \dim@c#2\relax |

1960 | \dim@b\eq@freewidth |

1961 | \advance\dim@b-#1\advance\dim@b-\dim@c |

1962 | \ifdim\dim@b<\z@ \advance\dim@c\dim@b |

1963 | \ifdim\dim@c<\p@ \dim@c\p@\relax \fi |

1964 | \fi |

1965 | \edef\@parshape{\@parshape\space#1 \the\dim@c}% |

1966 | \fi |

1967 | \adjust@for@number@RM |

1968 | } |

1969 | \def\eq@trial@p{% |

1970 | \@parshape % |

1971 | \eq@dump@box\unhcopy\EQ@copy |

1972 | {\@@par}% leave \parshape readable |

1973 | \eq@lines\prevgraf |

1974 | \debugmsg{Number of lines: \number\eq@lines}% |

1975 | \eq@fix@lastline |

1976 | \let\eq@badline\@False |

1977 | \if i\eq@layout \ifnum\eq@lines>\@ne \let\eq@badline\@True \fi\fi |

1978 | \eq@curline\eq@lines % loop counter for eq@measure@lines |

1979 | \let\eq@measurements\@empty |

1980 | \eq@ml@record@indents |

1981 | \eq@measure@lines |

1982 | \eq@recalc |

1983 | } |

1984 | \let\adjust@rel@penalty\@empty |

1985 | \def\eq@shortLHS{0\ifdim\eq@wdL>.44\eq@bodywidth \@xp 1\else \@xp 0\fi} |

1986 | \def\eq@longLHS{0\ifdim\eq@wdL>6em \@xp 0\else \@xp 1\fi} |

1987 | \def\eq@nextlayout#1{% |

1988 | \endgroup |

1989 | \debugwr{Nope ... that ain't gonna work.}% |

1990 | \begingroup #1% |

1991 | } |

1992 | \def\eq@trial@d#1#2{\eq@trial@c{#1}{}} |

1993 | \let\EQ@fallback\@empty |

1994 | \def\eq@ml@record@indents{% |

1995 | \int@a\z@ |

1996 | \def\@tempa{% |

1997 | \advance\int@a\@ne |

1998 | \@xp\edef\csname eq@i\number\int@a\endcsname{\the\dim@a}% |

1999 | \ifnum\int@a<\int@b \afterassignment\@tempb \fi |

2000 | \dim@a |

2001 | }% |

2002 | \def\@tempb{\afterassignment\@tempa \dim@a}% |

2003 | \def\@tempc##1##2 {\int@b##2\afterassignment\@tempa\dim@a}% |

2004 | \@xp\@tempc\@parshape |

2005 | } |

2006 | \chardef\eq@zek=`\! |

2007 | \chardef\eq@kez=`\? |

2008 | \def\eq@measurements{% |

2009 | \eq@zek 4.5pt/5.0pt,66.0ptx6.8pt+2.4pt@27\eq@kez |

2010 | ... |

2011 | } |

2012 | \def\eq@measure@lines{% |

2013 | \let\eq@ml@continue\eq@measure@lines |

2014 | \setbox\tw@\lastbox \dim@b\wd\tw@ % find target width of line |

2015 | \setbox\z@\hbox to\dim@b{\unhbox\tw@}% check for overfull |

2016 | \eq@badness\badness |

2017 | \ifnum\eq@badness<\inf@bad \else \let\eq@badline\@True \fi |

2018 | \eq@ml@a \eq@ml@continue |

2019 | } |

2020 | \def\eq@ml@a{% |

2021 | \setbox\tw@\hbox{\unhbox\z@ \unskip}% find natural width |

2022 | \debug\ifnum\eq@badness<\inf@bad\else\debugmsg{!?! Overfull: \the\wd\tw@ >\the\dim@b}\fi\gubed |

2023 | \ifdim\dim@b<\wd\tw@ \dim@a\dim@b % shrunken line |

2024 | \else \dim@a\wd\tw@ % OK to use natural width |

2025 | \fi |

2026 | \skip@a\lastskip \unskip \unpenalty |

2027 | \ifdim\skip@a=\z@ |

2028 | \let\eq@ml@continue\relax % end the recursion |

2029 | \else |

2030 | % Sum repeated vskips if present |

2031 | \def\@tempa{% |

2032 | \ifdim \lastskip=\z@ |

2033 | \else \advance\skip@a\lastskip \unskip\unpenalty \@xp\@tempa |

2034 | \fi |

2035 | }% |

2036 | \fi |

2037 | \edef\eq@measurements{\eq@zek |

2038 | \the\skip@a\space^^J% extra space to facilitate extracting only the |

2039 | % dimen part later |

2040 | \csname eq@i% |

2041 | \ifnum\eq@curline<\parshape \number\eq@curline |

2042 | \else\number\parshape |

2043 | \fi |

2044 | \endcsname,\the\dim@a x\the\ht\tw@+\the\dp\tw@ @\the\eq@badness\eq@kez |

2045 | \eq@measurements |

2046 | }% |

2047 | \advance\eq@curline\m@ne |

2048 | \ifnum\eq@curline=\z@ \let\eq@ml@continue\relax\fi |

2049 | } |

2050 | \def\eq@ml@vspace{% |

2051 | \global\advance\eq@vspan\lastskip \unskip\unpenalty |

2052 | \ifdim\lastskip=\z@ \else \@xp\eq@ml@vspace \fi |

2053 | } |

2054 | \def\eq@dense@enough{% |

2055 | \ifnum\eq@lines<\thr@@ \@True |

2056 | \else |

2057 | \ifdim\eq@wdL >.7\eq@bodywidth \@False |

2058 | \else \@xp\@xp\@xp\eq@dense@enough@a |

2059 | \fi |

2060 | \fi |

2061 | } |

2062 | \def\true@false@true{\fi\fi\iftrue\iffalse\iftrue} |

2063 | \def\false@false@false{\fi\fi\iffalse\iffalse\iffalse} |

2064 | \def\false@true@false{\fi\fi\iffalse\iftrue\iffalse} |

2065 | \def\eq@density@factor{.475} |

2066 | \def\eq@dense@enough@a{% |

2067 | \@True \fi |

2068 | \ifnum\eq@lines>\sixt@@n |

2069 | \eq@dense@enough@b |

2070 | \else |

2071 | \dim@b\z@ \let\eq@zek\eq@delt \eq@measurements |

2072 | \dim@c\eq@density@factor\eq@bodywidth \multiply\dim@c\eq@lines |

2073 | \debugwr{black \the\dim@b/\eq@density@factor total \the\dim@c}% |

2074 | \ifdim\dim@b>\dim@c \true@false@true \else \false@false@false \fi |

2075 | \fi |

2076 | } |

2077 | \def\eq@delt#1^^J#2,#3x#4+#5@#6\eq@kez{\advance\dim@b#3\relax}% |

2078 | \def\eq@dense@enough@b{% |

2079 | \int@b\eq@bodywidth \divide\int@b\p@ |

2080 | \dim@b\eq@wdL \divide\dim@b\int@b |

2081 | \dim@c\eq@lines\p@ \multiply\dim@c\f@ur |

2082 | \int@b\eq@lines \multiply\int@b 9 \advance\int@b -10% |

2083 | \divide\dim@c\int@b |

2084 | \debugwr{l/t \the\dim@b\space< \the\dim@c\space 4n/(9n-10)?}% |

2085 | \ifdim\dim@b<\dim@c \true@true@true \else \false@true@false \fi |

2086 | } |

2087 | \def\adjust@parshape#1{% |

2088 | \@xp\adj@psh@a \csname adjust@parshape@#1@\eq@layout\endcsname |

2089 | } |

2090 | \def\adj@psh@a#1{% |

2091 | \ifx\@@undefined#1\relax |

2092 | \debugmsg{UNDEFINED: \string#1}% |

2093 | \else \@xp#1\eq@parshape |

2094 | \fi |

2095 | } |

2096 | \def\adj@psh@b#1{% |

2097 | \debugmsg{Adjusting parshape (\eqindent\if@eq@number\eqnumside\eqnumplace\fi @\eq@layout)}% |

2098 | \edef\eq@parshape{\parshape \number\eq@lines}% |

2099 | \let\eq@zek#1\eq@measurements \let\eq@zek\relax |

2100 | \edef\eq@parshape{\eq@parshape\relax}% |

2101 | \leftskip\z@skip |

2102 | } |

2103 | \def\adjust@parshape@C@L#1 #2 #3 #4 #5\relax{% |

2104 | \dim@a\leftskip \advance\dim@a#4\relax |

2105 | \edef\eq@parshape{#1 \the\leftskip\space#3 \the\dim@a\space#5\relax}% |

2106 | \leftskip\z@skip |

2107 | } |

2108 | \def\adjust@parshape@C@D#1 #2 #3 #4 #5\relax{% |

2109 | \dim@b\eq@linewidth \advance\dim@b-\eq@bodywidth |

2110 | \debugmsg{linewidth - wdT = \the\eq@linewidth\space- \the\eq@bodywidth\space=\the\dim@b}% |

2111 | \advance\dim@b-\eqmargin |

2112 | \debugmsg{ - eqmargin (\the\eqmargin) = \the\dim@b}% |

2113 | \advance\dim@b#4\relax |

2114 | \debugmsg{ + #4 = \the\dim@b}% |

2115 | \dim@a\eqmargin |

2116 | \adj@psh@b\C@Deq@zek |

2117 | } |

2118 | \def\C@Deq@zek#1^^J#2,#3x#4\eq@kez{% |

2119 | \edef\eq@parshape{\eq@parshape\space \the\dim@a\space #3}% |

2120 | \dim@a\dim@b % use dim@b for all remaining lines |

2121 | } |

2122 | \def\adjust@parshape@C@S#1 #2 #3 #4 #5\relax{% |

2123 | \dim@b#4\relax % normally = \eqmargin |

2124 | \dim@d\eq@linewidth \advance\dim@d-\eq@bodywidth |

2125 | \ifdim\dim@d<2\dim@b |

2126 | \dim@c\leftskip |

2127 | \advance\dim@d-\dim@c |

2128 | \else \advance\dim@d-2\dim@b |

2129 | \dim@c\dim@b |

2130 | \fi |

2131 | \advance\dim@d-\dim@c \advance\dim@d\dim@b |

2132 | \int@a\eq@lines \advance\int@a\m@ne |

2133 | \ifnum\int@a>\@ne \divide\dim@d\int@a \fi |

2134 | \debugmsg{dim@d after dividing: \the\dim@d}% |

2135 | \adj@psh@b\C@Seq@zek |

2136 | } |

2137 | \def\C@Seq@zek#1^^J#2,#3x#4+#5@#6\eq@kez{% |

2138 | \edef\eq@parshape{\eq@parshape\space \the\dim@c\space #3}% |

2139 | \advance\dim@c\dim@d |

2140 | } |

2141 | \def\adjust@parshape@CRM@D#1 #2 #3 #4 #5\relax{% |

2142 | \dim@b\eq@linewidth \advance\dim@b-\eq@bodywidth |

2143 | \debugmsg{linewidth - wdT = \the\eq@linewidth\space- \the\eq@bodywidth\space=\the\dim@b}% |

2144 | \advance\dim@b-\eqnumsep \advance\dim@b-\wd\EQ@numbox |

2145 | \debugmsg{ - numsep (\the\eqnumsep) - numwd (\the\wd\EQ@numbox) = \the\dim@b}% |

2146 | \advance\dim@b#4\relax |

2147 | \debugmsg{ + #4 = \the\dim@b}% |

2148 | \dim@a\eqmargin |

2149 | \adj@psh@b\C@Deq@zek |

2150 | } |

2151 | \def\adjust@parshape@CRM@L{\adjust@parshape@C@L} |

2152 | \def\adjust@parshape@CRM@S#1 #2 #3 #4 #5\relax{% |

2153 | \dim@b#4\relax % normally = \eqmargin |

2154 | \dim@d\eq@linewidth \advance\dim@d-\eq@bodywidth |

2155 | \advance\dim@d-\eqnumsep \advance\dim@d -\wd\EQ@numbox |

2156 | \ifdim\dim@d<\dim@b \dim@c\leftskip |

2157 | \else \dim@c\dim@b |

2158 | \fi |

2159 | \advance\dim@d-\dim@c \advance\dim@d\dim@b |

2160 | \int@a\eq@lines \advance\int@a\m@ne |

2161 | \ifnum\int@a>\@ne \divide\dim@d\int@a \fi |

2162 | \debugmsg{dim@d after dividing: \the\dim@d}% |

2163 | \adj@psh@b\C@Seq@zek |

2164 | } |

2165 | \def\adjust@parshape@CRM@A#1\relax{\debugmsg{CRM@A: #1}} |

2166 | \def\adjust@parshape@CRM@l#1\relax{\debugmsg{CRM@l: #1}} |

2167 | \let\eq@parshape\@empty |

2168 | \def\eq@params{% |

2169 | \baselineskip\eqlinespacing |

2170 | \lineskip\eqlineskip \lineskiplimit\eqlineskiplimit |

2171 | \clubpenalty\@M \widowpenalty\@M \interlinepenalty\eqinterlinepenalty |

2172 | \linepenalty\eqlinepenalty \exhyphenpenalty9999 |

2173 | \rightskip\eqrightskip |

2174 | \ifdim\hfuzz<\p@ \hfuzz\p@ \fi |

2175 | \advance\rightskip \z@\@minus\hfuzz |

2176 | \hfuzz\z@ |

2177 | \parfillskip\z@skip |

2178 | \if\eq@centerlines |

2179 | \advance\leftskip\rightskip \advance\leftskip -1\rightskip |

2180 | \fi |

2181 | \tolerance9999 \pretolerance\m@ne |

2182 | \hbadness\tolerance |

2183 | } |

2184 | \def\eq@dump@box#1#2{% |

2185 | %\debug@box#1% |

2186 | \debugwr{Dumping with leftskip = \the\leftskip, |

2187 | \ifx\@empty\eq@parshape \else eq\fi @parshape =}% |

2188 | \debugwr{\ifx\@empty\eq@parshape \@parshape \else\eq@parshape\fi}% |

2189 | \noindent #1#2\setbox\f@ur\lastbox \setbox\tw@\lastbox |

2190 | \if L\eq@layout \box\tw@ \else\unhbox\tw@\fi |

2191 | \adjust@rel@penalty \unhbox\f@ur |

2192 | } |

2193 | \def\eq@C{% |

2194 | \debugmsg{\eq@sidespace\the\eq@sidespace, \eq@bodywidth\the\eq@bodywidth, \eq@linewidth\the\eq@linewidth}% |

2195 | \eq@params |

2196 | \leftskip\eq@sidespace |

2197 | \adjust@parshape{C}% |

2198 | \eq@parshape |

2199 | \eq@topspace{\noindent}% |

2200 | \ifx F\eq@frame |

2201 | \else |

2202 | \vbox to\eq@firstht{\hbox to\z@{\eq@addframe\hss}\vss}% |

2203 | \fi |

2204 | \eq@dump@box\unhbox\EQ@box \@@par |

2205 | } |

2206 | \def\eq@CRB{% |

2207 | \if\eq@shiftnumber |

2208 | \leftskip\eq@sidespace |

2209 | \else |

2210 | \ifnum\eq@lines=\@ne |

2211 | \leftskip\eq@sidespace \advance\leftskip\eqnumsep |

2212 | \ifdim\leftskip<3\wd\EQ@numbox |

2213 | \multiply\leftskip\tw@ \divide\leftskip\thr@@ |

2214 | \ifdim\leftskip<2\eqnumsep |

2215 | \leftskip\eq@sidespace \divide\leftskip\tw@ |

2216 | \fi |

2217 | \debugmsg{Shifting off-center: leftskip \the\leftskip}% |

2218 | \else |

2219 | \divide\leftskip\tw@ |

2220 | \debugmsg{Plenty of room: leftskip \the\leftskip}% |

2221 | \fi |

2222 | \fi |

2223 | \fi |

2224 | \eq@CRBa |

2225 | } |

2226 | \def\eq@CRBa{% |

2227 | \eq@topspace{\noindent}% |

2228 | \ifx F\eq@frame |

2229 | \else \vbox to\eq@firstht{\hbox to\z@{\eq@addframe\hss}\vss}% |

2230 | \fi |

2231 | \eq@params \eq@parshape |

2232 | \add@grp@label |

2233 | \eq@dump@box\unhbox\EQ@box \@@par |

2234 | \penalty\@M |

2235 | \if\eq@shiftnumber |

2236 | \else |

2237 | \lineskiplimit-\maxdimen \baselineskip\z@skip |

2238 | \fi |

2239 | \hbox to\eq@linewidth{\hfil\copy\EQ@numbox}% |

2240 | } |

2241 | \def\eq@CRM{% |

2242 | \debug |

2243 | \dim@a\eq@bodywidth \advance\dim@a\eqnumsep \advance\dim@a\wd\EQ@numbox |

2244 | \debugmsg{\hsize\the\hsize, \eq@linewidth\the\eq@linewidth}% |

2245 | \debugmsg{T+S+N = \the\eq@bodywidth+\the\eqnumsep+\the\wd\EQ@numbox\space= \the\dim@a}% |

2246 | \debugmsg{sidespace: \the\eq@sidespace}% |

2247 | \gubed |

2248 | \ifnum\eq@lines<\tw@ |

2249 | \ifdim\eq@bodywidth>\eq@freewidth \let\eq@shiftnumber\@True\fi |

2250 | \fi |

2251 | \debugmsg{\rightskip=\the\rightskip??}% |

2252 | \parfillskip\z@skip |

2253 | \if\eq@shiftnumber |

2254 | \@xp\eq@CRB % shifted number |

2255 | \else |

2256 | \set@leftskip@for@centering |

2257 | \@xp\eq@CRMa % nonshifted number |

2258 | \fi |

2259 | } |

2260 | \def\set@leftskip@for@centering{% |

2261 | \leftskip\eq@sidespace\relax |

2262 | \ifdim\leftskip>\z@ % when not true? |

2263 | % Skip quickly past the more complicated stuff if not needed (which |

2264 | % is true most of the time) |

2265 | \ifdim\leftskip<2\wd\EQ@numbox |

2266 | \set@leftskip@fca |

2267 | \else |

2268 | \debugwr{Plenty of room: leftskip \the\leftskip}% |

2269 | \fi |

2270 | \fi |

2271 | } |

2272 | \def\set@leftskip@fca{% |

2273 | % Save free space = linewidth - bodywidth - numberwidth in \dim@a |

2274 | \dim@a\eq@linewidth \advance\dim@a-\eq@bodywidth |

2275 | \advance\dim@a-\wd\EQ@numbox |

2276 | \ifdim\dim@a<\eqnumsep |

2277 | \leftskip\z@skip |

2278 | \debugwr{Not enough room, wha happend?}% |

2279 | \else |

2280 | % Put two thirds of the free space on the side opposite to the number |

2281 | \leftskip\dim@a \multiply\leftskip\tw@ \divide\leftskip\thr@@ |

2282 | \dim@b\dim@a \advance\dim@b-\leftskip |

2283 | % But if that leaves less than eqnumsep for the other side, we need |

2284 | % to do some more adjusting. |

2285 | \ifdim\dim@b<\eqnumsep |

2286 | \leftskip\dim@a \advance\leftskip-\eqnumsep |

2287 | \debugwr{Off-center: far side \the\leftskip, near side \the\eqnumsep |

2288 | (\string\eqnumsep)}% |

2289 | \else |

2290 | \debugwr{Off-center: far side \the\leftskip\space (2/3 F), near side \the\dim@b\space (1/3 F)}% |

2291 | \fi |

2292 | \fi |

2293 | \if L\eqnumside |

2294 | % leftskip=.67F dim@a=.33F (e.g.) |

2295 | % swap dim@a and leftskip, then add number width to leftskip |

2296 | % and subtract it from rightskip |

2297 | \dim@b\dim@a \advance\dim@b-\leftskip |

2298 | \dim@a\leftskip \leftskip\dim@b |

2299 | \advance\leftskip\wd\EQ@numbox |

2300 | \edef\rightskip@shift{\advance\rightskip-\wd\EQ@numbox}% |

2301 | \fi |

2302 | \relax % watch it! |

2303 | } |

2304 | \let\rightskip@shift\@empty |

2305 | \def\eq@CRMa{% |

2306 | \eq@topspace{\vskip\parskip}% |

2307 | \vbox to\eq@firstht{% |

2308 | \ifx F\eq@frame |

2309 | \else |

2310 | \moveright\leftskip\hbox to\z@{\eq@addframe\hss}% |

2311 | \fi |

2312 | \vss}% |

2313 | \penalty\@M |

2314 | \skip@c\eq@vspan |

2315 | \advance\skip@c-\ht\EQ@numbox \advance\skip@c-\dp\EQ@numbox |

2316 | \divide\skip@c\tw@ |

2317 | \parskip-\skip@c |

2318 | \advance\parskip-\ht\EQ@numbox \advance\parskip-\dp\EQ@numbox |

2319 | \advance\skip@c-\eq@firstht |

2320 | \vskip\skip@c \nointerlineskip |

2321 | \hbox to\hsize{\hfil\copy\EQ@numbox}% |

2322 | \nobreak |

2323 | \eq@params |

2324 | \adjust@parshape{CRM}% |

2325 | \eq@parshape |

2326 | \nointerlineskip \noindent\add@grp@label \eq@dump@box\unhbox\EQ@box % |

2327 | % \tracingparagraphs=2 \@@par \tracingparagraphs=0% |

2328 | \@@par |

2329 | } |

2330 | \def\eq@CLM{% |

2331 | \ifnum\eq@lines=\@ne |

2332 | \ifdim\eq@freewidth<\wd\EQ@box |

2333 | \let\eq@shiftnumber\@True |

2334 | \fi |

2335 | \fi |

2336 | \if\eq@shiftnumber |

2337 | \eq@CLT |

2338 | \else |

2339 | \set@leftskip@for@centering |

2340 | \rightskip\eqrightskip % see also \eq@params |

2341 | \parfillskip\z@skip |

2342 | \ifnum\eq@lines>\@ne \eq@topspace{\vskip\parskip}% |

2343 | \else \vskip\abovedisplayskip |

2344 | \fi |

2345 | \vbox to\eq@firstht{% |

2346 | \ifx F\eq@frame |

2347 | \else |

2348 | \moveright\leftskip\hbox to\z@{\eq@addframe\hss}% |

2349 | \fi |

2350 | \vss}% |

2351 | \nointerlineskip |

2352 | \penalty\@M |

2353 | \vskip@for@number % also sets parskip for the following material |

2354 | \copy\EQ@numbox |

2355 | \nobreak |

2356 | \eq@params |

2357 | \rightskip@shift % compensate for left-hand number |

2358 | \debugmsg{\rightskip=\the\rightskip}% |

2359 | \eq@parshape |

2360 | %\debug@box\EQ@box\tracingparagraphs\@ne\debug@para |

2361 | \nointerlineskip |

2362 | \noindent\add@grp@label \eq@dump@box\unhbox\EQ@box \@@par |

2363 | \fi |

2364 | } |

2365 | \def\vskip@for@number{% |

2366 | \skip@c\eq@vspan \advance\skip@c-\ht\EQ@numbox |

2367 | \advance\skip@c-\dp\EQ@numbox \divide\skip@c\tw@ |

2368 | \parskip-\skip@c |

2369 | \advance\parskip-\ht\EQ@numbox \advance\parskip-\dp\EQ@numbox |

2370 | \advance\skip@c-\eq@firstht |

2371 | \vskip\skip@c |

2372 | } |

2373 | \def\eq@CLT{% |

2374 | \if\eq@shiftnumber |

2375 | \if A\eq@layout \eq@reindent@A |

2376 | \else \leftskip\eq@sidespace \divide\leftskip\tw@ |

2377 | \fi |

2378 | \else |

2379 | \leftskip\eq@sidespace \advance\leftskip\eqnumsep |

2380 | \ifnum\eq@lines=\@ne |

2381 | \ifdim\eq@sidespace<2\wd\EQ@numbox |

2382 | \multiply\leftskip\tw@ \divide\leftskip\thr@@ |

2383 | %\debugmsg{Shifting off-center: leftskip \the\leftskip}% |

2384 | \else |

2385 | \divide\leftskip\tw@ |

2386 | %\debugmsg{Plenty of room: leftskip \the\leftskip}% |

2387 | \fi |

2388 | \else |

2389 | \divide\leftskip\tw@ |

2390 | \fi |

2391 | \fi |

2392 | \eq@CLTa |

2393 | } |

2394 | \def\eq@CLTa{% |

2395 | \vskip\abovedisplayskip |

2396 | \copy\EQ@numbox \penalty\@M |

2397 | \if\eq@shiftnumber \else \kern-\eq@firstht \nointerlineskip \fi |

2398 | \noindent |

2399 | \ifx F\eq@frame |

2400 | \else \vbox to\eq@firstht{\hbox to\z@{\eq@addframe\hss}\vss}% |

2401 | \fi |

2402 | \eq@params \eq@parshape |

2403 | \add@grp@label \eq@dump@box\unhbox\EQ@box\@@par |

2404 | } |

2405 | \def\eq@IRM{\leftskip\mathindent \eq@CRMa} |

2406 | \def\eq@IRB{\leftskip\mathindent \eq@CRBa} |

2407 | \def\eq@I{% |

2408 | \leftskip\mathindent |

2409 | \eq@params |

2410 | \eq@topspace{\noindent}% |

2411 | \ifx F\eq@frame |

2412 | \else |

2413 | \vbox to\eq@firstht{\hbox to\z@{\eq@addframe\hss}\vss}% |

2414 | \fi |

2415 | \eq@dump@box\unhbox\EQ@box\@@par |

2416 | } |

2417 | \newcommand\eqframe[2]{\framebox{\z@rule\@height#2\kern#1}} |

2418 | \def\eq@addframe{% |

2419 | \hbox to\z@{\dim@a\fboxsep \advance\dim@a\fboxrule |

2420 | \kern-\dim@a |

2421 | \vbox to\z@{\kern-\dim@a |

2422 | \hbox{\eqframe{\eq@bodywidth}{\eq@vspan}}% |

2423 | \vss |

2424 | }% |

2425 | \hss |

2426 | }% |

2427 | } |

2428 | \@saveprimitive\left\@@left |

2429 | \@saveprimitive\right\@@right |

2430 | \newcount\lr@level |

2431 | \def\eq@left{% |

2432 | \@ifnext .{\eq@nullleft}{\begingroup \let\delimiter\eq@left@a}% |

2433 | } |

2434 | \def\eq@right{% |

2435 | \@ifnext .{\eq@nullright}{\begingroup \let\delimiter\eq@right@a}% |

2436 | } |

2437 | \def\eq@left@a#1 #2{\endgroup\@@left\delimiter#1 \after@open} |

2438 | \def\eq@right@a#1 #2{\endgroup |

2439 | \@@right\delimiter#1 \after@close\ss@scan{#1}% |

2440 | } |

2441 | \def\eq@nullleft#1{\@@left#1\after@open} |

2442 | \def\eq@nullright#1{\@@right#1\after@close} |

2443 | \def\delim@reset{% |

2444 | \let\after@open\relax \let\after@close\relax |

2445 | \let\left\@@left \let\right\@@right |

2446 | } |

2447 | \@ifundefined{bBigg@}{% not defined |

2448 | \let\big@size\p@ |

2449 | \def\big{\bBigg@{8.5}}\def\Big{\bBigg@{11.5}}% |

2450 | \def\bigg{\bBigg@{14.5}}\def\Bigg{\bBigg@{17.5}}% |

2451 | \def\biggg{\bBigg@{20.5}}\def\Biggg{\bBigg@{23.5}}% |

2452 | }{} |

2453 | \def\bBigg@#1#2{% |

2454 | {\delim@reset |

2455 | \left#2% |

2456 | \vrule\@height#1\big@size\@width-\nulldelimiterspace |

2457 | \right. |

2458 | }% |

2459 | } |

2460 | \def\bigl#1{\mathopen\big{#1}\after@open} |

2461 | \def\Bigl#1{\mathopen\Big{#1}\after@open} |

2462 | \def\biggl#1{\mathopen\bigg{#1}\after@open} |

2463 | \def\Biggl#1{\mathopen\Bigg{#1}\after@open} |

2464 | \def\bigggl#1{\mathopen\biggg{#1}\after@open} |

2465 | \def\Bigggl#1{\mathopen\Biggg{#1}\after@open} |

2466 | |

2467 | \def\bigr#1{\mathclose\big{#1}\after@close} |

2468 | \def\Bigr#1{\mathclose\Big{#1}\after@close} |

2469 | \def\biggr#1{\mathclose\bigg{#1}\after@close} |

2470 | \def\Biggr#1{\mathclose\Bigg{#1}\after@close} |

2471 | \def\bigggr#1{\mathclose\biggg{#1}\after@close} |

2472 | \def\Bigggr#1{\mathclose\Biggg{#1}\after@close} |

2473 | |

2474 | %% No change needed, I think. [mjd,1998/12/04] |

2475 | %%\def\bigm{\mathrel\big} |

2476 | %%\def\Bigm{\mathrel\Big} |

2477 | %%\def\biggm{\mathrel\bigg} |

2478 | %%\def\Biggm{\mathrel\Bigg} |

2479 | %%\def\bigggm{\mathrel\biggg} |

2480 | %%\def\Bigggm{\mathrel\Biggg} |

2481 | \let\m@@DeL\m@DeL \let\m@@DeR\m@DeR \let\m@@DeB\m@DeB |

2482 | \def\d@@DeL#1#2#3{% |

2483 | \delimiter"4\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 \after@open |

2484 | } |

2485 | \def\d@@DeR#1#2#3{% |

2486 | \delimiter"5\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 \after@close |

2487 | } |

2488 | \def\d@@DeB#1#2#3{% |

2489 | \delimiter"0\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 \after@bidir |

2490 | } |

2491 | \let\after@bidir\@empty |

2492 | \mathchardef\zero@bop=888 \relax |

2493 | \mathchardef\bop@incr=4444 \relax |

2494 | \def\after@open{% |

2495 | \global\advance\lr@level\@ne |

2496 | \prebinoppenalty\bop@incr \multiply\prebinoppenalty\lr@level |

2497 | \advance\prebinoppenalty\zero@bop |

2498 | \ifnum\eqbreakdepth<\lr@level |

2499 | \let\m@Bin\m@@Bin |

2500 | \else |

2501 | \eq@binoffset=\eqbinoffset |

2502 | \advance\eq@binoffset\lr@level\eqdelimoffset plus1fill\relax |

2503 | \def\dt@fill@cancel{\hskip\z@ minus1fill\relax}% |

2504 | \fi |

2505 | \nobreak |

2506 | } |

2507 | \def\after@close{% |

2508 | \global\advance\lr@level\m@ne |

2509 | \ifnum\lr@level<\z@ \eq@lrbad \global\lr@level\z@ \fi |

2510 | \prebinoppenalty\bop@incr \multiply\prebinoppenalty\lr@level |

2511 | \advance\prebinoppenalty\zero@bop |

2512 | \ifnum\eqbreakdepth<\lr@level |

2513 | \else \let\m@Bin\d@@Bin |

2514 | \fi |

2515 | \ifnum\lr@level<\@ne \eq@binoffset=\eqbinoffset\relax \fi |

2516 | } |

2517 | \def\eq@lrbad{% |

2518 | \PackageError{breqn}{Too many closing delimiters?}{% |

2519 | The unmatched delimiter might be further back.\MessageBreak |

2520 | \@ehc |

2521 | }% |

2522 | } |

2523 | \let\subsup@flag=\count@ |

2524 | \def\ss@delim@a#1#2#3#4{\xdef\right@delim@code{\number"#2#3#4}} |

2525 | \def\ss@scan#1{% |

2526 | \begingroup |

2527 | \let\delim@a\ss@delim@a \@tempcnta#1\relax |

2528 | \endgroup |

2529 | \subsup@flag\@M \afterassignment\ss@scan@a \let\@let@token=} |

2530 | \def\ss@scan@a{% |

2531 | \ifx\@let@token\sb \advance\subsup@flag\@ne\else |

2532 | \ifx\@let@token\sp \advance\subsup@flag\tw@\else |

2533 | \ss@finish |

2534 | \expandafter\@firstoftwo % gobble \ss@scan@b |

2535 | \fi\fi |

2536 | \ss@scan@b\@let@token |

2537 | } |

2538 | \def\ss@scan@b#1#2{#1{% |

2539 | % hack! coff! |

2540 | \let\m@Bin\m@@Bin \let\m@Rel\m@@Rel |

2541 | #2}\afterassignment\ss@scan@a \let\@let@token=}% |

2542 | \def\ss@finish{% |

2543 | \@@vadjust{\penalty\thr@@}% |

2544 | \penalty\right@delim@code \penalty-\subsup@flag \keep@glue |

2545 | } |

2546 | \def\eq@lrunpack{\setbox\z@\lastbox |

2547 | \unskip \nointerlineskip |

2548 | \noindent\unhbox\z@ \unskip |

2549 | \subsup@flag-\lastpenalty \unpenalty |

2550 | \xdef\right@delim@code{\number\lastpenalty}% |

2551 | \unpenalty |

2552 | \ifnum\subsup@flag>\@M |

2553 | \advance\subsup@flag-\@M |

2554 | \setbox\tw@\lastbox |

2555 | \else \setbox\tw@\box\voidb@x |

2556 | \fi |

2557 | \setbox\z@\lastbox |

2558 | \ifvoid\tw@ \unhbox\z@ |

2559 | \else \lrss@reattach % uses \subsup@flag, box\z@, box\tw@ |

2560 | \fi |

2561 | \penalty-\@Mi\z@rule\@@par |

2562 | \setbox\z@\lastbox \unskip\unpenalty |

2563 | %%{\showboxbreadth\maxdimen\showboxdepth99\showlists}% |

2564 | } |

2565 | \dimendef\sub@depth=8 \dimendef\sup@base=6 |

2566 | \dimendef\prelim@sub@depth=4 \dimendef\prelim@sup@base=2 |

2567 | \def\sym@xheight{\fontdimen5\textfont\tw@} |

2568 | \def\sup@base@one{\fontdimen13\textfont\tw@} |

2569 | \def\sub@base@one{\fontdimen16\textfont\tw@} |

2570 | \def\sub@base@two{\fontdimen17\textfont\tw@} |

2571 | \def\sup@drop{\fontdimen18\scriptfont\tw@} |

2572 | \def\sub@drop{\fontdimen19\scriptfont\tw@} |

2573 | \providecommand{\mathaxis}{\fontdimen22\textfont\tw@} |

2574 | \def\lrss@reattach{% |

2575 | \begingroup |

2576 | % "The TeXbook" Appendix G step 18: |

2577 | \prelim@sup@base\ht\z@ \advance\prelim@sup@base-\sup@drop |

2578 | \prelim@sub@depth\dp\z@ \advance\prelim@sub@depth\sub@drop |

2579 | \unhbox\z@ |

2580 | \ifcase\subsup@flag % case 0: this can't happen |

2581 | \or \lr@subscript % case 1: subscript only |

2582 | \or \lr@superscript % case 2: superscript only |

2583 | \else \lr@subsup % case 3: sub and superscript both |

2584 | \fi |

2585 | \endgroup |

2586 | } |

2587 | \def\lr@subscript{% |

2588 | \sub@depth\sub@base@one |

2589 | \ifdim\prelim@sub@depth>\sub@depth \sub@depth\prelim@sub@depth\fi |

2590 | \dim@a\ht\tw@ \advance\dim@a -.8\sym@xheight |

2591 | \ifdim\dim@a>\sub@depth \sub@depth\dim@a \fi |

2592 | \twang@adjust\sub@depth |

2593 | \lower\sub@depth\box\tw@ |

2594 | } |

2595 | \def\lr@superscript{% |

2596 | \sup@base\sup@base@one |

2597 | \ifdim\prelim@sup@base>\sup@base \sup@base\prelim@sup@base\fi |

2598 | \dim@a\dp\tw@ \advance\dim@a -.25\sym@xheight |

2599 | \ifdim\dim@a>\sup@base \sup@base\dim@a \fi |

2600 | \twang@adjust\sup@base |

2601 | \raise\sup@base\box\tw@ |

2602 | } |

2603 | \def\lr@subsup{% |

2604 | \sub@depth\sub@base@two |

2605 | \ifdim\prelim@sub@depth>\sub@depth \sub@depth\prelim@sub@depth \fi |

2606 | \twang@adjust\sub@depth |

2607 | \lower\sub@depth\box\tw@ |

2608 | } |

2609 | \def\twang@adjust#1{% |

2610 | \begingroup |

2611 | \@ifundefined{twang@\right@delim@code}{}{% |

2612 | \dim@d=#1\advance\dim@d-\mathaxis |

2613 | % put an upper limit on the adjustment |

2614 | \ifdim\dim@d>1em \dim@d 1em \fi |

2615 | \kern\csname twang@\right@delim@code\endcsname\dim@d |

2616 | }% |

2617 | \endgroup |

2618 | } |

2619 | \edef\next{\catcode0=\the\catcode0\relax} |

2620 | \catcode0=\active\let^^@\@empty |

2621 | \newcommand{\DeclareTwang}[2]{% |

2622 | \ifcat.\@nx#1\begingroup |

2623 | \lccode0=`#1\lowercase{\endgroup \DeclareTwang{^^@}}{#2}% |

2624 | \else |

2625 | \@xp\decl@twang#1?\@nil{#2}% |

2626 | \fi |

2627 | } |

2628 | \next |

2629 | \def\decl@twang#1#2#3#4#5#6#7\@nil#8{% |

2630 | \global\@namedef{twang@\number"#4#5#6}{#8}% |

2631 | } |

2632 | \DeclareTwang{\rangle}{-.4} |

2633 | \DeclareTwang{)}{-.33} |

2634 | \DeclareTwang{\rbrace}{-.25} |

2635 | \newenvironment{dseries}{\@eq@numbertrue \@optarg\@dseries{}}{}% |

2636 | \def\enddseries#1{\check@punct@or@qed} |

2637 | \def\@dseries[#1]{% |

2638 | \def\display@setup{\displaystyle}% |

2639 | \let\eq@centerlines\@True |

2640 | \@dmath[#1]% |

2641 | \mathsurround\z@\@@math \penalty\@Mi |

2642 | \let\endmath\ends@math |

2643 | \def\premath{% |

2644 | \ifdim\lastskip<.49em \unskip\fi |

2645 | \ifnum\lastpenalty<\@M\dquad\fi |

2646 | }% |

2647 | \def\postmath{\eq@addpunct \penalty-99 \dquad \@ignoretrue }% |

2648 | } |

2649 | \def\end@dseries{% |

2650 | \unskip\unpenalty |

2651 | \@@endmath \mathsurround\z@ \end@dmath |

2652 | } |

2653 | \newenvironment{dseries*}{\@eq@numberfalse \@optarg\@dseries{}}{} |

2654 | \@namedef{enddseries*}#1{\check@punct@or@qed} |

2655 | \@namedef{end@dseries*}{\end@dseries} |

2656 | \renewenvironment{math}{% |

2657 | \leavevmode \premath |

2658 | \ifmmode\@badmath\else\@@math\fi |

2659 | }{% |

2660 | \ifmmode\@@endmath\else\@badmath\fi |

2661 | } |

2662 | \def\ends@math#1{\check@punct@or@qed} |

2663 | \def\end@math{% |

2664 | \ifmmode\@@endmath\else\@badmath\fi |

2665 | \postmath |

2666 | } |

2667 | \newcommand\dquad{\hskip1em minus.25em } |

2668 | \newcommand\premath{}\newcommand\postmath{} |

2669 | \let\eq@group\@False |

2670 | \global\let\GRP@top\@True |

2671 | \newenvironment{dgroup}{% |

2672 | \@eq@numbertrue \@optarg\@dgroup{}% |

2673 | }{% |

2674 | \end@dgroup{\grp@resetnumber}% |

2675 | } |

2676 | \newtoks\GRP@queue |

2677 | \newenvironment{dgroup*}{% |

2678 | \@eq@numberfalse \@optarg\@dgroup{}% |

2679 | }{ |

2680 | \end@dgroup{}% |

2681 | } |

2682 | \def\@dgroup[#1]{% |

2683 | \let\eq@group\@True \global\let\GRP@top\@True |

2684 | \global\GRP@queue\@emptytoks \global\setbox\GRP@box\box\voidb@x |

2685 | \global\let\GRP@label\@empty |

2686 | \gdef\GRP@info{\grp@wdL\z@ \grp@bodywidth\z@ \grp@linewidth\z@}% |

2687 | \eq@prelim |

2688 | \setkeys{breqn}{#1}% |

2689 | \if@eq@number \grp@setnumber \fi |

2690 | } |

2691 | \def\end@dgroup#1{% |

2692 | \EQ@displayinfo \grp@finish |

2693 | #1% \grp@resetnumber |

2694 | } |

2695 | \@ifundefined{c@parentequation}{\newcounter{parentequation}}{} |

2696 | \global\let\GRP@label\@empty |

2697 | \def\add@grp@label{% |

2698 | \ifx\@empty\GRP@label |

2699 | \else \GRP@label \global\let\GRP@label\@empty |

2700 | \fi |

2701 | } |

2702 | \def\grp@setnumber{% |

2703 | \global\let\GRP@label\next@label \global\let\next@label\@empty |

2704 | \eq@setnumber |

2705 | \protected@edef\theparentequation{\theequation}% |

2706 | \setcounter{parentequation}{\value{equation}}% |

2707 | \setcounter{equation}{0}% |

2708 | \def\theequation{\theparentequation\alph{equation}}% |

2709 | } |

2710 | \def\grp@resetnumber{% |

2711 | \setcounter{equation}{\value{parentequation}}% |

2712 | } |

2713 | \gdef\GRP@info{\grp@wdL\z@ \grp@bodywidth\z@ \grp@linewidth\z@} |

2714 | \newbox\GRP@box |

2715 | \def\grp@push{% |

2716 | \global\GRP@queue\@xp\@xp\@xp{\@xp\the\@xp\GRP@queue |

2717 | \@xp\eq@zek\@xp{\EQ@trial}% |

2718 | }% |

2719 | \global\setbox\GRP@box\vbox{% |

2720 | \hbox{\box\EQ@box\box\EQ@copy\penalty\@ne\copy\EQ@numbox}% |

2721 | \unvbox\GRP@box |

2722 | }% |

2723 | \EQ@trial \GRP@info |

2724 | \xdef\GRP@info{% |

2725 | \grp@wdL=\ifdim\eq@wdL>\grp@wdL \the\eq@wdL \else \the\grp@wdL \fi |

2726 | \grp@bodywidth=\ifdim\eq@bodywidth>\grp@bodywidth \the\eq@bodywidth \else \the\grp@bodywidth \fi |

2727 | \grp@linewidth=% |

2728 | \ifdim\eq@linewidth>\grp@linewidth \the\eq@linewidth |

2729 | \else \the\grp@linewidth |

2730 | \fi |

2731 | \relax |

2732 | }% |

2733 | } |

2734 | \def\grp@finish{% |

2735 | \debug@box\GRP@box |

2736 | %\debugmsg{\GRP@queue: \the\GRP@queue}% |

2737 | \GRP@info |

2738 | \grp@wdL\z@ \grp@bodywidth\z@ |

2739 | \let\eq@zek\eqgrp@prelim |

2740 | \the\GRP@queue |

2741 | \advance\grp@bodywidth\grp@wdL |

2742 | \debugmsg{grp@wdL \the\grp@wdL, grp@bodywidth \the\grp@bodywidth}% |

2743 | \let\eq@zek\eqgrpeq@zek |

2744 | \the\GRP@queue |

2745 | \let\eq@zek\relax |

2746 | \eq@botspace |

2747 | } |

2748 | \def\eqgrp@prelim#1{% |

2749 | #1% |

2750 | \ifdim\eq@wdL>\grp@wdL \grp@wdL\eq@wdL \fi |

2751 | \dim@a\eq@bodywidth \advance\dim@a-\eq@wdL |

2752 | \ifdim\dim@a>\grp@bodywidth \grp@bodywidth\dim@a \fi |

2753 | } |

2754 | \def\eqgrpeq@zek#1{% |

2755 | \global\setbox\GRP@box\vbox{% |

2756 | \unvbox\GRP@box |

2757 | \setbox\z@\lastbox |

2758 | \setbox\tw@\hbox{\unhbox\z@ |

2759 | \ifnum\lastpenalty=\@ne |

2760 | \else |

2761 | \global\setbox\EQ@numbox\lastbox |

2762 | \fi |

2763 | \unpenalty |

2764 | \global\setbox\EQ@copy\lastbox |

2765 | \global\setbox\EQ@box\lastbox |

2766 | }% |

2767 | }% |

2768 | \begingroup \let\eq@botspace\relax |

2769 | #1% |

2770 | \eq@finish |

2771 | \endgroup |

2772 | } |

2773 | \newskip\darraycolsep \darraycolsep 20pt plus1fil minus12pt |

2774 | \newcount\cur@row \newcount\cur@col |

2775 | \def\@tempa#1#2#3{% |

2776 | \cur@col#1 \hfil |

2777 | \setbox\z@\hbox{$\displaystyle####\m@th$}\@nx\col@box |

2778 | \tabskip\z@skip |

2779 | &\cur@col#2 \hfil |

2780 | \setbox\z@\hbox{$\displaystyle\mathord{}####\mathord{}\m@th$}\@nx\col@box |

2781 | \hfil |

2782 | &\cur@col#3 \setbox\z@\hbox{$\displaystyle####\m@th$}\@nx\col@box |

2783 | \hfil\tabskip\darraycolsep |

2784 | } |

2785 | \xdef\darray@preamble{% |

2786 | \@tempa 123&\@tempa 456&\@tempa 789% |

2787 | &\@tempa{10}{11}{12}&\@tempa{13}{14}{15}&\@tempa{16}{17}{18}% |

2788 | \cr |

2789 | } |

2790 | \@ifundefined{Mathstrut@}{\let\Mathstrut@\strut}{} |

2791 | \def\darray@cr{\Mathstrut@\cr} |

2792 | \def\col@box{% |

2793 | %\debugmsg{Col \number\cur@row,\number\cur@col: \the\wd\z@\space x \the\ht\z@+\the\dp\z@}% |

2794 | \unhbox\z@ |

2795 | } |

2796 | \newenvironment{darray}{\@optarg\@darray{}}{} |

2797 | \def\@darray[#1]{% |

2798 | \if\eq@group\else\eq@prelim\fi |

2799 | \global\let\@preamble\@empty |

2800 | \setkeys{breqn}{#1}% |

2801 | \the\eqstyle \eq@setnumber |

2802 | \ifx\@preamble\@empty \global\let\@preamble\darray@preamble \fi |

2803 | \check@mathfonts |

2804 | % \let\check@mathfonts\relax % tempting, but too risky |

2805 | \@xp\let\csname\string\ \endcsname\darray@cr |

2806 | \setbox\z@\vbox\bgroup |

2807 | \everycr{\noalign{\global\advance\cur@row\@ne}}% |

2808 | \tabskip\z@skip \cur@col\z@ |

2809 | \global\cur@row\z@ |

2810 | \penalty\@ne % flag for \dar@repack |

2811 | \halign\@xp\bgroup\@preamble |

2812 | } |

2813 | \def\enddarray#1{\check@punct@or@qed} |

2814 | \def\end@darray{% |

2815 | \ifvmode\else \eq@addpunct \Mathstrut@\fi\crcr \egroup |

2816 | \dar@capture |

2817 | \egroup |

2818 | } |

2819 | \def\dar@capture{% |

2820 | %% \showboxbreadth\maxdimen\showboxdepth99\showlists |

2821 | \eq@wdL\z@ \eq@wdRmax\z@ \eq@sidespace\maxdimen |

2822 | \dar@repack |

2823 | } |

2824 | \def\dar@repack{% |

2825 | \unpenalty |

2826 | \setbox\tw@\lastbox |

2827 | %\batchmode{\showboxbreadth\maxdimen\showboxdepth99\showbox\tw@}\errorstopmode |

2828 | \global\setbox\EQ@box\hbox{% |

2829 | \hbox{\unhcopy\tw@\unskip}\penalty-\@M \unhbox\EQ@box}% |

2830 | \global\setbox\EQ@copy\hbox{% |

2831 | \hbox{\unhbox\tw@\unskip}\penalty-\@M \unhbox\EQ@copy}% |

2832 | \unskip |

2833 | \ifcase\lastpenalty \else\@xp\@gobble\fi |

2834 | \dar@repack |

2835 | } |

2836 | \newskip\conditionsep \conditionsep=10pt minus5pt% |

2837 | \newcommand{\conditionpunct}{,} |

2838 | \let\cond@gobble\@firstofone |

2839 | \newcommand\condition{% |

2840 | \begingroup\@tempswatrue |

2841 | \@ifstar{\@tempswafalse \condition@a}\condition@a |

2842 | } |

2843 | \newcommand\condition@a[2][\conditionpunct]{% |

2844 | \hbox{#1}\hskip\conditionsep |

2845 | \if@tempswa \@xp\hbox \else \@xp\condition@b\fi |

2846 | {#2}% |

2847 | \endgroup |

2848 | \let\cond@gobble\@gobble |

2849 | } |

2850 | \newcommand\condition@b[1]{% |

2851 | \cond@gobble{\hskip\conditionsep}% |

2852 | \textmath@setup #1% |

2853 | } |

2854 | \newenvironment{dsuspend}{% |

2855 | \global\setbox\EQ@box\vbox\bgroup \@parboxrestore |

2856 | \parshape 1 \displayindent \displaywidth\relax |

2857 | \hsize=\columnwidth \noindent\ignorespaces |

2858 | }{% |

2859 | \par\egroup |

2860 | \global\setbox\GRP@box\vbox{% |

2861 | \vbox{\copy\EQ@box\vtop{\unvbox\EQ@box}}% |

2862 | \unvbox\GRP@box |

2863 | }% |

2864 | \global\GRP@queue\@xp{\the\GRP@queue |

2865 | \eq@zek{\gdef\EQ@trial{}}% |

2866 | }% |

2867 | } |

2868 | \newcommand\breqn@intertext[1]{\dsuspend#1\enddsuspend} |

2869 | \renewcommand{\*}{% |

2870 | \if@display |

2871 | \setbox\z@\hbox{\mathsurround\z@$\mkern\eq@binoffset$}% |

2872 | \discretionary{}{% |

2873 | \kern\the\wd\z@ \textchar\discretionarytimes |

2874 | }{}% |

2875 | \thinspace |

2876 | \else |

2877 | \discretionary{\thinspace\textchar\discretionarytimes}{}{}% |

2878 | \fi |

2879 | } |

2880 | \newcommand{\discretionarytimes}{\times} |

2881 | \def\nref#1{\@xp\@nref\csname r@#1\endcsname} |

2882 | \def\@nref#1#2{\ifx\relax#1??\else \@xp\@firstoftwo#1\fi} |

2883 | \breqnpopcats |

2884 | %</package> |

2885 | % \end{macrocode} |

**Note:**See TracBrowser for help on using the repository browser.