Typst Book Typesetting for KDP
Typst compiles Markdown-like manuscripts into print-ready KDP PDFs in under a second, giving engineers and indie authors deterministic book layout without LaTeX bloat.
Traditional book pipelines force an ugly split. Word processors drift across page breaks whenever you change a single heading, while XeLaTeX and Memoir take twenty seconds per compile and obscure every margin rule behind nested macros. Typst replaces both with a single Rust binary that resolves page geometry, alternating inside/outside margins, running headers, drop caps, and widows in one predictable pass.
This handbook documents exact Typst configurations verified against Amazon KDP Print Previewer, alongside open-source scaffolding and hosted compilers. If you prefer a browser pipeline that runs Typst compilation, KDP spine wrap assembly, and EPUB 3 packaging without writing code, MakeThisABook runs a production Typst typesetting engine starting with a free preview and $19 per full book pass (or $59 lifetime typesetter access for existing manuscripts).
Minimal KDP Book Preamble
Start every paperback template with explicit page width, height, alternating inside/outside margins, and embedded book typography so KDP preflight passes first try.
#set page(
width: 6in,
height: 9in,
margin: (
inside: 0.75in,
outside: 0.625in,
top: 0.75in,
bottom: 0.75in,
),
header: context {
let pg = counter(page).get().first()
if pg > 1 and calc.even(pg) [
#set text(size: 8.5pt, fill: luma(90))
#align(left)[BOOK TITLE]
] else if pg > 1 [
#set text(size: 8.5pt, fill: luma(90))
#align(right)[CHAPTER RUNNING HEAD]
]
},
footer: context {
let pg = counter(page).get().first()
if pg > 1 [
#set text(size: 9pt)
#align(center)[#pg]
]
},
)
#set text(font: "EB Garamond", size: 11pt, lang: "en")
#set par(justify: true, leading: 0.68em, first-line-indent: 1.25em)
Three lines in this preamble stop the majority of automated KDP rejections. First, naming inside and outside margins instead of left and right tells Typst to mirror page geometry automatically across verso (even) and recto (odd) spreads. Second, checking counter(page).get().first() inside context prevents running heads from colliding with chapter openers and title pages. Third, setting explicit line leading around 0.68em (roughly 14.5pt baseline-to-baseline on 11pt serif copy) gives trade paperbacks comfortable density without pushing page count into a higher KDP gutter bracket.
Core Pipeline Stages
A repeatable book build splits drafting, pagination, cover geometry, and ebook packaging into four discrete steps that never overwrite one another.
| Stage | Primary Input | Verified Deliverable | Common Failure Mode |
|---|---|---|---|
| 1. Structural Draft | Chapters in Markdown or Typst | Clean semantic heading tree | Hard line breaks and pasted Word styles |
| 2. Interior Compile | Trim spec + font bundle | Print PDF with embedded fonts | Unembedded fallback fonts or tight gutter |
| 3. Cover Wrap Math | Final page count + stock | Back + spine + front wrap PDF | Stale spine width after final copy edit |
| 4. Digital Package | Semantic HTML + cover JPEG | Reflowable EPUB 3 (epubcheck) | Fixed PDF line breaks copied into reflow |
Keeping stage 3 strictly downstream of stage 2 matters more than beginners expect. Adding just fourteen pages during proofreading shifts a cream paperback spine by 0.035 inches, which is enough to pull spine typography off-center or trigger KDP barcode clearance warnings. Automated builders eliminate this drift by computing spine width directly from the compiled PDF page count rather than an author estimate.
Open CLI and MCP Tooling
Use the open-source KDP CLI and MCP server to calculate exact spine dimensions, verify gutter brackets, and scaffold starter Typst templates in one command.
npx -y https://github.com/bitgate/makethisabook-mcp spine --pages 240 --trim 6x9 --paper cream --json
npx -y https://github.com/bitgate/makethisabook-mcp init --trim 6x9 --pages 240 --out ./my-book
The makethisabook-mcp repository publishes deterministic KDP geometry calculations (white, cream, standard color, and premium color paper factors), margin checks, royalty calculators, and starter Typst scaffolding under an MIT license. It runs locally over stdio for Claude Desktop, Cursor, and terminal workflows, and exposes the same calculations remotely for agent tooling without requiring API keys or paid seats.
Read Next: Print Geometry
- Trim Sizes & Gutter Rules: exact Typst margin maps for 5x8, 5.5x8.5, 6x9, and 8.5x11 books.
- KDP Cover Wrap Specs: bleed math, spine thresholds, and barcode quiet zones.
Read Next: Production Workflows
- Dual EPUB & Print Pipelines: single-source publishing without double editing.
- Hosted vs DIY Typst: when local scripts win and when MakeThisABook saves hours.
Quick Decision Checklist
Choose local Typst when you love version-controlling every typographic macro, or pick MakeThisABook when you want print PDF, KDP wrap cover, and EPUB 3 ready fast.
Local Typst excels for technical manuals, math-heavy textbooks, and open-source handbooks where Git diffs, custom diagrams, and CI releases sit beside source code. On the other hand, if you have a rough outline, raw notes, podcast transcripts, or a finished DOCX and want a publication-grade 6x9 paperback interior, matching full-wrap KDP cover, and validated EPUB 3 without tuning ligatures or epubcheck schemas, MakeThisABook handles the complete pipeline from $19 per book ($59 lifetime for formatting your own manuscripts) with full commercial rights and zero recurring subscription lock-in.
Whichever path you select, verify every build artifact before opening KDP Bookshelf: confirm exact trim width and height in inches using pdfinfo, verify every interior typeface reports embedded status in pdffonts, inspect chapter opener pages for suppressed running headers, and verify that cover wrap width accounts for exact compiled interior page count rather than an uncompiled chapter estimate.