Project 3 min read
Multi-Script LaTeX Production System
Component-based typesetting pipeline handling Chinese, Arabic, and multilingual documents.
Overview #
Agent-orchestrated XeLaTeX pipeline for bilingual Chinese learning materials. This project is a local-first document production system that turns raw bilingual Chinese-English lesson transcripts into polished educational PDFs through a modular XeLaTeX architecture and an AI agent trained to operate it. Instead of treating LaTeX as a static template and AI as a text generator, the system is structured so the agent understands available document components, asks clarifying questions, maps content into the correct visual formats, applies preprocessing and validation, and compiles the final PDF locally.
Stack #
- XeLaTeX — multilingual typesetting and PDF compilation
- Modular .tex — component architecture for reusable publishing blocks
- Python — preprocessing and validation scripts for tone-coloring and layout checks
- Hermes — orchestration agent guided through a custom skills.md instruction layer
- Local-first — editable .tex retained after compilation
Problem #
A raw lecture transcript is not a document. Before anything can be typeset, the content has to be interpreted editorially: which lines belong in dialogue bubbles, which terms should become vocabulary rows, which expressions deserve callouts, which patterns need grammar explanation, and which exercises should be generated to reinforce the lesson.

Most automated PDF pipelines fail at that mapping stage. They may generate formatted output, but they do not reliably preserve pedagogical structure, visual hierarchy, or document consistency across different lesson types.
A raw lecture transcript is not a document — the pipeline must decide which lines become dialogue bubbles, vocabulary rows, grammar callouts, and exercises before any XeLaTeX component is invoked.
Approach #
Hermes was taught how the document system works through a custom skills.md file that acts as an operational guide to the component architecture. Each LaTeX component has a defined name, purpose, and set of valid use cases, so the agent is not generating layout decisions blindly.
Architecture #
The LaTeX side is modular rather than monolithic. Instead of maintaining one oversized preamble, the system is split into reusable component files so different document types can load only what they need while preserving a consistent visual language.
Validation #
The pipeline includes preprocessing and post-generation checks rather than relying on a one-pass compile. Tone-colored pinyin is applied automatically, and the generated document is then checked for spacing issues, padding inconsistencies, empty pages, and related layout problems before final delivery.
Tone-colored pinyin, spacing checks, and empty-page detection run before final compile — the pipeline rejects one-pass output instead of shipping layout defects into courseware PDFs.
Output #
The finished PDFs are intentionally dense and polished, combining decorative borders, structured vocabulary tables, color-coded pinyin, dialogue bubbles, grammar cards, themed callouts, and tightly controlled spacing into material that feels like designed courseware rather than exported notes.


Capabilities #
- Modular LaTeX system design for reusable, structured publishing workflows
- AI-agent orchestration over a defined component architecture, not just freeform text generation
- Human-in-the-loop editorial control at the correct stage of the workflow
- Local-first PDF production with editable source retention and fast turnaround
- End-to-end solo ownership across design, architecture, orchestration, validation, and delivery