# Referencia Rápida de LaTeX

*Estructura del documento, matemáticas, tablas, figuras y más*

> Source: LaTeX Project (latex-project.org) · MIT

## Estructura del documento

### Documento mínimo

```
\documentclass{article}
\begin{document}
Hello, LaTeX!
\end{document}
```

### Clases de documento

| Command | Description |
|---------|-------------|
| `article` | Documentos cortos, artículos, informes |
| `report` | Documentos largos con capítulos |
| `book` | Libros completos con partes y capítulos |
| `beamer` | Presentaciones de diapositivas |
| `letter` | Cartas formales |

### Preámbulo

```
\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, graphicx}
\title{My Document}
\author{Alice}
\date{\today}
```

### Secciones

| Command | Description |
|---------|-------------|
| `\part{}` | División de nivel superior (book/report) |
| `\chapter{}` | Capítulo (solo report/book) |
| `\section{}` | Sección |
| `\subsection{}` | Subsección |
| `\subsubsection{}` | Sub-subsección |
| `\paragraph{}` | Párrafo con nombre |

## Formato de texto

### Estilos de fuente

| Command | Description |
|---------|-------------|
| `\textbf{bold}` | Texto en **negrita** |
| `\textit{italic}` | Texto en *cursiva* |
| `\underline{text}` | Texto subrayado |
| `\texttt{code}` | Monoespacio / máquina de escribir |
| `\textsc{Small Caps}` | Versalitas |
| `\emph{emphasis}` | Énfasis (cursiva según contexto) |

### Tamaños de fuente

| Command | Description |
|---------|-------------|
| `\tiny` | El más pequeño |
| `\small` | Más pequeño que el normal |
| `\normalsize` | Tamaño por defecto |
| `\large / \Large` | Grande / aún más grande |
| `\huge / \Huge` | Enorme / el más grande |

### Espaciado y saltos

| Command | Description |
|---------|-------------|
| `\\` | Salto de línea |
| `\newpage` | Salto de página |
| `\vspace{1cm}` | Espacio vertical |
| `\hspace{1cm}` | Espacio horizontal |
| `\noindent` | Suprimir sangría de párrafo |
| `~` | Espacio sin separación |

## Modo matemático

### Matemáticas en línea y en display

```
Inline: $E = mc^2$ or \( a^2 + b^2 = c^2 \)
Display: \[ \int_0^\infty e^{-x} dx = 1 \]
Numbered: \begin{equation}
  F = ma \label{eq:newton}
\end{equation}
```

### Símbolos comunes

| Command | Description |
|---------|-------------|
| `^ and _` | Superíndice / subíndice: `x^2`, `a_i` |
| `\frac{a}{b}` | Fracción: a/b |
| `\sqrt{x} / \sqrt[3]{x}` | Raíz cuadrada / cúbica |
| `\sum_{i=1}^{n}` | Sumatoria |
| `\int_a^b` | Integral |
| `\lim_{x \to 0}` | Límite |
| `\infty` | Símbolo de infinito |

### Letras griegas

| Command | Description |
|---------|-------------|
| `\alpha \beta \gamma \delta` | Griego en minúscula |
| `\Gamma \Delta \Theta \Lambda` | Griego en mayúscula |
| `\epsilon \sigma \omega \pi` | Más griego en minúscula |
| `\mu \nu \rho \tau \phi` | Comunes en estadística / física |

### Matrices

```
\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
% pmatrix = (), vmatrix = ||, Bmatrix = {}
```

## Entornos

### Entornos comunes

| Command | Description |
|---------|-------------|
| `document` | Área de contenido principal |
| `equation` | Ecuación matemática numerada |
| `align` | Ecuaciones multilínea alineadas |
| `figure` | Figura flotante |
| `table` | Tabla flotante |
| `verbatim` | Texto literal (sin formato) |
| `abstract` | Bloque de resumen (article) |

### Ecuaciones alineadas

```
\begin{align}
  x &= a + b \\
  y &= c + d
\end{align}
% & marks alignment point, \\ breaks lines
```

## Listas y tablas

### Listas

```
\begin{itemize}
  \item Bullet point
  \item Another item
\end{itemize}
\begin{enumerate}
  \item First  \item Second
\end{enumerate}
```

### Tablas

```
\begin{tabular}{|l|c|r|}
  \hline
  Name & Age & Score \\ \hline
  Alice & 25 & 88 \\
  Bob & 30 & 92 \\ \hline
\end{tabular}
```

