Equation Layouts

MJD [1998/12/28]

1 Misc examples

Let us consider which of these have 50% or more of wasted whitespace within the bounding box of the visible material.

display width

\begin{aligned}L & =  R_{1} \\ & =  R_{1} \end{aligned}

2 Ladder and step layouts

2.1 Straight ladder layout

This is distinguished by a relatively short LHS and one or more RHS’s of any length.

display width

L =  R_{1}
=  R_{2}
=  R_{3}

…

The simplest kind of equation that fits on one line and has only one RHS may be viewed as a trivial subcase of the straight ladder layout:

display width

L =  R

If some of the RHS’s are too wide to fit on a single line they may be broken at binary operator symbols such as plus or minus. This is still classified as a straight ladder layout if none of the fragments intrude into the LHS column, because the underlying parshape is the same.

display width

L =  R_{1a}
+  R_{1b}
=  R_{2}
=  R_{3a}
+  R_{3b}
+  R_{3c}
…

2.2 Skew ladder layout

display width

L  =  R_{1}
=  R_{2}
=  R_{3}
…

In a skew ladder layout, the combined LHS width plus width of R_{1} does not exceed the available width, but one of the other RHS’s is so wide that aligning its relation symbol with the others cannot be done without making it run over the right margin: width(L) + width_{max}(R_{i}) > width_{avail}. In that case we next try aligning all but the first relation symbol, allowing all the R_{i} after R_{1} to shift leftward.

2.3 Drop ladder layout

display width

L

=  R_{1}
=  R_{2}
=  R_{3}

…

The drop ladder layout is similar to the skew ladder layout but with the width of R_{1} too large for it to fit on the same line as the LHS. Then we move R_{1} down to a separate line and try again to align all the relation symbols. Note that this layout consumes more vertical space than the skew ladder layout.

2.4 Step layout

display width

R_{a}

+  R_{b}
+  R_{c}
+  R_{d}
…

