Converting a thesis or a long report, chapter by chapter

Last reviewed

Converting a three-hundred-page thesis in one operation is possible and almost always the wrong approach. Not because of size, but because a long document is rarely one kind of document, and a single conversion has to settle on one set of assumptions for all of it.

Splitting first costs ten minutes and removes most of the failure modes below.

8 minute read

One document, several layouts

A thesis typically contains a single-column preface, a two-column body or a single-column one, a table-heavy results chapter, an appendix of scanned forms, and a bibliography set with hanging indents. Those are five conversion problems, and they want five different sets of assumptions.

The reason this matters more than it sounds is the unit of measure. The body-text height is computed once, from the whole document, as the most common font height weighted by how many characters are set at it. Every heading threshold, every paragraph break and every table column boundary is a multiple of that one number.

So a document whose appendices are set two points smaller than its body pulls that average, and the thresholds shift for the whole file. Converted alone, the appendix gets its own correct unit. Converted inside the thesis, it gets the body's.

Split before you convert

Split at the boundaries where the layout changes, not at the boundaries in the table of contents. Those are often the same, and where they differ, follow the layout.

  • Front matter, from the title page to the end of the contents. It is mostly headings and page numbers and converts into very little of value.
  • The body, split by chapter if the chapters are long or in one piece if the layout is uniform throughout.
  • Any results or data chapter that is mostly tables, on its own. Tables benefit most from being measured against their own page.
  • Appendices, individually. They are the part most likely to be scanned, set differently, or landscape.
  • The bibliography, on its own, since it needs an entirely different treatment afterwards.

What happens at a page boundary

Inside a page, whether two lines belong to the same paragraph is decided by the vertical gap between them: up to one and a half body heights continues the paragraph, more starts a new one.

Across a page break that measurement is meaningless, so the decision falls back to the text. A paragraph is treated as continuing when the previous line did not end in sentence-ending punctuation and the next line does not begin with a capital letter.

That heuristic is right most of the time and wrong in two predictable places. A sentence ending in an abbreviation at the foot of a page is read as continuing. A page beginning with a proper noun mid-sentence is read as a new paragraph. In a long document these accumulate, so it is worth searching the assembled Markdown for paragraphs that begin mid-clause.

Running headers and footers

Repeated page furniture is detected and removed, and the rule is worth knowing because it explains what survives.

Lines in the top or bottom twelve per cent of a page are candidates. Digits are normalised, so page one of twelve and page two of twelve count as the same header. A candidate is removed when it appears on at least half the pages, with a floor of two, and the check only runs on documents of three pages or more.

The consequence for long documents: a running header carrying the chapter title changes at every chapter, so in a twelve-chapter thesis no single version reaches half the pages and none of them is removed. This is one of the strongest arguments for splitting by chapter, where each chapter's header does repeat on most of its pages and is duly stripped.

The contents page is not worth converting

A table of contents converts into a list of headings with page numbers attached, and it is worth deleting rather than repairing. Every page number in it refers to a pagination that no longer exists once the document is Markdown, and the structure it describes is already present as the actual headings.

If you want navigation, generate it from the converted headings afterwards. Most editors, static site generators and note tools will do it automatically, and a generated contents list stays correct when the document is edited.

The same applies to an index. A back-of-book index is a mapping from terms to page numbers, and once there are no page numbers there is nothing left of it. Search replaces it completely.

The assembly pass

With the parts converted, putting them back together is mechanical, and doing it in this order avoids rework.

  • Normalise the heading levels across parts first. Each part was converted independently, so each has its own level-one heading, and chapter three's level two is not necessarily the same rank as chapter four's.
  • Concatenate in reading order, with the parts as sections under a single top-level heading if the result is one file.
  • Rejoin paragraphs broken at part boundaries. There will be one at each seam, and they are easy to find because they are the first line of each part.
  • Check the tables last, once, in the assembled file. Doing it per part means checking the same reflex several times.
  • Delete the converted contents page and any converted index.

When one file is the wrong output

A three-hundred-page Markdown file is searchable and unpleasant to work in. Most editors handle it, most note tools do not, and it dominates every search result it appears in.

One file per chapter with an index note linking them is almost always the better shape, and it is what the split above has already produced. The assembly pass is worth doing only when the destination genuinely wants a single document, such as a repository where one file per chapter would be noise.

There is also a hard ceiling to be aware of in the other direction. If you intend to send the result back out as a PDF using the exporter on this site, documents past roughly half a million characters are refused — not as a policy limit, but because paginating a document that size in a browser stops being slow and starts being a frozen tab. A thesis is comfortably inside that. A converted corpus concatenated into one file may not be.