I
LaTeX
Verified@ivangdavila
npx machina-cli add skill @ivangdavila/latex --openclawFiles (1)
SKILL.md
3.1 KB
Special Characters
- Reserved chars need escape:
\# \$ \% \& \_ \{ \} \textbackslash - Tilde as character:
\textasciitildenot\~(that's an accent) - Caret:
\textasciicircumnot\^ - Backslash in text:
\textbackslashnot\\(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-1in text
Math Mode
- Inline:
$...$or\(...\); display:\[...\]orequationenvironment - Text inside math:
$E = mc^2 \text{ where } m \text{ is mass}$ - Multiline equations:
alignenvironment, not multipleequations \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
\usepackageorder matters—hyperrefalmost always lastinputenc+fontencfor UTF-8:\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}graphicxfor images,booktabsfor professional tables,amsmathfor advanced mathmicrotypefor 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]fromfloatpackage to force - Always use
\centeringinside float, notcenterenvironment - Caption before
\label—label references the last numbered element
References
- Compile twice to resolve
\refand\pageref—first pass collects, second uses \labelimmediately after\captionor inside environment being labeled- For bibliography: latex → bibtex → latex → latex (4 passes)
hyperrefmakes refs clickable—but can break with some packages
Tables
tabularfor inline,tablefloat for numbered with caption- Use
booktabs:\toprule,\midrule,\bottomrule—no vertical lines @{}removes padding:\begin{tabular}{@{}lll@{}}- Multicolumn:
\multicolumn{2}{c}{Header}; multirow needsmultirowpackage
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
\includeadds page break,\inputdoesn't—use\inputfor fragments
Document Structure
- Preamble before
\begin{document}—all\usepackageand settings \maketitleafter\begin{document}if using\title,\author,\datearticlefor short docs,reportfor chapters without parts,bookfor full books
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
- 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}.
- Step 2: Write content between \begin{document} and \end{document}, including math ($...$ or \( ... \)) and figures/tables with captions and labels.
- 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