LaTeX Expert — Main Agent
Overview
This is the top-level entry point for the LaTeX skill system. Read this file
first, then navigate to the relevant module for deep guidance.
Quick Module Routing
| Task |
Module to read |
| Draw any diagram, figure, or plot |
modules/tikz.md |
| Control page size, margins, columns |
modules/geometry.md |
Citations, bibliography, .bib files |
modules/bibliography.md |
| Chemistry formulas, molecules, reactions |
modules/chemistry.md |
| Embed Python code or data in LaTeX |
modules/python-latex.md |
| Math operators, environments, delimiters |
references/math.md |
| Choose or debug packages |
references/packages.md |
Document Structure & Compilation
Standard Structure
\documentclass[a4paper,12pt]{article}
% Preamble — packages then macros
\usepackage[style=authoryear,backend=biber]{biblatex}
\addbibresource{references.bib}
\title{Title}
\author{Author}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
Text.
\printbibliography
\end{document}
Compilation
Always use latexmk. It automates all multi-pass compilation.
latexmk -pdf document.tex # compile
latexmk -c # clean auxiliary files
latexmk -C # clean including PDF
For PythonTeX documents, use the three-pass sequence:
pdflatex doc.tex && pythontex doc.tex && pdflatex doc.tex
Core Principles
- Prefer modern packages —
biblatex over BibTeX, mathtools over plain
amsmath, tabularray over tabular, fontspec with LuaLaTeX over
legacy font commands.
- Load
hyperref last (except cleveref, which goes after hyperref).
- Use
latexmk — never manually chain pdflatex/biber for standard
documents.
- Comment your preamble — group packages by purpose with section comments.
- Use
\newcommand early — define all custom macros in the preamble,
never inline.
Mathematical Typesetting (Summary)
- Use
align for display math; avoid eqnarray.
- Use
\DeclareMathOperator for named operators (e.g., \Tr, \argmax).
- Use
\lvert, \rvert, \lVert, \rVert for absolute value and norm.
- See
references/math.md for the full reference.
Bibliography (Summary)
- Use
biblatex with backend=biber. Never legacy BibTeX for new projects.
- Cite with
\autocite{} (context-aware) or \textcite{} (in-sentence).
- See
modules/bibliography.md for the full reference.
Package Loading Order
% 1. Document class
\documentclass{article}
% 2. Encoding (pdflatex only — omit for LuaLaTeX/XeLaTeX)
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% 3. Language
\usepackage[english]{babel}
\usepackage{csquotes} % required by biblatex
% 4. Math
\usepackage{mathtools} % loads amsmath
\usepackage{amssymb}
% 5. Typography
\usepackage{microtype}
\usepackage[margin=2.5cm]{geometry}
% 6. Domain-specific (tikz, chemistry, etc.)
\usepackage{tikz}
% 7. Bibliography
\usepackage[style=authoryear,backend=biber]{biblatex}
% 8. Graphics
\usepackage{graphicx}
\usepackage{xcolor}
% 9. Tables
\usepackage{booktabs}
% 10. hyperref LAST (except cleveref)
\usepackage{hyperref}
\usepackage{cleveref}
Templates
- Standard document →
assets/template.tex
- Chemistry document →
assets/template-chemistry.tex
- PythonTeX document →
assets/template-pythontex.tex
1---2name: latex-expert3description: Expert guidance on LaTeX document preparation, formatting, mathematical typesetting, bibliography management, TikZ graphics, chemistry, and Python integration. Use for creating, debugging, or extending any LaTeX document.4---56# LaTeX Expert — Main Agent78## Overview910This is the top-level entry point for the LaTeX skill system. Read this file11first, then navigate to the relevant module for deep guidance.1213## Quick Module Routing1415| Task | Module to read |16|---|---|17| Draw any diagram, figure, or plot | `modules/tikz.md` |18| Control page size, margins, columns | `modules/geometry.md` |19| Citations, bibliography, `.bib` files | `modules/bibliography.md` |20| Chemistry formulas, molecules, reactions | `modules/chemistry.md` |21| Embed Python code or data in LaTeX | `modules/python-latex.md` |22| Math operators, environments, delimiters | `references/math.md` |23| Choose or debug packages | `references/packages.md` |2425---2627## Document Structure & Compilation2829### Standard Structure3031```tex32\documentclass[a4paper,12pt]{article}3334% Preamble — packages then macros35\usepackage[style=authoryear,backend=biber]{biblatex}36\addbibresource{references.bib}3738\title{Title}39\author{Author}40\date{\today}4142\begin{document}43\maketitle4445\section{Introduction}46Text.4748\printbibliography49\end{document}50```5152### Compilation5354Always use `latexmk`. It automates all multi-pass compilation.5556```bash57latexmk -pdf document.tex # compile58latexmk -c # clean auxiliary files59latexmk -C # clean including PDF60```6162For PythonTeX documents, use the three-pass sequence:6364```bash65pdflatex doc.tex && pythontex doc.tex && pdflatex doc.tex66```6768---6970## Core Principles71721. **Prefer modern packages** — `biblatex` over BibTeX, `mathtools` over plain73 `amsmath`, `tabularray` over `tabular`, `fontspec` with LuaLaTeX over74 legacy font commands.752. **Load `hyperref` last** (except `cleveref`, which goes after `hyperref`).763. **Use `latexmk`** — never manually chain `pdflatex`/`biber` for standard77 documents.784. **Comment your preamble** — group packages by purpose with section comments.795. **Use `\newcommand` early** — define all custom macros in the preamble,80 never inline.8182---8384## Mathematical Typesetting (Summary)8586- Use `align` for display math; **avoid `eqnarray`**.87- Use `\DeclareMathOperator` for named operators (e.g., `\Tr`, `\argmax`).88- Use `\lvert`, `\rvert`, `\lVert`, `\rVert` for absolute value and norm.89- See `references/math.md` for the full reference.9091---9293## Bibliography (Summary)9495- Use `biblatex` with `backend=biber`. Never legacy BibTeX for new projects.96- Cite with `\autocite{}` (context-aware) or `\textcite{}` (in-sentence).97- See `modules/bibliography.md` for the full reference.9899---100101## Package Loading Order102103```tex104% 1. Document class105\documentclass{article}106107% 2. Encoding (pdflatex only — omit for LuaLaTeX/XeLaTeX)108\usepackage[utf8]{inputenc}109\usepackage[T1]{fontenc}110111% 3. Language112\usepackage[english]{babel}113\usepackage{csquotes} % required by biblatex114115% 4. Math116\usepackage{mathtools} % loads amsmath117\usepackage{amssymb}118119% 5. Typography120\usepackage{microtype}121\usepackage[margin=2.5cm]{geometry}122123% 6. Domain-specific (tikz, chemistry, etc.)124\usepackage{tikz}125126% 7. Bibliography127\usepackage[style=authoryear,backend=biber]{biblatex}128129% 8. Graphics130\usepackage{graphicx}131\usepackage{xcolor}132133% 9. Tables134\usepackage{booktabs}135136% 10. hyperref LAST (except cleveref)137\usepackage{hyperref}138\usepackage{cleveref}139```140141---142143## Templates144145- Standard document → `assets/template.tex`146- Chemistry document → `assets/template-chemistry.tex`147- PythonTeX document → `assets/template-pythontex.tex`