\begin{article}
Compile LaTeX to PDF via API — formatex-compile Skill
Compile any .tex file to PDF from your terminal via the FormatEx API — no TeX Live, no Docker, no setup. Auto engine selection and error diagnosis included.

If you write LaTeX, you know the drill. You save your .tex file, switch to a terminal, run pdflatex, watch it spit out 80 lines of output, hunt for the actual error buried somewhere in the middle, fix it, run it again, and repeat until the PDF is clean. If you are building a system that generates PDFs programmatically, you either bundle a full TeX Live installation — which is several gigabytes — or you set up a Docker container and pray the dependencies stay stable. Neither option is fun.
The formatex-compile Claude Code skill eliminates all of that. It compiles any .tex file to a PDF by calling the FormatEx API directly from your terminal, inside your Claude Code session. No local LaTeX installation required. No Docker. No configuration ceremony. Just point it at a file and get a PDF back.
What Is the formatex-compile Skill
The formatex-compile skill is a Claude Code skill that wraps the FormatEx REST API compilation endpoint. When you invoke it, Claude checks your API key, inspects your .tex source to select the right engine automatically (pdflatex, xelatex, lualatex, or latexmk), sends the file to the FormatEx compilation service, and saves the resulting PDF to disk.
If the compilation fails, the skill reads the TeX log returned by the API and surfaces the relevant error lines directly in your terminal — no digging through raw log output yourself. If the error is fixable automatically, the skill can attempt a retry after applying the fix.
This is part of the broader latex-skills collection for Claude Code, which covers everything from fixing LaTeX errors to writing LaTeX markup from scratch.
How to Install
The formatex-compile skill lives in the latex-skills GitHub repository at https://github.com/formatex/latex-skills. Clone the repository, then copy the skill into your Claude Code skills directory.
Install just this skill:
cp -r skills/formatex-compile ~/.claude/skills/Install the full FormatEx skill bundle (compile, manage keys, check usage):
cp -r skills/formatex ~/.claude/skills/Install the full LaTeX skill bundle (all LaTeX-related skills):
cp -r skills/latex ~/.claude/skills/Install everything:
cp -r skills/latex-full ~/.claude/skills/After copying, set your FormatEx API key as an environment variable:
export FORMATEX_API_KEY=fx_live_your_key_hereYou can get an API key by signing up at formatex.io. The free plan includes 15 compilations per month, which is enough to evaluate the skill and integrate it into a small workflow. If you are building a PDF generation pipeline, see the getting started guide for a full walkthrough of the API.
What formatex-compile Does
When you invoke the skill with a .tex file path, it runs through the following steps:
1. API key check. The skill verifies that FORMATEX_API_KEY is set and makes a lightweight request to confirm the key is valid. If the key is missing or invalid, it tells you exactly what to do rather than failing silently.
2. Engine detection. The skill reads the first few lines of your .tex file and checks for engine-specific markers: \usepackage{fontspec} or \usepackage{unicode-math} signal xelatex; \directlua signals lualatex; a latexmkrc file in the same directory signals latexmk. Everything else defaults to pdflatex. You can override this by passing the engine explicitly.
3. Compilation request. The skill sends your file to the FormatEx API at https://api.formatex.io/api/v1/compile. The API compiles the document in an isolated TeX Live environment on the server and returns either a PDF binary or a JSON error response with the full TeX log.
4. Error handling. If compilation fails, the skill parses the TeX log and extracts the lines that actually matter — the error lines and the surrounding context. It presents these cleanly, without the walls of (./filename.sty) noise that real TeX logs contain. If you also have the latex-fix-errors skill installed, the skill can hand off directly to it for automatic error correction.
5. PDF output. On success, the PDF is saved to the same directory as the input file, with the same base name. You can override the output path by passing a second argument.
The entire round-trip for a simple document is typically under two seconds. For complex documents with many packages, it depends on compilation time, which the API caps according to your plan (30 seconds on free, up to 300 seconds on higher tiers).
Before and After: A Realistic Example
Before: The Manual Process
You are working on a technical report in Claude Code. You ask Claude to add a new section with a table, Claude edits report.tex, and now you need to verify the output looks right.
You: Can you check if the PDF looks correct?
Claude: I can see the .tex file but I cannot compile it — you will need to run
pdflatex locally and share the output with me.So you switch to a separate terminal, run pdflatex report.tex, get an error about a missing booktabs package import, fix it manually, run it again, get a second error about a misplaced & in the table, fix that, run it a third time, confirm the PDF looks right, and come back to Claude. The whole interruption took eight minutes and broke your focus.
After: With the formatex-compile Skill
You: Compile report.tex and check if the table rendered correctly.
Claude: [invoking formatex-compile on report.tex]
Compilation successful. PDF saved to report.pdf.
The table rendered correctly — three columns, borders aligned, header row bold.
One note: the column widths are uneven because the second column content is
significantly longer. Want me to adjust the column spec?Claude compiles the file, reads the result, and continues the conversation without breaking your flow. The FormatEx API handles the TeX Live execution server-side, so there is nothing to install or maintain.
Common Use Cases
1. Document Authoring in Claude Code
If you use Claude Code to draft or edit LaTeX documents — papers, reports, slides, CVs — the formatex-compile skill closes the feedback loop. Claude can edit the source and immediately verify the PDF output without leaving the session. Pair it with the document structure skill and the math equations skill for a complete authoring workflow.
2. CI/CD PDF Generation
If you are generating PDFs as part of a build pipeline and want to validate templates during development, you can call the FormatEx API directly from your scripts. See the Go client guide, the PHP/Laravel integration, or the Ruby on Rails guide for production integration patterns. The formatex-compile skill is the Claude Code companion to these integrations — use it during development to iterate on templates before wiring up the full API client.
3. Serverless PDF Rendering
If you are building a serverless function that compiles LaTeX, you cannot bundle TeX Live in a Lambda deployment package — the binary alone exceeds Lambda's layer size limits. The FormatEx API solves this cleanly. See the serverless AWS Lambda guide for the full pattern. Use formatex-compile during local development of the Lambda function to test your .tex templates before deploying.
4. Academic Paper Submission Checks
Before submitting to arXiv or a journal, run formatex-compile on your final .tex source to catch any compilation errors that only surface in a clean environment without your local TeX Live customizations. The FormatEx environment is a standard TeX Live installation, which closely matches what most submission systems use.
5. Multi-File Document Projects
For projects with a main file that includes subfiles, pass the root .tex file to formatex-compile. The skill uploads the file and any detected dependencies. The FormatEx API handles multi-file compilation correctly, including bibliography files and custom class or style files in the same directory.
Combining formatex-compile with Other Skills
The formatex-compile skill works best as part of a broader LaTeX workflow in Claude Code. Here is how it connects to the other skills in the collection:
- latex-fix-errors: When compilation fails,
formatex-compilecan hand off the error log to this skill for automatic diagnosis and correction. - latex-write-markup: Use this skill to generate LaTeX source from a description, then compile it immediately with
formatex-compile. - latex-citations-bibliography: Manages BibTeX references and bibliography formatting. After updating references, compile with
formatex-compileto verify the output. - latex-explain-commands: If the compiled output looks wrong and you are not sure why, this skill explains what specific LaTeX commands are doing.
Installing the full latex or latex-full bundle gives you all of these skills at once, which is the recommended setup if you work with LaTeX regularly.
Plan Limits and Engine Support
The formatex-compile skill respects the limits of your FormatEx plan. On the free plan, compilations are capped at pdflatex with a 30-second timeout and a 1MB input size limit. If you invoke the skill with a file that requires xelatex — for example, one that uses fontspec for custom fonts — and you are on the free plan, the skill will tell you upfront rather than sending the request and getting a plan enforcement error back from the API.
Developer and Pro plans unlock all four engines (pdflatex, xelatex, lualatex, latexmk), longer timeouts, and larger file size limits. See formatex.io for current plan details and pricing.
Get Started
The formatex-compile Claude Code skill is the fastest way to integrate LaTeX compilation into your terminal workflow. No TeX Live installation. No Docker containers. No maintenance overhead. The FormatEx API handles the compilation infrastructure so you can focus on the document.
Install the skill from https://github.com/formatex/latex-skills, grab an API key at formatex.io, and run your first compilation in under five minutes.
If you are building a production PDF generation system rather than working interactively, the same FormatEx API powers the skill — check the getting started guide for the full API reference and client library documentation.
\end{article}
\related{posts}