The chief characteristic of the step layout is that there is no relation symbol, so that the available line breaks are (usually) all at binary operator symbols. Let w_{1} and w_{l} be the widths of the first and last fragments. We postulate that the ideal presentation is as follows: Choose a small stairstep indent I (let’s say 1 or 2 em). We want the last fragment to be offset at least I from the start of the first fragment, and to end at least I past the end of the first fragment. If there are only two lines these requirements determine a target width w_{T} = max(w_{1} +I, w_{l} +I). If there are more than two lines (l > 2) then use w_{T} = max(w_{1} + (l − 1)I, w_{l} + I, w_{avail} and reset I to w_{T} /(l − 1) if w_{T} = w_{avail}.

Furthermore, we would like the material to be distributed as evenly as possible over all the lines rather than leave the last line exceedingly short. If the total width is 1.1(width_{avail}), we don’t want to have .9 of that on line 1 and .2 of it on line 2:

display width

R_{a}  +  R_{b}  +  R_{c} ; + R_{d}

Better to split it as evenly as possible, if the available breakpoints permit.

display width

R_{a}  +  R_{b} ; +  R_{c}  +  R_{d}

A degenerate step layout may arise if an unbreakable fragment of the equation is so wide that indenting it to its appointed starting point would cause it to run over the right margin. In that case, we want to shift the fragment leftward just enough to bring it within the right margin:

display width

L_{a}

+  L_{b}
+  L_{c}
+  L_{d}
…

And then we may want to regularize the indents as in the drop ladder layout. Let’s call this a dropped step layout:

L_{a}

+  L_{b}
+  L_{c}
+  L_{d}
…

display width

Equation Layouts 3

3 Strategy

Here is the basic procedure for deciding which equation layout to use, before complications like equation numbers and delimiter clearance come into the picture. Let A be the available width, w_{total} the total width of the equation contents, w(L) the width of the left-hand side, w_{max}(R) the max width of the righthand sides, I the standard indent for step layout, and O the standard offset for binary operators if a break occurs in the middle of an RHS. Also let t_{L} and t_{R} represent certain thresholds for the width of the LHS or the RHS at which a layout decision may change, as explained below.

(1) Does everything fit on one line? w_{total} ≤ A? Yes: print the equation on a single line (done). No: Check whether the equation has both LHS and RHS (2).

(2) Is there a left-hand side? Are there any relation symbols in the equation? Yes: Try a ladder layout (3). No: Try a step layout (10).

(3) Does the LHS leave room to fit the widest RHS? w(L) + w_{max}(R) < A? Yes: Use a straight ladder layout (5). No: Check the width of the LHS (4).

(4) Is the LHS relatively short? w(L) ≤ t_{L}? (where t_{L} is typically 0.4A). Yes: Subdividing one or more of the RHS’s may permit us to use a straight ladder layout (5). No: The straight ladder layout is unlikely to work. Try a skew or drop ladder layout (6).

(5) Straight ladder layout Set up a straight ladder parshape [0pt A w(L) A−w(L)] and run a trial break. If the combined width of the LHS plus the longest RHS is no greater than A then we should get a satisfactory layout with all line breaks occurring at major division points (relation symbols). Otherwise, we hope, some additional line breaks at minor division points will allow everything to fit within the text column. Line breaks OK? Yes: The straight ladder layout succeeded (done). No: Try a skew or drop ladder layout (6).

(6) Do the LHS and the first RHS fit on one line? w(L) + w(R_{1}) ≤ A? Yes: Try a skew ladder layout (7). No: Try a drop ladder layout (8).

(7) Skew ladder layout Set up a parshape [0pt A I A−I] and run a trial break. Line breaks OK? Yes: Skew ladder layout succeeded (done). No: One of the unbreakable fragments of the R_{i} (i > 1) is wider than A−I; try an almost-columnar layout (9).

(8) Drop ladder layout Set up a parshape [0pt w(L) I A − I] and run a trial break. This is the same parshape as for a skew ladder layout except that the width of the first line is limited to the LHS width,

Equation Layouts 4

so that the RHS is forced to drop down to the next line. Line breaks OK? Yes: Drop ladder layout succeeded (done). No: One of the unbreakable fragments of the R_{i} (i > 1) is wider than A−I; try an almost-columnar layout (9).

(9) Almost-columnar layout This presupposes a trial break that yielded a series of expressions or fragments, one per line. Let w(F) denote the width of the first fragment and w(R_{i}) the widths of the remaining fragments. Set up a parshape [0pt w(F) A − w_{max}(R_{i}) w_{max}(R_{i})]: in other words, set the first line flush left and the longest line flush right and all other lines indented to the same position as the longest line. But as a matter of fact there is one other refinement for extreme cases: if w_{max}(R_{i}) > A then the parshape can be simplified without loss to [0pt w(F) 0pt A]—for that is the net effect of substituting min(A, w_{max}) in stead of w_{max}. (Done.)

(10) Step layout Set target width w_{T} to A − 2I. Set parshape to [0pt w_{T} I w_{T} −I 2I w_{T} −2I … (l −1)I w_{T} − (l − 1)I], where l = ⌈w_{total}/A⌉ is the expected number of lines that will be required. Trial break with that parshape in order to find out the width of the last line. Indents OK? Yes: Step layout succeeded (done). No: One of the fragments is too wide to fit in the allotted line width, after subtracting the indent specified by the parshape. Try a dropped step layout (11)

(11) Dropped step layout Set up a parshape [0pt A I A−I] and run a trial break. Note that this is actually the same parshape as for a skew ladder layout. Line breaks OK? Yes: Dropped step layout succeeded (done). No: One of the unbreakable fragments of the R_{i} (i > 1) is wider than A−I; as a last resort try an almostcolumnar layout (9).

4 CLM layout

Centered equation, Left equation number, vertical placement of the number is Middle.

First find out how much free space F is left over. If F ≥ 3N (width of equation number), then the equation body B can be centered in the display width disregarding the width of the number. The space between the number and the equation is then (F + N)/2 − N.

displaywidth

⟷

N ⟷^{\frac{F +N}{2} −N}  B  ⟷^{\frac{F +N}{2}}

But if F < 3N then put one-third of the free space on the left and two-thirds on the right.

displaywidth

⟷

N ⟷^{\frac{1}{3} F}  B  ⟷^{\frac{2}{3} F}

And furthermore, if the one-third is too small (less than 1em), use 1 em minimum on the left and the remainder on the right.

displaywidth

⟷

N ⟷^{1em (min)}  B  ⟷^{F − 1em}