Reading Order Before Markdown
PDF has no paragraphs, only positioned glyphs. Extraction starts with text items that carry a transform matrix, width and font reference. Lines are grouped by baseline, then an XY-Cut recursively splits the page along the largest horizontal and vertical whitespace gaps, producing a reading order that handles two-column papers better than naive top-to-bottom sorting.
Headers, footers and page numbers repeat on every page and must be identified by frequency and position, or they become headings in the Markdown. Footnotes sit at the bottom, often above a rule, and superscript markers in the body must be matched to note text. Multi-column layouts with sidebars still confuse projection methods, so review the first pages before converting a book.