A Stack Laid out by Hand, One Box at a Time

The report of the example next door lays itself out: the engine chooses where each page breaks. Sometimes the boxes are yours to choose instead — a column beside a picture, a panel on a form, the room left under a letterhead — and the text has to go into them one after another.

Here a delivery slip is poured into a first box too short for it. The box says where it stopped, and the second box takes up from exactly there, so nothing is written twice and nothing is lost. A poster whose picture is taller than any box is refused outright rather than cut in half. Under each box a line gives the height taken and where it starts and ends: figures a program can check before it goes on.

What This Example Shows

  • A stack poured into boxes you choose, one at a time.
  • Each box says where the stack stopped, and the next resumes there.
  • A block taller than its box refused, never cut.

The Source Code, Complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library.

Read the Rust source Read the Python source

The Document Itself

Open the document in English Open the document in French Open the document in German Open the document in Spanish Open the document in Italian Open the document in Portuguese

A Stack Laid out by Hand, One Box at a Time, first page

The Same Document in Other Languages

This document weighs 17.0 kB

Examples Near This One

Breaking an Overlong Word

A word longer than the column that holds it: the library leaves it whole, cuts it at the column's edge, or cuts it and closes the line on a hyphen.

Break Points After a Slash or a Hyphen

A justified column set four times: file paths and compounds running past the edge with no break points, wrapping where a break after a slash or a hyphen is allowed, then wherever their punctuation allows one, and last with no-break hyphens that keep each compound whole.

A Font behind the Font

One line of statuses set twice: in a company font alone, where the characters it has no glyph for come out as empty boxes, then with a second font behind it that draws them.

Every example, by subject