Skip to content
Talk to an engineerRequest access

Wrapping and overflow

How long formulas break into lines, and what a formula that cannot break does — scroll, shrink, clip or paint past the edge.

The expansion of (a + b)³ broken into three lines in a 300-pixel box, each continuation line starting with = under the first =

A block display formula (displayMode: true) breaks into lines that fit the available width. In display style it breaks before relations and binary operators, so each continuation line starts with its operator, and the continuation lines line up under the first relation of the first line.

Option Default What it does
Math.wrap true for block display formulas Break long formulas into lines.
LayoutOptions.lineBreaking LineBreaking.auto Where breaks may fall: auto (display style for display math, TeX’s rule for inline math), tex (after operators and relations), display (before them), or none.
LayoutOptions.alignContinuation true Continuation lines line up under the first relation.
LayoutOptions.continuationIndent 2 Indent of continuation lines, in em, when they are not aligned.
LayoutOptions.repeatOperator false When a line breaks before an operator, also show it at the end of the line before.

A single symbol or box wider than the line still overflows it.

An inline Math.tex does not wrap by default, and as one box it could only break into a block of lines anyway. Inside a paragraph, use MathText: it splits each inline formula at its TeX break points (after binary operators and relations) and lets them wrap with the words, choosing the paragraph’s line breaks together so no line is left very short.

overflow decides what a formula that is still too wide does — when no break fits, or wrap is off. Block display formulas scroll by default; other formulas paint past the edge.

The same integral in a 140-pixel box three times: shrunk to fit, cut off at the right edge in a horizontal scroll view, and clipped on both sides

MathOverflow Behaviour
scroll Scroll horizontally. The default for block display formulas.
shrink Scale down to fit, but not below minShrink (0.5 by default); a formula that needs more is shown at that scale and scrolls.
clip Clip at the edges.
visible Paint past the edge. The default for everything else.

Whichever mode applies, the widget reports the formula’s baseline (scaled when shrunk), so it still lines up with text in a baseline Row.

Without Flutter, LayoutOptions.maxWidth (in em) breaks a formula to a width, and prepareFormula lays a formula out once so that layoutAt(width) re-runs only the line breaker. See Layout.