Skip to main content
skill CX Codex

latex-build — Claude Code skill: LaTeX builds and setup

latex-build is a Claude Code skill that builds LaTeX documents with latexmk, watches files for changes, and helps diagnose compilation errors.

MIT 236 installs ★ 3 updated 2026-10-25

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add terrylica/cc-skills --skill latex-build -a claude-code
Open on GitHub

What latex-build does

For a one-off build, the skill uses latexmk -pdf document.tex; live preview runs latexmk -pvc -pdf document.tex. latexmk tracks dependencies and repeats compilation when cross-references need it. Watch mode monitors file changes. To reload the PDF automatically in Skim, enable file-change checks in the app’s preferences.

The skill also covers SyncTeX builds, cleaning auxiliary files, and non-interactive compilation. Check that latexmk is installed and available in PATH before running a build; otherwise the command cannot be found. When compilation fails, inspect the .log file. Use latexmk -c to remove build artifacts while keeping the PDF.

What it helps with

  • build a PDF from a LaTeX document
  • watch project files and rebuild after changes
  • compile with SyncTeX support
  • remove auxiliary files while keeping the PDF
  • locate a compilation error in the .log file

Example prompts for the agent

  • Build a PDF from document.tex with latexmk.
  • Set up live preview for document.tex with automatic rebuilds.
  • Clean the build artifacts but keep the finished PDF.

How to install latex-build

1Skills CLI (Vercel)

npx skills add terrylica/cc-skills --skill latex-build -a claude-code

2Manually: put the files in place

~/.claude/skills/latex-build/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/latex-build/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about latex-build

How do I install latex-build in Claude Code?

Run npx skills add terrylica/cc-skills --skill latex-build -a claude-code. The skill file is at ~/.claude/skills/latex-build/SKILL.md.

What does latex-build do?

It helps compile LaTeX documents with latexmk, run a file-watching build, and clean build artifacts.

What does latex-build need to run?

The latexmk command must be installed and available in PATH. For automatic PDF reloads in Skim, turn on file-change checks in the app preferences.

Source text

SKILL.md · MIT
---
name: latex-build
description: LaTeX builds with latexmk and live preview. TRIGGERS - latexmk, LaTeX build, live preview, compilation.
allowed-tools: Read, Edit, Bash
---

# LaTeX Build Automation

> **Self-Evolving Skill**: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

## When to Use This Skill

Use this skill when:

- Compiling LaTeX documents
- Setting up live preview with auto-rebuild
- Managing multi-file projects
- Troubleshooting build failures
- Cleaning build artifacts
- Automating compilation workflows

## Quick Reference

## Why latexmk?

Industry standard build tool:

- Auto-detects dependencies (bibliography, index, etc.)
- Runs correct number of times (handles cross-references)
- Live preview mode watches for file changes
- Works with Skim for SyncTeX auto-reload
- Bundled with MacTeX (no separate install needed)

---

## Basic Usage

### One-Time Build

```bash
latexmk -pdf document.tex
# Result: document.pdf created
```

### Live Preview (Watch Mode)

```bash
latexmk -pvc -pdf document.tex

# What happens:
# - Compiles document initially
# - Watches for file changes
# - Auto-recompiles when files change
# - Auto-reloads PDF in Skim viewer
```

**Stop watching:** Press `Ctrl+C`

---

## Quick Reference Card

```bash
# Build once
latexmk -pdf document.tex

# Live preview (watch mode)
latexmk -pvc -pdf document.tex

# Build with SyncTeX
latexmk -pdf -synctex=1 document.tex

# Clean artifacts
latexmk -c              # Keep PDF
latexmk -C              # Remove PDF too

# Force rebuild
latexmk -gg -pdf document.tex

# Non-interactive (for CI)
latexmk -pdf -interaction=nonstopmode document.tex
```

---

## Build Checklist

