latex
Comprehensive LaTeX reference for document creation, formatting, mathematics, tables, figures, bibliographies, and compilation. Use when helping users write, edit, debug, or compile LaTeX documents.
What this skill does
# LaTeX Skill
## 1. Overview
LaTeX is a markup language and typesetting system for producing high-quality documents. It excels at structured documents with complex formatting, mathematics, cross-references, and bibliographies.
**When to use LaTeX:**
- Academic papers, journal submissions
- Theses and dissertations
- Technical documentation
- CVs and résumés
- Presentations (Beamer)
- Books, reports, letters
**Key concepts:**
| Concept | Description |
|---------|-------------|
| **Preamble** | Everything before `\begin{document}` — class, packages, settings |
| **Document body** | Content between `\begin{document}` and `\end{document}` |
| **Commands** | Start with `\`, e.g. `\textbf{bold}`. Optional args in `[]`, required in `{}` |
| **Environments** | `\begin{name}...\end{name}` blocks for scoped formatting |
| **Packages** | Extensions loaded with `\usepackage{name}` in the preamble |
## 2. Document Structure
### Document Classes
```latex
\documentclass[options]{class}
```
| Class | Use case |
|-------|----------|
| `article` | Short documents, papers, assignments |
| `report` | Longer documents with chapters |
| `book` | Books (front/back matter, chapters) |
| `beamer` | Presentations/slides |
| `letter` | Formal letters |
| `memoir` | Flexible — replaces article/report/book |
### Common Class Options
```latex
\documentclass[12pt,a4paper,twocolumn,draft]{article}
```
| Option | Values |
|--------|--------|
| Font size | `10pt`, `11pt`, `12pt` |
| Paper | `a4paper`, `letterpaper`, `a5paper` |
| Columns | `onecolumn`, `twocolumn` |
| Sides | `oneside`, `twoside` |
| Draft | `draft` (shows overfull boxes, skips images) |
### Minimal Document
```latex
\documentclass[12pt,a4paper]{article}
% === PREAMBLE ===
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\title{My Document}
\author{Author Name}
\date{\today}
% === BODY ===
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
Content here.
\end{document}
```
## 3. Text Formatting
### Style Commands
| Command | Result |
|---------|--------|
| `\textbf{text}` | **bold** |
| `\textit{text}` | *italic* |
| `\underline{text}` | underlined |
| `\emph{text}` | emphasis (italic, or upright if already italic) |
| `\texttt{text}` | `monospace` |
| `\textsc{text}` | SMALL CAPS |
| `\textsf{text}` | sans-serif |
### Font Sizes
Smallest to largest:
```
\tiny \scriptsize \footnotesize \small \normalsize
\large \Large \LARGE \huge \Huge
```
Use as: `{\large This text is large.}` or as environment.
### Font Families
| Command | Declaration | Family |
|---------|-------------|--------|
| `\textrm{}` | `\rmfamily` | Serif (Roman) |
| `\textsf{}` | `\sffamily` | Sans-serif |
| `\texttt{}` | `\ttfamily` | Monospace |
### Alignment
```latex
\begin{center} Centered text. \end{center}
\begin{flushleft} Left-aligned. \end{flushleft}
\begin{flushright} Right-aligned. \end{flushright}
```
Or inline: `\centering`, `\raggedright`, `\raggedleft`
### Spacing
```latex
\vspace{1cm} % vertical space
\hspace{2em} % horizontal space
\vfill % stretch vertical
\hfill % stretch horizontal
\\[0.5cm] % line break with extra space
\setlength{\parskip}{0.5em} % paragraph spacing
\setlength{\parindent}{0pt} % remove paragraph indent
\noindent % suppress indent for one paragraph
```
Line spacing (requires `setspace` package):
```latex
\usepackage{setspace}
\onehalfspacing % or \doublespacing, \singlespacing
```
### Special Characters
These characters must be escaped:
| Character | LaTeX | Character | LaTeX |
|-----------|-------|-----------|-------|
| `%` | `\%` | `$` | `\$` |
| `&` | `\&` | `#` | `\#` |
| `_` | `\_` | `{` | `\{` |
| `}` | `\}` | `~` | `\textasciitilde` |
| `^` | `\textasciicircum` | `\` | `\textbackslash` |
## 4. Document Organization
### Sectioning
```latex
\part{Part Title} % only in report/book
\chapter{Chapter Title} % only in report/book
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph}
\paragraphsub{Subparagraph}
```
Starred versions (`\section*{}`) suppress numbering and TOC entry.
### Table of Contents
```latex
\tableofcontents % requires two compilations
\listoffigures
\listoftables
```
### Lists
```latex
% Bulleted
\begin{itemize}
\item First item
\item Second item
\end{itemize}
% Numbered
\begin{enumerate}
\item First
\item Second
\end{enumerate}
% Labeled
\begin{description}
\item[Term] Definition here.
\end{description}
```
Customize with `enumitem` package:
```latex
\usepackage{enumitem}
\begin{enumerate}[label=(\alph*), start=1]
```
### Cross-References
```latex
\section{Methods}\label{sec:methods}
See Section~\ref{sec:methods} on page~\pageref{sec:methods}.
```
With `hyperref`, use `\autoref{sec:methods}` for automatic "Section 2" text.
**Rule:** Always place `\label` *after* `\caption` (in floats) or after the sectioning command.
### Footnotes
```latex
This has a footnote.\footnote{Footnote text here.}
```
## 5. Mathematics
### Inline vs Display
```latex
Inline: $E = mc^2$ or \(E = mc^2\)
Display:
\[ E = mc^2 \]
% Numbered equation:
\begin{equation}\label{eq:einstein}
E = mc^2
\end{equation}
```
### Essential Packages
```latex
\usepackage{amsmath} % align, cases, matrices, etc.
\usepackage{amssymb} % extra symbols (ℝ, ℤ, etc.)
\usepackage{mathtools} % extends amsmath (dcases, coloneqq, etc.)
```
### Common Constructs
```latex
% Fractions
\frac{a}{b} \dfrac{a}{b} (display-size)
% Roots
\sqrt{x} \sqrt[3]{x}
% Sub/superscripts
x_{i} x^{2} x_{i}^{2} a_{i,j}
% Sums, products, integrals
\sum_{i=1}^{n} x_i \prod_{i=1}^{n} x_i
\int_{0}^{\infty} f(x)\,dx
\lim_{x \to \infty} f(x)
% Brackets (auto-sized)
\left( \frac{a}{b} \right)
\left[ ... \right]
\left\{ ... \right\}
```
### Matrices
```latex
\begin{pmatrix} a & b \\ c & d \end{pmatrix} % (a b; c d)
\begin{bmatrix} a & b \\ c & d \end{bmatrix} % [a b; c d]
\begin{vmatrix} a & b \\ c & d \end{vmatrix} % |a b; c d| (determinant)
\begin{Bmatrix} a & b \\ c & d \end{Bmatrix} % {a b; c d}
```
### Aligned Equations
```latex
\begin{align}
f(x) &= x^2 + 2x + 1 \label{eq:f} \\
g(x) &= x^3 - 1 \label{eq:g}
\end{align}
% No numbering:
\begin{align*}
a &= b + c \\
d &= e + f
\end{align*}
```
### Cases
```latex
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x^2 & \text{if } x < 0
\end{cases}
```
### Greek Letters
| Lower | Command | Upper | Command |
|-------|---------|-------|---------|
| α | `\alpha` | Α | `A` |
| β | `\beta` | Β | `B` |
| γ | `\gamma` | Γ | `\Gamma` |
| δ | `\delta` | Δ | `\Delta` |
| ε | `\epsilon`, `\varepsilon` | Ε | `E` |
| θ | `\theta` | Θ | `\Theta` |
| λ | `\lambda` | Λ | `\Lambda` |
| μ | `\mu` | — | — |
| π | `\pi` | Π | `\Pi` |
| σ | `\sigma` | Σ | `\Sigma` |
| φ | `\phi`, `\varphi` | Φ | `\Phi` |
| ω | `\omega` | Ω | `\Omega` |
### Common Math Symbols
| Symbol | Command | Symbol | Command |
|--------|---------|--------|---------|
| ≤ | `\leq` | ≥ | `\geq` |
| ≠ | `\neq` | ≈ | `\approx` |
| ± | `\pm` | × | `\times` |
| ÷ | `\div` | · | `\cdot` |
| ∈ | `\in` | ∉ | `\notin` |
| ⊂ | `\subset` | ⊆ | `\subseteq` |
| ∪ | `\cup` | ∩ | `\cap` |
| ∞ | `\infty` | ∂ | `\partial` |
| ∇ | `\nabla` | ∀ | `\forall` |
| ∃ | `\exists` | → | `\to`, `\rightarrow` |
| ⇒ | `\Rightarrow` | ⇔ | `\Leftrightarrow` |
| ℝ | `\mathbb{R}` | ℤ | `\mathbb{Z}` |
| … | `\dots`, `\ldots`, `\cdots` | | |
## 6. Tables
### Basic Table
```latex
\begin{table}[htbp]
\centering
\caption{Results summary}\label{tab:results}
\begin{tabular}{lcrp{4cm}}
\toprule
Name & Count & Score & Description \\
\midrule
Alpha & 10 & 95.2 & First entry \\
Beta & 20 & 87.1 & Second entry \\
\bottomrule
\end{tabular}
\end{table}
```
### Column Specifiers
| Spec | AlRelated in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.