### Especificadores de columna

| Command | Description |
|---------|-------------|
| `l / c / r` | Alineación izquierda / centro / derecha |
| `\|` | Línea vertical entre columnas |
| `p{3cm}` | Columna de párrafo (ancho fijo) |
| `\hline` | Línea horizontal |
| `\cline{2-3}` | Línea horizontal parcial (cols 2-3) |

## Figuras

### Incluir imágenes

```
\usepackage{graphicx}  % in preamble
\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.8\textwidth]{img.png}
  \caption{A figure caption}
  \label{fig:example}
\end{figure}
```

### Especificadores de posición

| Command | Description |
|---------|-------------|
| `h` | Aquí (aproximadamente) |
| `t` | Parte superior de la página |
| `b` | Parte inferior de la página |
| `p` | Página especial de flotantes |
| `!` | Anular restricciones internas |
| `H` | Exactamente aquí (requiere `float`) |

### Referencias cruzadas

```
See Figure~\ref{fig:example} on
page~\pageref{fig:example}.
% Requires two compilations to resolve
```

## Bibliografía

### Flujo de trabajo BibTeX

```
% In .bib file:
@article{smith2025,
  author = {Smith, John},
  title = {A Great Paper},
  journal = {Nature}, year = {2025}
}
```

### Citar en el documento

```
According to~\cite{smith2025} ...
\bibliographystyle{plain}
\bibliography{refs}  % refs.bib
```

### Estilos de bibliografía

| Command | Description |
|---------|-------------|
| `plain` | Numerado, ordenado alfabéticamente |
| `unsrt` | Numerado, en orden de citación |
| `abbrv` | Como plain, nombres abreviados |
| `apalike` | Autor-año (estilo APA) |

## Paquetes

### Paquetes esenciales

| Command | Description |
|---------|-------------|
| `amsmath` | Entornos matemáticos avanzados |
| `graphicx` | Inclusión de imágenes |
| `hyperref` | Enlaces y referencias clicables |
| `geometry` | Márgenes: `\usepackage[margin=1in]{geometry}` |
| `booktabs` | Tablas profesionales (`\toprule`, `\midrule`) |
| `xcolor` | Colores de texto y fondo |
| `listings` | Listados de código fuente |
| `tikz` | Gráficos y diagramas programáticos |
| `babel` | Soporte multilingüe |
| `natbib` | Citas flexibles (autor-año, numérico) |

## Comandos personalizados

### Nuevos comandos

```
\newcommand{\R}{\mathbb{R}}    % shortcut
\newcommand{\norm}[1]{\|#1\|}  % 1 argument
Now use: $x \in \R$, $\norm{v}$
```

### Redefinir y crear entornos

```
\renewcommand{\abstractname}{Summary}
\newenvironment{boxed}
  {\begin{center}\begin{tabular}{|p{0.9\textwidth}|}\hline}
  {\hline\end{tabular}\end{center}}
```

### Atajos útiles

```
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\dd}[2]{\frac{d #1}{d #2}}
% Usage: $\pd{f}{x}$, $\dd{y}{t}$
```

## Patrones comunes

### Página de título

```
\begin{document}
\maketitle
\tableofcontents
\newpage
```

### Compilación

| Command | Description |
|---------|-------------|
| `pdflatex doc.tex` | Compilar a PDF |
| `bibtex doc` | Procesar bibliografía |
| `latexmk -pdf doc.tex` | Auto-compilar (gestiona re-ejecuciones) |
| `xelatex doc.tex` | Soporte Unicode / fuentes personalizadas |

### Caracteres especiales

| Command | Description |
|---------|-------------|
| `\% \$ \& \# \_` | Caracteres reservados escapados |
| `\textbackslash` | Barra invertida en texto |
| `\{ \}` | Llaves literales |
| ```text''` | Comillas dobles tipográficas |
| `---` | Raya (em dash) |
| `--` | Guión largo (en dash) |

### Consejos útiles

| Command | Description |
|---------|-------------|
| `\label{} + \ref{}` | Referencias cruzadas a cualquier elemento |
| `\input{file}` | Incluir otro archivo .tex |
| `% comment` | Comentario de una sola línea |
| `\usepackage{lipsum}` | Texto de relleno: `\lipsum[1-3]` |
