Get the FREE Ultimate OpenClaw Setup Guide →
I

LaTeX

Verified

@ivangdavila

npx machina-cli add skill @ivangdavila/latex --openclaw
Files (1)
SKILL.md
3.1 KB

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 equations
  • \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

Source

git clone https://clawhub.ai/ivangdavila/latexView on GitHub

Overview

Learn to write LaTeX documents with correct syntax, packages, and a reliable compilation workflow. It covers escaping special characters, math mode, tables, figures, and cross-references, plus best practices for preamble, package order, and error handling.

How This Skill Works

It uses a standard preamble with package commands and UTF-8/font encoding support. Content sits between \begin{document} and \end{document}, with inline math in $...$ and display math in \[ ... \] (or via the align environment). Compilation requires multiple passes: latex -> bibtex -> latex -> latex to resolve references and the bibliography.

When to Use It

  • Draft a short article or report with math and citations.
  • Create a long document (thesis or book) with sections, figures, and tables.
  • Include graphics with captions and labels for cross-references.
  • Write multilingual text with UTF-8 and proper font encoding.
  • Debug common errors and ensure all references resolve after compilation.

Quick Start

  1. Step 1: Create a .tex file with a document class and a preamble; load packages: \usepackage[utf8]{inputenc}, \usepackage[T1]{fontenc}, \usepackage{graphicx}, \usepackage{booktabs}, \usepackage{amsmath}, \usepackage{microtype}.
  2. Step 2: Write content between \begin{document} and \end{document}, including math ($...$ or \( ... \)) and figures/tables with captions and labels.
  3. Step 3: Compile with latex, bibtex, latex, latex; review the log for errors and ensure cross-references are resolved.

Best Practices

  • Escape reserved characters like #, $, %, _, {, } and use typographic quotes ``...'' and proper dashes -- and ---.
  • Place hyperref last in the preamble and enable UTF-8 with \usepackage[utf8]{inputenc} and \usepackage[T1]{fontenc}.
  • Use core packages: graphicx for images, booktabs for tables, amsmath for math, and microtype for typography; load them early for best results.
  • Floats: use [htbp] for placement, consider [H] with the float package to force position, always center inside floats, and caption before label.
  • Compile sequence: latex -> bibtex -> latex -> latex; check logs and fix references as needed.

Example Use Cases

  • Journal article with equations and BibTeX-managed references.
  • Engineering report with tables (booktabs) and figures (graphicx).
  • Book chapter or thesis with multi-section structure and cross-references.
  • UTF-8 multilingual paper using font encoding for proper non-ASCII characters.
  • PDF with clickable references using hyperref and consistent labeling.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers