home / skills / openclaw / skills / latex

This skill helps you write LaTeX documents with correct syntax, packages, and a reliable compilation workflow.

npx playbooks add skill openclaw/skills --skill latex

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

Files (2)
SKILL.md
3.1 KB
---
name: LaTeX
description: Write LaTeX documents with correct syntax, packages, and compilation workflow.
metadata: {"clawdbot":{"emoji":"📐","os":["linux","darwin","win32"]}}
---

## Special Characters

- Reserved chars need escape: `\# \$ \% \& \_ \{ \} \textbackslash`
- Tilde as character: `\textasciitilde` not `\~` (that's an accent)
- Caret: `\textasciicircum` not `\^`
- Backslash in text: `\textbackslash` not `\\` (that's line break)

## Quotes & Dashes

- Opening quotes: ``` `` ``` not `"`; closing: `''`—never use straight `"` quotes
- Hyphen `-`, en-dash `--` (ranges: 1--10), em-dash `---` (punctuation)
- Minus in math mode: `$-1$` not `-1` in text

## Math Mode

- Inline: `$...$` or `\(...\)`; display: `\[...\]` or `equation` environment
- Text inside math: `$E = mc^2 \text{ where } m \text{ is mass}$`
- Multiline equations: `align` environment, not multiple `equation`s
- `\left( ... \right)` for auto-sizing delimiters—must be paired

## Spacing

- Command followed by text needs `{}` or `\ `: `\LaTeX{}` or `\LaTeX\ is`
- Non-breaking space: `~` between number and unit: `5~km`
- Force space in math: `\,` thin, `\:` medium, `\;` thick, `\quad` `\qquad`

## Packages

- `\usepackage` order matters—`hyperref` almost always last
- `inputenc` + `fontenc` for UTF-8: `\usepackage[utf8]{inputenc}` `\usepackage[T1]{fontenc}`
- `graphicx` for images, `booktabs` for professional tables, `amsmath` for advanced math
- `microtype` for better typography—load early, subtle but significant improvement

## Floats (Figures & Tables)

- `[htbp]` suggests placement: here, top, bottom, page—not commands
- LaTeX may move floats far from source—use `[H]` from `float` package to force
- Always use `\centering` inside float, not `center` environment
- Caption before `\label`—label references the last numbered element

## References

- Compile twice to resolve `\ref` and `\pageref`—first pass collects, second uses
- `\label` immediately after `\caption` or inside environment being labeled
- For bibliography: latex → bibtex → latex → latex (4 passes)
- `hyperref` makes refs clickable—but can break with some packages

## Tables

- `tabular` for inline, `table` float for numbered with caption
- Use `booktabs`: `\toprule`, `\midrule`, `\bottomrule`—no vertical lines
- `@{}` removes padding: `\begin{tabular}{@{}lll@{}}`
- Multicolumn: `\multicolumn{2}{c}{Header}`; multirow needs `multirow` package

## Images

- Path relative to main file or set with `\graphicspath{{./images/}}`
- Prefer PDF/EPS for pdflatex/latex; PNG/JPG for photos
- `\includegraphics[width=0.8\textwidth]{file}`—no extension often better

## Common Errors

- Overfull hbox: line too long—rephrase, add `\-` hyphenation hints, or allow `\sloppy`
- Missing `$`: math command used in text mode
- Undefined control sequence: typo or missing package
- `\include` adds page break, `\input` doesn't—use `\input` for fragments

## Document Structure

- Preamble before `\begin{document}`—all `\usepackage` and settings
- `\maketitle` after `\begin{document}` if using `\title`, `\author`, `\date`
- `article` for short docs, `report` for chapters without parts, `book` for full books

Overview

This skill helps you write LaTeX documents with correct syntax, package choices, and a reliable compilation workflow. It focuses on practical, error-minimizing rules for special characters, math, floats, tables, images, and references. Use it to produce publication-quality PDFs and to troubleshoot common LaTeX errors quickly.

How this skill works

The skill inspects document structure, recommended packages, and common pitfalls, and advises concrete fixes (escaping reserved characters, pairing delimiters, correct quoting and dash usage). It outlines the compilation sequence for references and bibliographies and gives placement and formatting guidance for floats, tables, and images. It also highlights typography improvements and package ordering that avoid conflicts like hyperref issues.

When to use it

  • Creating articles, reports, or books in LaTeX for journals or coursework
  • Preparing math-heavy documents with aligned equations and proper delimiters
  • Assembling figures and tables with captions, labels, and cross-references
  • Troubleshooting compilation errors, overfull boxes, or undefined control sequences
  • Optimizing document typography and package ordering before final compilation

Best practices

  • Escape reserved characters (\#, \$, \%, \&, \_, \{\}, \textbackslash) and use \textasciitilde/\textasciicircum for tilde/caret in text
  • Use proper opening/closing quotes (``...''), en-dash (--) for ranges, em-dash (---) for punctuation
  • Keep math in math mode ($...$ or \[...\]), use align for multiline equations and \left/\right for paired delimiters
  • Load microtype early, amsmath for math, graphicx for images, booktabs for tables; load hyperref last
  • Place \label immediately after \caption and compile twice (or four passes for bibtex) to resolve references

Example use cases

  • Write a journal article with correct figure inclusion, captions, and clickable references via hyperref
  • Prepare lecture notes with aligned multiline equations and correct spacing inside math
  • Convert a manuscript with many special characters and ensure text compiles without undefined control sequences
  • Assemble a report with publication-quality tables using booktabs and no vertical rules
  • Troubleshoot overfull hboxes, missing $ errors, or broken package interactions

FAQ

How do I force a float to stay where it appears?

Use the float package and the [H] specifier, but prefer good placement hints ([htbp]) and adjusting text or float sizes first.

Why are my references not resolved?

Compile enough passes: two for basic refs (latex→latex) and four for bibtex-based bibliographies (latex→bibtex→latex→latex). Ensure \label follows \caption.