LaTeX quality audit for memoir/XeLaTeX book production — validates generated .tex files against best practices for print-ready output. Use as a quality gate after editorial-typesetting generates LaTeX source, or independently when reviewing any .tex file intended for commercial printing or POD. Catches errors that will break a print file: overfull lines, unembedded fonts, wrong color mode, missing PDF/X compliance, widow/orphan problems, memoir class misuse, and XeLaTeX/fontspec anti-patterns. Also use when the user mentions "LaTeX quality," "check the tex file," "print preflight," "PDF/X," "KDP," "IngramSpark," "crop marks," or "the PDF was rejected by the printer."
Check for editorial context first: If .agents/editorial-context.md exists, read the Typesetting Decisions record — the chosen trim size, bleed, binding type, font, and PDF target inform what to check and what thresholds to apply.
This skill audits .tex files for print-readiness. The editorial-typesetting skill generates LaTeX from markdown; this skill verifies that the output is correct — not just syntactically valid, but professionally sound for commercial book printing or POD submission.
The test of a clean print file: compile it, submit the PDF to the printer, and receive no rejection or technical correction notice.
If the following are not in .agents/editorial-context.md, ask before auditing:
Required:
.tex files? (Path to main.tex or the project root.)Helpful: 4. What font is specified in the preamble? (Needed to check for fake bold/italic issues.) 5. Does the interior contain any color images or color design elements? (Determines CMYK vs. grayscale requirements.)
Every finding maps to one of five categories. Run them in order.
memoir has specific usage patterns. Deviating from them produces subtle errors that are hard to diagnose after the fact.
\checkandfixthelayout placement:
\setstocksize, \settrimmedsize, \settrims, \setlrmarginsandblock, \setulmarginsandblock) and before \begin{document}.\checkandfixthelayout: margins silently fail to apply. This is the most common memoir geometry error.Page style aliases — the three required:
\aliaspagestyle{cleared}{empty} % blank pages: no header, no footer
\aliaspagestyle{chapter}{plain} % chapter opening pages: page number only
\aliaspagestyle{title}{empty} % title page: nothing
Missing these means blank pages display running heads (looks like a layout error in print) and chapter opening pages carry a full running head (against typographic convention).
\frontmatter / \mainmatter / \backmatter sequence:
\frontmatter: Roman numeral page numbering, no chapter numbering. Must precede the first front matter file.\mainmatter: Resets page counter to 1, Arabic numerals, chapter numbering active. Must precede Chapter 1.\backmatter: No chapter numbering, but page numbering continues. Must precede back matter.openright and blank pages:
openright (set in \documentclass) forces chapters to begin on recto (odd/right) pages.empty via \aliaspagestyle{cleared}{empty}.openright set? Is cleared aliased to empty?\raggedbottom vs \flushbottom:
\flushbottom for two-sided documents — it stretches vertical space to align bottom margins across facing pages.\raggedbottom looks better and avoids ugly inter-paragraph gaps on pages with headings or short paragraphs.\raggedbottom unless the book has uniform paragraph density throughout. Add it to the preamble explicitly — don't rely on the default.\epigraph for chapter epigraphs:
\epigraph{text}{attribution}. Use it rather than manual \begin{quote} formatting.\epigraph{The quote text.}{---Author, \textit{Source}}\hfill attribution.Float placement:
[tbp] not [h] alone. [h] forces the float exactly at that position even if it doesn't fit — this causes ugly column gaps and page overflows in print.[p] (figures-only page).Fake bold and fake italic detection:
\textbf{} is used with a font that has no dedicated bold face, XeLaTeX synthesizes a "fake bold" by thickening strokes algorithmically. This looks bad in print and is rejected by some prepress workflows.\setmainfont have explicit BoldFont and BoldItalicFont entries, or are they being resolved automatically?\setmainfont{EB Garamond}[
Ligatures=TeX,
ItalicFont={EB Garamond Italic},
BoldFont={EB Garamond Medium},
BoldItalicFont={EB Garamond Medium Italic}
]
Ligature settings:
Ligatures=TeX is required for correct handling of -- (en dash), --- (em dash), and backtick quotes.Ligatures=Common enables standard typographic ligatures (fi, fl, ff, ffi, ffl). Recommended for all serif body fonts.\setmainfont{Font Name} with no options — em dashes and ligatures may not render correctly.microtype with XeLaTeX:
\usepackage[protrusion=true, expansion=false]{microtype}
expansion=true with XeLaTeX causes a compile warning and is silently ignored — but it signals the preamble was not written for XeLaTeX. Fix it explicitly.csquotes for all quotation marks:
"..." or ...'' `` in LaTeX source. Use \enquote{...} from the csquotes package.csquotes is language-aware (respects babel/polyglossia settings) and handles nested quotes automatically.\usepackage[autostyle]{csquotes}\enquote{This is a quote.} not "This is a quote.".tex source outside of code/verbatim blocks.babel or polyglossia for hyphenation:
\usepackage[american]{babel} or \usepackage{polyglossia} \setdefaultlanguage[variant=american]{english}Widow and orphan penalties: Every book preamble must set these. Their absence allows widows and orphans that are invisible at compile time but embarrassing in print:
\widowpenalty=10000 % prevents last line of paragraph alone at top of page
\clubpenalty=10000 % prevents first line of paragraph alone at bottom of page
\displaywidowpenalty=10000 % prevents widows before display math
A value of 10000 prohibits the condition entirely. LaTeX will adjust spacing elsewhere to avoid it. Values of 9000+ strongly discourage but allow as a last resort.
Consecutive hyphenation:
\doublehyphendemerits=10000 % discourages two consecutive hyphenated lines
\finalhyphendemerits=5000 % discourages hyphen on second-to-last line of paragraph
Overfull \hbox — lines extending into the margin:
Overfull \hbox warning in the compile log is a line that protrudes into the margin in the printed book.\hyphenation{In-gram-Spark}In\-gram\-Spark\sloppy locally as a last resort (increases word spacing — use sparingly)Underfull \vbox with \flushbottom:
\raggedbottom.Font embedding — non-negotiable:
fontspec.pdffonts main.pdf (command line). Every entry in the "emb" column must read "yes."PDF/X compliance:
pdfx package:
\usepackage[x-1a]{pdfx} % or [x-3] for PDF/X-3
pdfx must be loaded before hyperref — or it will be loaded instead of hyperref (it includes equivalent functionality).pdfx in the preamble? Is it loaded in the right order?Color mode:
Crop marks:
crop package or confirm with the printer whether to include them or deliver a bleed-only PDF.PDF metadata:
\hypersetup{
pdftitle={Exact Book Title},
pdfauthor={Author Name},
pdfsubject={Subject or genre},
pdfkeywords={keyword1, keyword2},
pdfproducer={XeLaTeX with memoir class},
}
Missing metadata won't reject a print job, but it is required for ISBN registration workflows and good practice for distribution.
Image resolution:
After each compile, the log must be reviewed. Not all warnings are benign.
Errors (must fix before submitting):
! Font ... not loadable — font not installed or name wrong! LaTeX Error: File '...' not found — missing image or included file! Undefined control sequence — command typo or missing package! Missing $ inserted — math mode entered unintentionallyWarnings that are print errors:
Overfull \hbox — line protrudes into margin (see Category 3)Font shape ... not available, using ... instead — font fallback triggered; likely fake bold/italicWarnings that can be ignored:
Underfull \hbox (badness ...) — minor spacing adjustment, usually finePDF inclusion: found PDF version 1.x, but at most 1.y allowed — version mismatch, usually harmless but worth notingPhase 1 — Audit:
Read the .tex files and compile log. Document every finding in .agents/editorial-context.md under ## LaTeX Audit Issues:
### TX[#] — [Brief descriptor]
- **File:** [Which .tex file — preamble.tex, main.tex, ch01.tex, etc.]
- **Category:** [memoir / fontspec / Typography / PDF / Compile log]
- **Issue:** [What the problem is]
- **Fix:** [The specific correction to make]
Unlike the editorial skills, fixes are included in Phase 1 — LaTeX issues have definitive correct solutions, not author-judgment calls.
Phase 2 — Resolution:
Work through each TX# issue in sequence, applying the fix directly to the .tex file. After all fixes, recompile and confirm the log is clean. Run the preflight checklist in references/PRINT-PREFLIGHT.md before declaring the file print-ready.
.tex source belong to editorial-prooflatex-book after the initial generationlatex-book confirms the source is clean