\begin{article}
Build LaTeX PDF Templates with Variables — formatex-template
Create FormaTeX LaTeX templates with <<placeholders>> and render personalized PDFs — certificates, invoices, reports — by passing JSON data.

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 helps you turn a LaTeX document into a 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 angle brackets — <<recipient_name>>, <<invoice_total>>, <<issue_date>> — save the template in your account, and then any caller with your API key can render a personalized PDF by POSTing a JSON payload. The formatex-template skill helps with the first two steps inside Claude Code: it drafts the LaTeX, marks the placeholders and prepares the variable schema.
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:
# 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:
-
Template authoring or ingestion. If you have an existing
.texfile, 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. -
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. -
Template registration. You save the annotated
.texsource and the variable schema in your account: paste them into Templates, New template in the dashboard, orPOSTthem tohttps://api.formatex.io/api/v1/templateswith your API key. FormaTeX stores the template and returns itsid. Templates need a Pro plan or above. -
Render demonstration. To confirm everything works, build a sample payload from the declared fields and call
POST https://api.formatex.io/api/v1/templates/user/{id}/compilewith your API key, then open the resulting PDF and read 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. -
Batch generation scaffolding. Optionally, the skill drafts a small code snippet — Node, Python, or curl — that reads a CSV or JSON array and calls the compile endpoint in a loop.
The authoring happens inside your Claude Code session: you see the LaTeX source, the variable schema and the batch snippet 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, and save the result as a template. Your application calls:
POST https://api.formatex.io/api/v1/templates/user/1280f9b1-10d0-4d0a-933e-042325c86a56/compile
X-API-Key: your_api_key
Content-Type: application/json
{
"variables": {
"recipient_name": "Maria Santos",
"course_title": "Advanced Kubernetes Operations",
"completion_date": "June 14, 2026",
"instructor_name": "Dr. James Okafor"
}
}You receive a compiled PDF. Values are inserted into the source as LaTeX, so escape characters such as &, %, $, # and _ in user supplied text before you send it. 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 compile 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 LaTeX lives in the template, 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 the line item block, totals, and customer details. Variables are flat strings, so build the repeating rows in your own code (one Item & 2 & 40.00 \\ line per entry) and pass them as a single variable such as <<line_items>>.
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
A template carries a schema alongside the LaTeX source. FormaTeX uses it to validate every compile request, and your team can use it as documentation for what your application must send.
The schema is an array with one entry per variable: key, type, required, default and description. The types are string, number and date (YYYY-MM-DD, or the word today). Values are always sent as JSON strings, including numbers. A required variable that is missing, or a number or date that does not parse, returns a 400 with a message that names the variable, not a broken PDF — which matters for production reliability. The Templates reference lists every rule and limit.
Updating and Versioning Templates
Templates are not immutable. When your design changes — new logo, updated legal boilerplate, restructured table — you edit the source in the dashboard, or send the new source with PUT https://api.formatex.io/api/v1/templates/user/{id}, and run your sample compile again. There is no version history, so if you want to keep the old design live while testing the new one, save the new design as a second template (it counts toward your plan's template limit) and move 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. Upload the .bib file as a template asset (POST /api/v1/templates/user/{id}/assets, or the Assets panel in the template editor) and choose the latexmk engine so references resolve in a single compile. If the bibliography changes per document, send it at compile time in the files array (base64) and it replaces the stored asset with the same path. For deeper coverage of bibliography tooling, see the citations and bibliography skill.
Related Skills
The formatex-template skill works best as part of a broader workflow. Related skills in the latex-skills suite:
- /latex-fix-errors — resolves compilation errors in your template source before registration
- /latex-write-markup — writes LaTeX from scratch when you are building a new template
- /latex-math-equations — handles complex mathematical content in templates
- /latex-document-structure — sets up document classes, packages, and section hierarchy for new templates
- /latex-citations-bibliography — manages bibliography and citation tooling for reference-heavy templates
- /latex-explain-commands — explains unfamiliar LaTeX commands encountered while editing template source
Get Started
The formatex-template skill helps with the one step that is not an API call: authoring the LaTeX and its placeholders. Once your template is saved, 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 an account at formatex.io (templates need the Pro plan or above) to get your API key, and run /formatex-template in your next Claude Code session.
\end{article}
\related{posts}




