PDFPipe

Numbers, tables and totals / Price break table

A quantity price break table where the bands cannot be misread

Prices that change with quantity, printed as bands, where the boundary between one band and the next is the thing that gets read wrong.

Why this block is harder than it looks

The whole content of the table is where each band starts and stops, and the usual notation hides exactly that. A column headed 1 to 99, 100 to 499, 500 plus is unambiguous. A column headed 1, 100, 500 is not, because a reader with an order of 250 has to infer that the second row covers them, and about a third of readers infer wrongly on a first pass. The second problem is that the bands are ordered by quantity and priced downward, so the cheapest row is at the bottom, which is where the eye goes last.

The decisions that make it work

Reasons rather than a description of the code. Each of these is a choice that has a wrong answer, and the wrong answer is usually the default.

  • Print both ends of every band explicitly, including the last one as an open range. Ranges are three characters longer and remove the whole class of misreading.
  • Use the same word at both ends. From 100 to 499 units and 500 units or more are consistent; 100+ next to 1 to 99 is not.
  • Right-align the quantities and the prices separately, both with tabular figures, so the bands read as a ladder.
  • Give the band boundaries a hairline between rows rather than shading, so the eye sees where one band ends without relying on a background.
  • State the unit once in the column header and the currency once, rather than on every row.
  • Keep the table whole with break-inside: avoid. A price break table split across pages means somebody quotes from the half they can see.

The fragment

Markup and the CSS it needs, and nothing else. It expects a document that already has a page rule and a base stylesheet, so paste it into one rather than opening it on its own.

html
<table class="breaks">
  <thead>
    <tr><th>Quantity (units)</th><th class="n">Price each</th></tr>
  </thead>
  <tbody>
    <tr><td>1 to 99</td><td class="n">2.4050</td></tr>
    <tr><td>100 to 499</td><td class="n">2.1800</td></tr>
    <tr><td>500 to 1,999</td><td class="n">1.9400</td></tr>
    <tr><td>2,000 or more</td><td class="n">1.7600</td></tr>
  </tbody>
</table>

<style>
  .breaks {
    break-inside: avoid;
    border-collapse: collapse;
    font-size: 9pt;
  }
  .breaks th, .breaks td {
    padding: 4pt 12pt 4pt 0;
    border-bottom: 0.4pt solid #ddd;    /* boundaries by rule, not by tint */
  }
  .breaks td:first-child {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .breaks .n {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .breaks thead th { border-bottom-width: 0.75pt; font-weight: 600; }
</style>

What breaks when it is built the obvious way

Listing only the lower bound of each band. It is how the data is stored and it is not how a price list is read, and the reader who gets it wrong is the one placing the order that sits on a boundary.

How to prove it survived pagination

Give the printed table to somebody and ask the price for a quantity that sits one below a boundary, then one above it. Both answers should be immediate. Any hesitation means the ranges are implied rather than printed.

Where it sits in a finished document

This page is one block. The document it belongs to has a page rule, a base stylesheet, a header and everything else around it, and repeating all of that here would make thirty pages that say the same thing. The trade price list template is a complete file with this block already in it, so take that and change the fragment rather than assembling one from parts. The property doing most of the work here is covered on its own page, with the support caveats that belong there rather than here.

Frequently asked

Will this fragment work on its own?

Not as a whole document. It has no page rule, no margins and no base type, because those belong to the document rather than to the block, and duplicating them in every fragment would mean thirty copies to keep in step. Paste it into a template that already has them.

Why does it look right in a browser and wrong in the PDF?

Because a browser window is one continuous surface and a document is a stack of fixed rectangles. Nothing in a scrolling view exercises a page boundary, so every break rule in the fragment is inert until the content is paginated. Render the real thing with enough content to cross two or three boundaries, then look.

Do I need a special option on the render request for this?

No. Everything on this page is CSS and markup, which is your side of the boundary. What the render has to give you is a real page size with real margins, and after that the layout is decided by the stylesheet.

Other parts of a document

The blocks that sit next to this one, and one from the next group along so you are not sealed inside a single kind of problem.

Paste the fragment into the playground inside a page rule and see what it does at a real page size. That is the only way any of this gets confirmed.