PaperFit: Vision-in-the-Loop Typesetting Optimization for Scientific Documents

Bihui Yu, Xinglong Xu, Junjie Jiang, Jiabei Cheng, Caijun Jia, Siyuan Li, Conghui He, Jingxuan Wei, Cheng TanarXiv 2026

TL;DR

PaperFit introduces an intelligent, vision-in-the-loop agent designed to automate the frustrating "compile-inspect-edit" cycle of LaTeX typesetting. By combining multi-source feedback (source code, logs, and rendered page images) with a constrained repair policy, it fixes visual defects like overflowing equations and misplaced figures to deliver publication-ready PDFs.

What Problem Does This Paper Address?

Anyone who has rushed to meet an academic conference deadline knows the pain of LaTeX layout optimization. You run a compilation, check the PDF, find an equation bleeding past the margin or a table spilling onto an accidental extra page, tweak the code, and repeat.

The authors formalize this tedious game of layout whack-a-mole as Visual Typesetting Optimization (VTO). Traditional automation tools fall short here: rule-based compilers only see one-dimensional log warnings (like overfull \hbox), completely missing how whitespace is distributed or how a figure affects reading flow. On the flip side, text-only Large Language Models (LLMs) operate in an open loop—they can edit the code but cannot see or verify the 2D spatial consequences of their changes.

Methods

To bridge this gap, the authors present PaperFit, a vision-in-the-loop agent that treats typesetting as a closed-loop control problem.

Comparison of typesetting optimization approaches, highlighting PaperFit's visual closed-loop architecture.

The framework operates on a structured Sense-Act-Verify loop:

  1. Sense (Multi-Source Evidence Integration): PaperFit fuses signals from four layers: the .tex source code, .log compilation files, .pdf document metadata, and actual rendered page images. This multi-modal view allows it to accurately diagnose purely visual defects like column imbalances or float stacking.
  2. Act (Constrained Repair Policy): LLMs left to their own devices often rely on "pseudo-fixes"—like brute-forcing \vspace{-5mm} or wrapping tables in an ugly, unreadable \resizebox. PaperFit tames this action space by enforcing strict layout-native preferences (e.g., converting equations to multiline formats or utilizing width-aware tabularx environments). As a last resort, it can even perform bounded "semantic polishing" (minor, meaning-preserving text edits to save line space).
  3. Verify (Checklist Quality Control): Because LaTeX edits are highly non-local (a change on page 2 can cascade and ruin page breaks on page 7), a gatekeeper re-compiles and re-inspects the full document after every single edit before approving the changes.

Datasets

To rigorously benchmark this task, the authors introduced PaperFit-Bench.

Figure 2: Perturbation distribution and category composition. The inner ring shows proportions of five perturbation categories (Class A–E); the outer ring shows specific perturbation.

The dataset consists of 200 real academic papers sourced from arXiv, spanning 10 major conference templates (including AAAI, ICLR, CVPR, and NeurIPS) with both single- and double-column formats. The authors systematically injected 13 distinct types of typesetting defects across three difficulty tiers, creating a total of 761 perturbations to evaluate how effectively an agent can restore a document to its pristine, ground-truth layout.

Key Insights and Ideas

  • Visual feedback is necessary but not sufficient: Simply giving page images to a multi-round LLM agent (the baseline VisualMR) isn't enough. Without explicit defect taxonomies and strict repair constraints, naive visual agents often introduce new layout bugs or fail to respect page budgets.
  • The Non-Local Cascade Effect: Small source modifications trigger unpredictable, document-wide layout shifts. This makes a strict, gated verification step after every single edit absolutely vital.
  • Framework Design Trumps Model Choice: When testing PaperFit across different LLM backends (GPT, Claude, DeepSeek), the performance remained remarkably stable. This indicates that the structured closed-loop framework itself drives the success, rather than the raw power of a specific foundational model.

Key Results

PaperFit significantly outperformed all rule-based, text-only, and naive visual baselines across the board:

  • Perfect Reliability: It achieved a 100% compilation and rendering success rate, ensuring that the agent never breaks the document build.
  • Strict Page Control: PaperFit hit the exact target page budget in 80.5% of cases, vastly outperforming the naive visual agent baseline (VisualMR at 54.9%).
  • High Visual Quality: In human-aligned visual quality assessments (VLM score), PaperFit scored 3.39 out of 5 and achieved an 89.5% win rate against unoptimized, perturbed documents.

Limitations and Future Work

Despite its strong performance, PaperFit has a few clear boundaries:

  • Microtypographic Blindness: Current Vision-Language Models can still overlook highly subtle layout issues, such as font-level kerning errors or microtypographic imperfections.
  • The "Hard Case" Bottleneck: On highly complex documents featuring 5–8 co-occurring defects, PaperFit's page-budget hit rate drops to roughly 70%, showing that dense, multi-defect environments remain challenging.
  • Scope and Overhead: The system is currently optimized only for English-language LaTeX documents. Furthermore, the iterative multi-round recompilation loop incurs a higher computational cost than single-pass generation methods, making pipeline speedups a key focus for future work.

Summary updated

BibTeX
@misc{yu2026paperfit,
  author = {Bihui Yu and Xinglong Xu and Junjie Jiang and Jiabei Cheng and Caijun Jia and Siyuan Li and Conghui He and Jingxuan Wei and Cheng Tan},
  title = {{PaperFit: Vision-in-the-Loop Typesetting Optimization for Scientific Documents}},
  year = {2026},
  eprint = {2605.10341},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.10341},
}

Loading related content...

Figure