# Latex Beamer

> LaTeX compilation and Beamer presentation patterns for macOS with TeX Live. Covers pdflatex, latexmk, bibtex, error diagnosis, and Beamer slide authoring.

- Skill: `aleonsa/latex-beamer` (Agent Skill)
- Install (CLI): `npx skillmds@latest add aleonsa/latex-beamer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aleonsa/latex-beamer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: aleonsa (https://skillmd.com/u/aleonsa)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/aleonsa/latex-beamer

---


# LaTeX & Beamer on macOS (TeX Live)

## When to Activate

- Compiling `.tex` files on macOS
- Authoring or editing Beamer presentations
- Diagnosing LaTeX compilation errors
- Working with bibliographies (bibtex/natbib)

## Prerequisites Check

```bash
which pdflatex          # should return /Library/TeX/texbin/pdflatex
pdflatex --version      # TeX Live version
which latexmk           # optional but preferred for automation
```

If missing: install MacTeX from https://tug.org/mactex/ (full install ~5 GB) or BasicTeX (~100 MB, minimal).

---

## Compilation

### Standard (manual, 2 passes)

Always run twice — first pass builds .aux, second pass resolves cross-references and TOC.

```bash
cd /path/to/project
pdflatex main.tex && pdflatex main.tex
```

### With bibliography (bibtex)

```bash
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex
```

### With latexmk (preferred — handles passes automatically)

```bash
latexmk -pdf main.tex          # compile
latexmk -pdf -pvc main.tex     # watch mode (recompiles on save)
latexmk -C                     # clean all generated files
```

### Clean auxiliary files manually

```bash
rm -f *.aux *.log *.out *.toc *.bbl *.blg *.nav *.snm *.vrb
```

---

## Common Errors and Fixes

| Error | Cause | Fix |
|-------|-------|-----|
| `! LaTeX Error: File 'X.sty' not found` | Missing package | `tlmgr install <package>` |
| `! Undefined control sequence \X` | Typo or missing `\usepackage` | Check spelling, add package |
| `Overfull \hbox` | Text overflows column/frame | Use `\small`, `\footnotesize`, or `\linebreak` |
| `! Missing $ inserted` | Math outside math mode | Wrap in `$...$` or `\(...\)` |
| `natbib: cannot find bibliography` | `.bib` file not found or bibtex not run | Check path, run `bibtex main` |
| PDF not updating | Viewer caching or compilation error | Check `.log`, re-run |

### Read the log

```bash
grep -n "^!" main.log          # fatal errors
grep -n "Warning" main.log     # warnings
```

### Install missing packages (TeX Live)

```bash
sudo tlmgr update --self
sudo tlmgr install <package-name>   # e.g.: tlmgr install beamer
sudo tlmgr install collection-latexrecommended   # common bundle
```

---

## Beamer Patterns

### Minimal slide structure

```latex
\documentclass[aspectratio=169]{beamer}
\usetheme{SimplePlus}          % or Madrid, Warsaw, etc.
\usepackage{amsmath,amssymb,bm}
\usepackage{graphicx,booktabs}

\title{Title}
\author{Author}
\date{\today}

\begin{document}
\begin{frame}
    \titlepage
\end{frame}
\begin{frame}{Contenido}
    \tableofcontents
\end{frame}

\section{Sección 1}
\input{sections/01_intro.tex}
\end{document}
```

### Frame types

```latex
% Two columns
\begin{frame}{Título}
    \begin{columns}[T]
    \begin{column}{0.48\textwidth}
        Columna izquierda
    \end{column}
    \begin{column}{0.48\textwidth}
        Columna derecha
    \end{column}
    \end{columns}
\end{frame}

% Alert / Example blocks
\begin{alertblock}{Problema}
    Texto en rojo.
\end{alertblock}

\begin{exampleblock}{Solución}
    Texto en verde.
\end{exampleblock}

% Figure
\begin{frame}{Figura}
    \begin{center}
        \includegraphics[width=0.8\linewidth]{fig/nombre.png}
        {\footnotesize Descripción de la figura}
    \end{center}
\end{frame}

% Table
\begin{frame}{Tabla}
    \begin{table}
    \small
    \begin{tabular}{@{}lcc@{}}
    \toprule
    \textbf{Col 1} & \textbf{Col 2} & \textbf{Col 3} \\
    \midrule
    A & 1.23 & 4.56 \\
    \bottomrule
    \end{tabular}
    \end{table}
\end{frame}
```

### TikZ diagrams in Beamer

```latex
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, shapes.geometric}

\begin{frame}{Diagrama}
\begin{center}
\begin{tikzpicture}[
    node distance=0.5cm and 0.4cm,
    box/.style={draw, rounded corners, minimum width=2cm, minimum height=0.8cm,
                align=center, font=\small},
    done/.style={box, fill=green!20, draw=green!60!black},
    curr/.style={box, fill=orange!20, draw=orange},
    future/.style={box, fill=gray!15, draw=gray},
    arrow/.style={-{Stealth[length=2mm]}, thick}
]
    \node[done]   (a) {Fase 0\\\checkmark};
    \node[curr,   right=of a] (b) {Fase 1\\En curso};
    \node[future, right=of b] (c) {Fase 2\\Futuro};
    \draw[arrow] (a) -- (b);
    \draw[arrow] (b) -- (c);
\end{tikzpicture}
\end{center}
\end{frame}
```

### Math in Beamer

```latex
% Inline
$\omega_e = (P/2)\,\omega_m$

% Display
\begin{equation}
    \mathbf{e}_{\alpha\beta} = K_e\,\omega_m\,\mathbf{s}(\theta_e)
\end{equation}

% Aligned
\begin{align}
    f_1 &= \frac{1}{L}(u_1 - e - R\,i) \\
    f_2 &= \frac{1}{L}(u_2 - e - R\,i)
\end{align}
```

### Placeholder for missing figures

```latex
\newcommand{\placeholder}[2][0.8\textwidth]{%
    \begin{center}
    \fcolorbox{gray}{gray!10}{%
        \parbox{#1}{\centering\vspace{1cm}\textit{#2}\vspace{1cm}}%
    }
    \end{center}
}
% Usage:
\placeholder[0.6\textwidth]{Figura: ripple vs velocidad}
```

---

## Project Layout (modular)

```
presentation/
├── main.tex              # root: \input{sections/...}
├── reference.bib         # bibliography
├── fig/                  # all images (.png, .pdf, .eps)
├── sections/
│   ├── 01_intro.tex
│   ├── 02_theory.tex
│   └── ...
└── theme/                # custom .sty files if any
```

- Keep one `\section` per file in `sections/`.
- Use `\input{}`, not `\include{}` (no forced page breaks).
- Store figures as PNG (≥150 DPI) or PDF (vector, preferred for equations).

---

## Open PDF after compilation (macOS)

```bash
open main.pdf             # opens in Preview
open -a Skim main.pdf     # Skim supports auto-reload on recompile
```

Skim (free, recommended): https://skim-app.sourceforge.io/

