GuidesEbooks and EPUBTables, code and technical content in an ebook

Tables, code and technical content in an ebook

A reflowable ebook is one flowing column of text whose width the reader sets and you never see. Prose is happy there. Anything whose meaning lives in a two-dimensional arrangement — a grid, an indented listing, a stacked equation — is working against the format rather than with it.

This is the material that reflow punishes hardest, and the honest answer is rarely a clever trick. It is usually a decision to hold the content differently.

A table has columns and a phone does not

A table is a fixed number of columns. A phone in portrait, at a type size a middle-aged reader has chosen, gives you something on the order of forty characters across. Six columns will not fit in forty characters. Nothing you do to the markup changes that arithmetic: the reading system can shrink the type, squeeze the columns past legibility, scroll the table sideways, or clip it, and every one of those is a worse table.

So the question is not how to make a six-column table work on a phone. It is what to do instead.

The four options, in order

1. Restructure the data as labeled blocks. Turn each row into a short block, with the column headings as labels in front of their values. A ten-row, five-column table becomes ten small stacked entries. It works on every screen at every type size, it reads aloud correctly, and it is usually clearer than the table was, because a reader on a phone was going to take it one row at a time anyway. This is the right answer far more often than authors expect.

2. Cut the table down to two or three columns. If the grid really is the point, make it narrow enough to survive. Two columns almost always fit. Three usually do with short entries. Often a wide table is two narrow tables that were joined for the convenience of the printed page, and splitting them back apart costs nothing.

3. Let it scroll sideways. A table can be given its own horizontal scroll so it slides within the page rather than breaking the layout. Support varies between reading systems, so treat it as an improvement where it works rather than something to rely on — and a reader scrolling sideways to compare two numbers is not comparing them.

4. Ship it as an image, with the full content in the alt text. The last resort, and a real loss: text inside an image cannot be searched, selected or resized, so it ignores the reader's type settings like any other picture. It is defensible for a grid that genuinely cannot be reduced, and only if the alt text carries the entire content rather than describing it. "Table of results" is not alt text. The whole table, read out in a sensible order, is.

Note what is missing from that list: shrinking the type until the table fits. That is the one approach that fails everywhere.

The printed edition of the same book has no such problem, and it is worth setting the two differently rather than making one file serve both — Tables, charts and data in a printed book covers the print half, and EPUB and print PDF are two different books covers why they diverge.

In the Interior Formatter. It reads a .docx and keeps structure only — chapter starts, italics, bold, scene breaks — which is why a table is worth restructuring before you import it. Images, including a table supplied as one, are placed inline or as full-page plates, and their alt text is carried into the EPUB. Start your ebook → · about the Interior Formatter

Code and preformatted text

Code has a rule that ordinary prose does not: the line breaks are content. A listing that reflows is a listing that has been altered. Preformatted text has to be marked as preformatted so the reading system knows not to re-wrap it.

  • Long lines have nowhere to go. Either the block scrolls sideways, which varies by app, or the line wraps in a place you did not choose and the listing reads as broken. The fix is on your side of the file: keep lines short enough to survive a narrow screen. Somewhere near sixty characters is a sane ceiling, and shorter is safer.
  • Indent with spaces, not tabs. A tab is an instruction to advance to a stop that the reading system defines, and different systems define it differently or drop it. Spaces are characters and survive as they are. Convert every tab before you export.
  • A monospaced face is the one justified font request. Normally you should let the reader's chosen typeface win. Code is the exception, because column alignment and telling one character from another both depend on fixed widths. Ask for the generic monospaced family rather than naming a specific font, so each device supplies one it actually has. Our six body faces are text faces for prose, chosen for long reading rather than listings.
  • Watch the punctuation. Smart quotes and dashes are correct in prose and wrong in code, where a curled quotation mark is a different character from a straight one. Accents, symbols and characters that go missing has the general version of that trap.

Mathematics is genuinely hard

An equation is a two-dimensional object: numerator over denominator, limits above and below, a radical enclosing a whole expression. Markup languages exist to express that inside an EPUB, and how well any given store or app renders them varies enough that you cannot assume. Test anything you rely on.

The pragmatic fallback is the same as for the impossible table: supply the equation as an image, with the expression written into the alt text in a form that reads aloud correctly. Inline mathematics of a symbol or two is better set as text with the proper characters, which keeps it selectable and lets it scale with the paragraph.

Musical notation is the same problem with less hope: a stave is engraved elsewhere and placed as an image in both editions, and the image has to be legible at phone width. Printing music and notation covers how that image is produced.

The principle underneath all of it

Anything whose meaning lives in its two-dimensional arrangement is fighting a format built for a single flowing column. You will not win that fight by out-engineering the reading system, because the reader's settings are the last word and there are more reading systems than you can test.

So the winning move is almost always to restructure the content rather than to fight the format: rows become blocks, a wide table becomes two narrow ones, a long line of code becomes two short ones. Before you publish, open the file on the smallest screen you own at the largest type size it offers — see Checking an ebook before you publish it — because everything in this guide either survives that test or does not.


Make your ebook

The tools are free to use: bring your manuscript once and get both a print PDF and an EPUB out of the same source, so the two editions cannot drift apart. You only pay when you want the files without the preview watermark.

Start your ebook →


Next: Reflowable text, and the things that break it · More: Tables, charts and data in a printed book · What makes an EPUB pass validation · Accessible ebooks, and why they are now everyone's problem

Was this helpful?

More in Ebooks and EPUB

Ready to make the ebook?

Bring your manuscript once and get both a print PDF and an EPUB 3 out of the same source, so the two editions cannot drift apart. Start your ebook →