- [ ] Verify latexmk installed: `which latexmk`
- [ ] Test basic build: `latexmk -pdf document.tex`
- [ ] Enable SyncTeX: Add `-synctex=1` flag
- [ ] Test live preview: `latexmk -pvc -pdf document.tex`
- [ ] Configure Skim for auto-reload
- [ ] Create Makefile for common tasks (optional)
- [ ] Create .latexmkrc for project-specific settings (optional)
- [ ] Test clean: `latexmk -c` removes artifacts

---

## Reference Documentation

For detailed information, see:

- [Common Commands](./references/common-commands.md) - Build options and output formats
- [Multi-File Projects](./references/multi-file-projects.md) - Automatic dependency tracking for complex documents
- [Configuration](./references/configuration.md) - .latexmkrc and Makefile integration
- [Troubleshooting](./references/troubleshooting.md) - Common build issues and solutions
- [Advanced Patterns](./references/advanced-patterns.md) - Parallel builds and CI/CD integration

**Official Docs**: Run `man latexmk` or `latexmk -help` for complete reference

**See Also**:

- Use `latex/setup` skill for installing LaTeX and configuring environment
- Use `latex/tables` skill for creating tables with tabularray

---

## Troubleshooting

| Issue                      | Cause                         | Solution                                             |
| -------------------------- | ----------------------------- | ---------------------------------------------------- |
| latexmk not found          | Not in PATH                   | Add `/Library/TeX/texbin` to PATH                    |
| Undefined control sequence | Missing package               | Check `\usepackage` statements for required packages |
| References show ??         | Need multiple runs            | latexmk handles this automatically; ensure no errors |
| Live preview not updating  | Skim auto-reload disabled     | Skim Preferences → Sync → Check for file changes     |
| Build hangs                | Input prompt in nonstop mode  | Use `-interaction=nonstopmode` flag                  |
| PDF not updating           | Build error preventing output | Check .log file for specific error                   |
| SyncTeX not working        | Missing -synctex=1 flag       | Add `-synctex=1` to build command                    |
| Too many aux files         | Normal build artifacts        | Run `latexmk -c` to clean (keeps PDF)                |


## Post-Execution Reflection

After this skill completes, check before closing:

1. **Did the command succeed?** — If not, fix the instruction or error table that caused the failure.
2. **Did parameters or output change?** — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
3. **Was a workaround needed?** — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.

Only update if the issue is real and reproducible — not speculative.

© terrylica · MIT · terrylica/cc-skills

Similar skills

All skills for Science and research →

From the same set79

The whole set →
gdrive-access The gdrive-access skill gives your agent Google Drive from the command line: list files, download them, sync whole folders. OAuth credentials come from 1Password. CX Codex +1 357installs chezmoi-workflows chezmoi-workflows runs dotfiles through chezmoi: adds configs to a Git repo, pulls them onto other machines, renders templates. Useful when shell and editor settings drift apart. CX Codex +1 308installs disk-hygiene disk-hygiene audits macOS disk usage, clears bloated developer caches, and flags forgotten large files without automated accidental deletions. CX Codex +1 273installs latex-tables Teaches the agent to build LaTeX tables with tabularray: fixed column widths, alignment, rule lines. Useful when a tblr has to be written from scratch or an old table rewritten. CX Codex +1 242installs ascii-diagram-validator The ascii-diagram-validator skill finds structural alignment problems in Markdown box diagrams and reports where they occur. Run it after editing architecture docs or README files. CX Codex +1 217installs calendar-event-manager calendar-event-manager builds macOS Calendar events with layered sound alarms and matching Reminders, so a meeting does not slip past you. CX Codex +1 214installs agent-reach The agent-reach skill equips your agent with web search and reading capabilities across 17 platforms: social networks (Twitter, Reddit, Weibo, Xiaohongshu, Douyin, Bilibili, V2EX), job boards (LinkedIn), GitHub, YouTube, podcasts. CX Codex +1 195installs code-hardcode-audit code-hardcode-audit scans codebases for raw credentials, magic numbers, and duplicated blocks. It coordinates nine static analysis utilities through uv. CX Codex +1 166installs

Project sponsors

Companies that keep this analytics open