home / skills / benchflow-ai / skillsbench / latex-pdf-compiler

latex-pdf-compiler skill

/registry/terminal_bench_2.0/full_batch_reviewed/terminal_bench_2_0_overfull-hbox/environment/skills/latex-pdf-compiler

This skill compiles LaTeX sources to PDF using pdflatex, returning editable source and the generated PDF for Overleaf-compatible documents.

This is most likely a fork of the latex-pdf-compiler skill from robdmc
npx playbooks add skill benchflow-ai/skillsbench --skill latex-pdf-compiler

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.0 KB
---
name: latex-pdf-compiler
description: Compiles LaTeX source code to PDF using pdflatex. Use this skill whenever the user asks to create and compile LaTeX documents, generate PDFs from LaTeX, or compile existing LaTeX code in artifacts.
---

# LaTeX PDF Compiler

This skill enables Claude to create Overleaf-compatible LaTeX documents and compile them to PDF using the user's local pdflatex installation.

## When to Use This Skill

Activate this skill when the user:
- Asks to "create a LaTeX [document] and compile it"
- Requests "make a PDF using LaTeX"
- Says "compile this LaTeX" or "compile to PDF"
- Asks to "generate and compile" any LaTeX document
- Requests updates to existing LaTeX with recompilation

## Workflow

### Single-Step Generation and Compilation

When user requests a LaTeX document with compilation:

1. **Generate Overleaf-Compatible LaTeX**
   - Create clean, well-structured LaTeX using standard document classes
   - Use common, widely-available packages
   - Put LaTeX source in a code artifact with `language="latex"`

2. **Compile Immediately**
   - Use the `compile_latex.py` script to compile the LaTeX
   - Run pdflatex twice (for references and TOC)
   - Provide the compiled PDF to the user

3. **Present Both Artifacts**
   - Show the LaTeX source code artifact (editable)
   - Provide the compiled PDF

### Update and Recompile

When user requests changes to existing LaTeX:

1. **Update the LaTeX artifact** with requested changes
2. **Recompile automatically** using the compilation script
3. **Update the PDF** artifact or provide new download

### Compile-Only

When user says "compile this" with existing LaTeX artifact:

1. **Extract LaTeX from the artifact**
2. **Compile using the script**
3. **Provide the PDF**

## LaTeX Generation Guidelines

### Standard Practices
- Use standard document classes: `article`, `report`, `book`, `letter`
- Include only common packages that work in Overleaf:
  - `amsmath`, `amssymb` - Math symbols
  - `graphicx` - Images
  - `hyperref` - Hyperlinks
  - `geometry` - Page layout
  - `fancyhdr` - Headers/footers
  - `enumitem` - List formatting
  - `xcolor` - Colors
- Use UTF-8 encoding
- Ensure proper document structure

### Example LaTeX Structure

```latex
\documentclass[11pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[margin=1in]{geometry}

\title{Document Title}
\author{Author Name}
\date{\today}

\begin{document}

\maketitle

\section{Introduction}
Content here...

\end{document}
```

## Compilation Process

The skill uses the `compile_latex.py` script which:

1. **Writes LaTeX to temporary .tex file**
2. **Runs pdflatex twice** with flags:
   - `-interaction=nonstopmode` (don't stop on errors)
   - `-output-directory` (specified temp directory)
3. **Captures output and errors**
4. **Returns**:
   - Success: PDF file path and base64-encoded PDF data
   - Failure: Error messages and log excerpts

## Error Handling

If compilation fails:
- Show relevant error messages from the LaTeX log
- Suggest common fixes (missing packages, syntax errors, etc.)
- Offer to update the LaTeX and retry

## Output Format

After successful compilation:
- Provide download link or base64-encoded PDF
- Keep the LaTeX source artifact for future edits
- Mention file location if saved locally

## Requirements

- `pdflatex` must be installed (TeX Live, MiKTeX, or MacTeX)
- `pdflatex` should be in system PATH
- Python 3.x available for the compilation script

## Common Use Cases

1. **Academic Papers**: `\documentclass{article}` with `amsmath`, sections, bibliography
2. **Resumes/CVs**: Clean formatting with `geometry`, `enumitem`
3. **Reports**: `\documentclass{report}` with chapters, TOC, figures
4. **Letters**: `\documentclass{letter}` with proper formatting
5. **Math Homework**: Heavy use of `amsmath`, `align`, equation environments
6. **Presentations**: `\documentclass{beamer}` for slides

## Script Location

The compilation script should be located at:
`scripts/compile_latex.py`

This script is automatically invoked when compilation is needed.

Overview

This skill compiles LaTeX source to PDF using a local pdflatex installation. It generates Overleaf-compatible LaTeX when requested, runs pdflatex (twice) to resolve references, and returns both the editable .tex source and the compiled PDF. Use it whenever you need to create, update, or compile LaTeX documents into downloadable PDFs.

How this skill works

When asked to create or compile LaTeX, the skill produces clean LaTeX source using standard document classes and common packages, then writes the source to a temporary .tex file. It invokes a Python compilation script that runs pdflatex twice with nonstopmode and a specified output directory, captures output and errors, and returns the compiled PDF (as a file path and base64 data) along with logs. On failures, it extracts log excerpts and suggests fixes.

When to use it

  • User asks to create a LaTeX document and produce a PDF
  • User provides existing .tex source and requests compilation
  • User requests edits to LaTeX with a recompile
  • Generate academic papers, reports, resumes, letters, or homework PDFs from LaTeX source

Best practices

  • Use standard document classes (article, report, book, letter) and common packages (amsmath, graphicx, hyperref, geometry) to maximize portability
  • Encode source in UTF-8 and keep file structure simple so pdflatex can run without custom toolchains
  • Run pdflatex twice to resolve cross-references and table of contents entries
  • Provide any required image files or .bib files alongside the .tex source when requesting compilation
  • When compilation fails, share the relevant log excerpt and the .tex snippet around the error for faster fixes

Example use cases

  • Create a new article with math and figures, compile to PDF, and get both source and download link
  • Compile a user-provided .tex file and return a base64-encoded PDF or download path
  • Apply requested edits to an existing LaTeX artifact, recompile, and deliver the updated PDF
  • Generate a resume using geometry and enumitem, compile, and return a print-ready PDF
  • Compile homework or assignment solutions heavy in amsmath and return the final PDF

FAQ

What is required on the system to use this skill?

pdflatex must be installed and on the system PATH (TeX Live, MiKTeX, or MacTeX). Python 3.x is required for the compilation script.

What happens if compilation fails?

The skill returns log excerpts and error messages, suggests common fixes (missing packages, syntax errors, missing files), and offers to revise the LaTeX and retry.