FormaTeX

\begin{article}

draft — not published

Build LaTeX PDF Templates with Variables — formatex-template

Create FormatEx LaTeX templates with double-brace placeholders and render personalized PDFs — certificates, invoices, reports — by passing JSON data.

Build LaTeX PDF Templates with Variables — formatex-template

If you have ever needed to generate fifty personalized certificates, a hundred invoices, or a batch of weekly reports as PDFs, you already know the pain: either you build a fragile string-interpolation script around a LaTeX file, maintain that script every time the template changes, or you pay someone to click through a Word mail-merge workflow. None of those options scale, and none of them belong in a modern development pipeline. The formatex-template Claude Code skill exists to eliminate that problem entirely. It turns a LaTeX document into a registered FormatEx template with {{variable}} placeholders, and from that point forward your application generates personalized PDFs by sending JSON — no LaTeX knowledge required per document, no TeX Live installation, no per-document compilation babysitting.

The Core Idea: Define Once, Render Thousands of Times

FormatEx is built around the idea that LaTeX compilation should be an API call, not an infrastructure project. The template system extends that idea one level up: LaTeX authoring should also be a one-time investment. You write (or have Claude write) the document structure once, annotate the dynamic fields with double-brace syntax — {{recipient_name}}, {{invoice_total}}, {{issue_date}} — register the template via the FormatEx API, and then any caller with your API key can render a personalized PDF by POSTing a JSON payload. The formatex-template skill automates all three of those steps inside Claude Code.

If you are new to FormatEx and have not yet set up an account or API key, start with Getting Started with FormatEx before continuing here.

How to Install

The formatex-template skill lives in the latex-skills GitHub repository. You have four installation options depending on how much of the skill suite you want:

bash
# Install just the formatex-template skill
cp -r skills/formatex-template ~/.claude/skills/

# Install the full FormatEx skill bundle (recommended if you use FormatEx heavily)
cp -r skills/formatex ~/.claude/skills/

# Install the full LaTeX skill bundle
cp -r skills/latex ~/.claude/skills/

# Install everything at once
cp -r skills/latex-full ~/.claude/skills/

After copying, the skill is immediately available inside any Claude Code session. No restart required. You invoke it by typing /formatex-template in the chat interface.

What formatex-template Does

When you invoke /formatex-template, the skill walks through a structured workflow:

  1. Template authoring or ingestion. If you have an existing .tex file, point the skill at it. If you are starting from scratch, describe the document — certificate, invoice, contract, report — and the skill writes the LaTeX for you, drawing on the same underlying capabilities as the latex-write-markup skill.

  2. Placeholder injection. The skill identifies the fields that should vary per render — names, dates, amounts, URLs, scores — and rewrites those positions in the LaTeX source as {{field_name}} tokens. It avoids touching structural LaTeX commands, so the document still compiles cleanly as a preview with dummy values.

  3. Template registration. The skill calls POST https://api.formatex.io/api/v1/templates with your API key, uploading the annotated .tex source and a JSON schema describing the expected fields. FormatEx stores the template and returns a template_id.

  4. Render demonstration. To confirm everything works, the skill constructs a sample payload from the declared fields and calls POST https://api.formatex.io/api/v1/templates/{template_id}/render, downloads the resulting PDF, and reports any compilation errors. If the LaTeX has issues, it hands off to the same error-resolution logic described in the fix-errors skill before retrying.

  5. Batch generation scaffolding. Optionally, the skill emits a small code snippet — Node, Python, or curl — that reads a CSV or JSON array and calls the render endpoint in a loop, giving you a working batch pipeline in under a minute.

The entire flow happens inside your Claude Code session. You see the LaTeX source, the registered schema, the sample PDF confirmation, and the batch snippet — all in one conversation.

Before and After: The Real Difference

Before the skill — a typical certificate generation workflow looks like this:

You have a LaTeX file you or a designer produced. You write a Python script that reads a CSV, does string replacement on the .tex source, writes each variant to a temp file, shells out to pdflatex, moves the output to a results folder, and cleans up. This script breaks when the template gains a new field, when pdflatex is not on the CI machine, when a name contains a special LaTeX character like & or _, or when you need a different engine for Unicode names. Debugging means reading TeX error logs. Maintenance means you own a TeX Live installation.

After the skill — the same workflow looks like this:

You run /formatex-template in Claude Code, paste in the certificate .tex file or describe what you want. The skill registers it against the FormatEx API. Your application calls:

