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:
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"
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
Present Both Artifacts
-
Show the LaTeX source code artifact (editable)
-
Provide the compiled PDF
Update and Recompile
When user requests changes to existing LaTeX:
-
Update the LaTeX artifact with requested changes
-
Recompile automatically using the compilation script
-
Update the PDF artifact or provide new download
Compile-Only
When user says "compile this" with existing LaTeX artifact:
-
Extract LaTeX from the artifact
-
Compile using the script
-
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
\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:
-
Writes LaTeX to temporary .tex file
-
Runs pdflatex twice with flags:
-
-interaction=nonstopmode (don't stop on errors)
-
-output-directory (specified temp directory)
-
Captures output and errors
-
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
-
Academic Papers: \documentclass{article} with amsmath , sections, bibliography
-
Resumes/CVs: Clean formatting with geometry , enumitem
-
Reports: \documentclass{report} with chapters, TOC, figures
-
Letters: \documentclass{letter} with proper formatting
-
Math Homework: Heavy use of amsmath , align , equation environments
-
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.