Numbers, tables and totals / Multi-currency total
Showing a total in two currencies without the columns going ragged
A total repeated in a second currency, usually because the document is issued in one currency and has to be settled or reported in another.
Why this block is harder than it looks
Two currencies means two symbols of different widths, two conventions for the decimal separator, and two figures whose magnitudes can differ by a factor of a hundred. Set that as ordinary right-aligned text and the column goes ragged: the symbol sits hard against the digits on one line and a space away on the next, and a figure with a thousands separator pushes wider than one without. The conversion rate also has to appear somewhere, because a converted figure with no rate beside it is not verifiable, and people do check.
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.
- Split symbol and amount into separate boxes and give the symbol box a fixed width. Right-align the amount, left-align the symbol inside its box, and the two currencies line up regardless of symbol width.
- Use tabular figures on both. Proportional digits in a column of money is the most common typographic mistake in generated documents.
- Format each amount with the separators of its own currency convention rather than the document's, and do it in the code that produced the number, not in CSS.
- Print the rate and the date it was taken, in smaller type directly beneath. A converted total without a rate is a claim rather than a figure.
- Mark clearly which currency is actually payable. If both are set at the same weight the reader has to guess, and half of them guess wrong.
- Keep the pair together with break-inside: avoid, since a converted figure separated from its original is worse than useless.
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.
<section class="dual-total">
<div class="row primary">
<span class="label">Total due</span>
<span class="cur">EUR</span><span class="amt">4,180.00</span>
</div>
<div class="row secondary">
<span class="label">Equivalent</span>
<span class="cur">USD</span><span class="amt">4,556.20</span>
</div>
<p class="rate">Converted at 1 EUR = 1.09 USD, rate of 14 March 2026.
Payment is due in EUR.</p>
</section>
<style>
.dual-total { break-inside: avoid; width: 52%; margin-left: auto; }
.dual-total .row {
display: grid;
grid-template-columns: 1fr 34pt 76pt; /* label, symbol, amount */
align-items: baseline;
padding: 3pt 0;
}
.dual-total .cur { font-size: 8.5pt; letter-spacing: 0.04em; }
.dual-total .amt {
text-align: right;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.dual-total .primary {
font-weight: 700;
border-top: 1pt solid currentColor;
padding-top: 5pt;
}
.dual-total .secondary { color: #555; }
.dual-total .rate { margin-top: 5pt; font-size: 8pt; color: #555; }
</style>What breaks when it is built the obvious way
Formatting both amounts with the document locale. A reader in a country that uses a comma decimal separator, looking at a figure printed with a point, reads it correctly. A reader looking at two figures printed with different separators on adjacent lines stops and works out which is which, and that pause is exactly what a payment document cannot afford.
How to prove it survived pagination
Render with amounts of different magnitudes on the two lines, one four digits and one seven, and confirm the symbols still line up and neither amount wraps. Then render with the longest currency code you support and confirm the symbol box is still wide enough.
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 commercial invoice 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.
Discount and surcharge lines that read correctly on paper
Rows that reduce or increase the amount without being goods or services, which have to be legible as adjustments rather than as more items.
Carried forward and brought forward totals on a long table
The running figure printed at the foot of each page and repeated at the top of the next, so a multi-page table can be checked page by page instead of only at the end.
A running balance column that stays readable over many pages
A column on a transaction table showing the balance after each movement, which turns a list of events into something a reader can audit line by line.
A contact block where the long email address does not break the layout
Phone, email, reference number and website, usually set small under a name or in a footer, and usually the block that overflows first.
Commercial invoice, as a complete file
The whole document with this block already in place, ready to copy and change.
font-variant-numeric in paged output
The property carrying the weight here, with its real support status.
Every part of a document
The full list, grouped by the kind of problem the block poses.
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.