LaTeX Polish — Source Lint + Vision-On-Rendered-PDF
Heavier-weight visual-quality review than
latex. Combines the Phase 4 source-pathology lint with vision-model inspection of selected rendered PDF pages. Designed to catch the failure class thatlatexPhase 4 source-grep misses: blank pages, clipped tables, illegible shrunken figures, weird title-page line spacing that the regex couldn't fingerprint, bad float placement, overlap.
When to Use
- Pre-submission visual check on a paper, proposal, thesis, or deck
- After major restructuring (new sections, table re-layouts, figure swaps) when you want eyes on the rendered output
- When
latexreports a clean build but something still "looks weird" - When preparing for a panel / supervisor read where presentation matters
When NOT to Use
| Need | Use instead |
|------|-------------|
| Compile-fix loop | latex |
| Citation audit | latex (Phase 5) or bib-validate |
| Prose / academic-argument review | proofread |
| Single-figure analysis | figure-feedback |
| Continuous integration | This skill renders + vision-inspects pages; too expensive to run on every save |
Inputs
.texpath — auto-discovered or user-provided. Prefer the user's argument.- PDF path — assumed at
<project>/<basename>.pdf(perlatexconvention). If absent or older than.tex, the skill aborts and suggestslatexfirst. --no-vision— skip the vision-rendering phases (Page rendering onward), run the source-pathology lint only.--pages auto|N,N,N— page selection override. Defaultauto.
Hard Rules
- Do not compile. This skill presupposes a clean PDF. If the PDF is missing or stale, abort and suggest
latexfirst. - Read-only with respect to source files. Exception: Pattern-1 (spacing-hack) opt-in fix, which is offered with a diff and only applied on explicit user yes.
- No deploy actions. This skill produces a report; it does not commit, push, or modify build infrastructure.
- Cap render cost. Max 8 pages rendered per invocation. If page selection would exceed 8, prioritise: title page, worst-overfull page, first table/figure page, then arbitrary sample.
- Cap vision-prompt cost. One Read per rendered page. No per-page back-and-forth.
Protocol — 7 Phases
Phase 1: Pre-flight
- Resolve
.texpath. If a directory was given, findmain.texor single.texinside. - Resolve PDF path:
<dirname>/<basename without .tex>.pdf. If missing or older than.tex, abort with: "Stale or missing PDF — runlatexfirst." - Verify
pdftoppmis on PATH. If not, abort with install hint (brew install poppleron macOS). - Create render dir:
mktemp -d /tmp/latex-polish.XXXXXX. Track this as$RENDER_DIR.
Phase 2: Source-pathology re-run (Phase 4 of `latex`)
Run the 9 grep-based source-pathology detectors from <skills-root>/latex/references/source-pathologies.md, plus chktex and latexindent -k if installed. Collect findings into a structured list.
This phase is identical to latex Phase 4 and is rerun here for self-containment (so latex-polish can be invoked without a prior latex run).
Phase 3: Page selection
Determine which pages to vision-inspect. Default auto:
| Page | Why | Mandatory if available |
|------|-----|------------------------|
| 1 | Title / cover — high-stakes visual real estate; title-page failure mode is common | Yes |
| Page containing any overfull vbox > 50pt | Vertical overflow is almost always visually broken | Yes |
| Page containing the largest overfull hbox | The "worst" horizontal overflow seen | Yes |
| First page containing a table | Tables produce the most common visual pathologies | Yes |
| First page containing a figure | Same | If figures exist |
| Last body page before bibliography | Catches widow/orphan and end-of-content layout issues | If pages > 5 |
| Bibliography page 1 | Citation formatting + hanging indent regressions | If bib exists |
If overfull-box locations are not known (no log file or out/main.log missing), skip those entries. Cap total at 8 pages; if the selection would exceed 8, drop the lowest-priority entries.
Pull overfull-box page locations by reading <project>/out/<basename>.log:
awk '/Overfull \\(v|h)box/ { for(i=1;i<=NF;i++) if($i ~ /\[[0-9]+\]/) print substr($i,2,length($i)-2) }' out/main.log | sort -u
For each candidate page, also record WHY it was selected (used to pick the right vision-prompt later).
Phase 4: Page rendering
for P in $SELECTED_PAGES; do
pdftoppm -r 150 -f $P -l $P -png "$PDF" "$RENDER_DIR/page-$P"
done
150 DPI is enough for layout analysis without ballooning file sizes. Each PNG lands at $RENDER_DIR/page-<N>-<P>.png (pdftoppm pads the page number).
Phase 5: Vision analysis
For each rendered page, Read the PNG and apply the per-page-type prompt from