http
POST https://api.formatex.io/api/v1/templates/tpl_abc123/render
X-API-Key: your_api_key
Content-Type: application/json

{
  "data": {
    "recipient_name": "Maria Santos",
    "course_title": "Advanced Kubernetes Operations",
    "completion_date": "June 14, 2026",
    "instructor_name": "Dr. James Okafor"
  }
}

You receive a compiled PDF. Special characters are escaped automatically by the rendering pipeline. The engine is configured once on the template. Scaling from one certificate to ten thousand is a loop over your data — no infrastructure changes.

For teams building this kind of integration in Go, the Go client guide shows exactly how to wire up the render endpoint. PHP/Laravel teams should check the Laravel integration post, and Ruby on Rails teams have a dedicated walkthrough at the Rails post.

Common Use Cases

Personalized certificates and credentials. Training platforms, online courses, and compliance systems issue certificates constantly. Define the layout once — logo, border, signature line, accreditation text — and render per-recipient by passing name, course, and date. The formatex-template skill handles the LaTeX so your certification microservice sends one API call per issuance.

Dynamic invoices and receipts. Accounting and e-commerce systems often need branded PDF invoices that reflect line items, tax calculations, and payment terms. Register a template with placeholders for each line item block, totals, and customer details. The render endpoint accepts nested JSON, so line item arrays map cleanly to LaTeX table rows via the template engine.

Automated research and analytics reports. If your product generates weekly or monthly reports for clients — usage summaries, analytics dashboards, audit outputs — a FormatEx template gives you a professionally typeset PDF with your brand, updated automatically from your data pipeline. Pair this with the serverless AWS Lambda pattern to trigger renders from S3 events or scheduled jobs without any server management.

Academic and scientific document pipelines. Journals, thesis systems, and preprint servers that accept structured metadata can use a template to produce consistently formatted PDFs from author-submitted data. The skill's support for math-heavy templates integrates with the capabilities covered in the math equations skill — your template can include complex formulae that stay static while only the surrounding metadata varies.

Contracts and legal documents. NDAs, service agreements, and offer letters follow a fixed structure with variable parties, dates, and terms. A FormatEx template keeps the legal language locked while allowing the dynamic fields to be injected per use. Combined with proper document structure (see the document structure skill), you get consistently formatted legal PDFs without a document assembly server.

Working with the Template Schema

When the skill registers your template, it posts a field schema alongside the LaTeX source. This schema serves two purposes: FormatEx uses it to validate incoming render payloads at the API level, and your team uses it as documentation for what JSON your application must send.

The schema is a flat or nested JSON object describing field names, types (string, number, boolean, array), and whether each field is required. The skill infers this schema from the placeholders it identifies in your .tex source, but you can review and edit it before registration. Required fields that are missing from a render request return a 400 error with a clear message, not a broken PDF — which matters for production reliability.

Updating and Versioning Templates

Templates are not immutable. When your design changes — new logo, updated legal boilerplate, restructured table — you invoke /formatex-template again, point it at the updated .tex source, and call PUT https://api.formatex.io/api/v1/templates/{template_id}. The skill handles the update call and reruns the render smoke test. If you want to keep the old version live while testing the new one, register it as a new template under a different template_id and migrate your application's calls when ready.

For understanding unfamiliar LaTeX commands you encounter while editing templates, the explain-commands skill is useful — paste in a command and get a plain-English explanation before modifying it.

Citations and Bibliography in Templates

Some document types — literature reviews, technical reports, academic papers — require bibliography support. If your template includes a \bibliography{} block, the skill detects this and configures the FormatEx render call to run bibtex as part of the compilation pipeline. The static .bib file is uploaded as part of the template registration. Dynamic citations per render are also possible if you include the .bib content as a template field. For deeper coverage of bibliography tooling, see the citations and bibliography skill.

The formatex-template skill works best as part of a broader workflow. Related skills in the latex-skills suite:

Get Started

The formatex-template skill removes the only remaining friction in building PDF generation into your application: the LaTeX authoring and registration step. Once your template is registered, rendering personalized PDFs is a single API call with a JSON body — something any HTTP client in any language can do.

Install the skill from the latex-skills repository on GitHub, create a free account at formatex.io to get your API key, and run /formatex-template in your next Claude Code session. Your first template can be registered and rendering PDFs in under ten minutes.

\end{article}

Back to blog

\related{posts}

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy