🤖 AI Summary
Accurately converting structured Markdown drafts into LaTeX documents that adhere to template constraints presents dual challenges of semantic fidelity and formatting compliance. This work proposes a two-track hybrid framework: in an offline phase, template constraints are automatically extracted to generate reusable checklists; during the online phase, a rule engine handles most transformations, while large language models (LLMs) are selectively invoked only in semantically dense regions. By systematically decoupling content from formatting for the first time, the approach balances structural accuracy with semantic completeness, effectively mitigating both the hallucination tendencies of pure LLM-based methods and the rigidity of purely rule-based systems. Experiments across seven templates and 56 academic papers demonstrate significant improvements in structural fidelity, typographic compliance, and compilation success rates.
📝 Abstract
With the increasing demands for advanced document conversion, mapping structured Markdown drafts into template-compliant formats like LaTeX remains a challenge. Existing approaches largely depend on either deterministic rule-based converters or pure end-to-end Large Language Model (LLM) generation. The former fails to correctly handle asset insertions and template-specific constraints, while the latter tends to induce semantic drift, leading to hallucinations that are difficult to debug. To address these limitations, we introduce a robust Dual-Track Framework that systematically decouples template formatting from document processing: an offline track extracts template constraints into a reusable manifest, while an online track implements a hybrid execution pipeline. This pipeline confines LLM usage exclusively to reasoning-intensive components (e.g., semantic metadata, bibliographic references, and complex visual/tabular layouts) while delegating rule-based engines for deterministic processing. Empirical evaluation across 7 LaTeX templates and 56 published research papers demonstrates that our method preserves better structural fidelity, satisfies diverse layout constraints, and achieves a higher compilation success rate compared to the previous baselines.