--- name: latex-math-writeup description: Generate LaTeX documentation for mathematical research. Use when creating papers, notes, or documenting formulas, proofs, and verification results. argument-hint: license: Apache-2.0 metadata: version: "1.0" category: writing --- # LaTeX Math Writeup Generate formatted LaTeX documentation with theorems, proofs, and verification tables. ## When to Use - User asks for a LaTeX writeup - Creating a paper or research notes - Documenting formulas, proofs, or computations - User mentions "LaTeX", "writeup", "document", "PDF" ## Workflow 1. **Check for existing preamble** — if the project already has `.tex` files, use the same preamble/style. If not, ask the user if they have a preferred preamble or use the default one below. 2. **Gather content** — understand what mathematical results need documenting 3. **Create LaTeX source** — use standard document structure (see below) 4. **Add verification** — include computed verification tables where applicable 5. **Compile to PDF** — run `latexmk -pdf` or `pdflatex`, then **check the log for errors/warnings** and fix any issues before delivering 6. **Clean up** — remove build artifacts with `latexmk -c` ## Document Structure A typical mathematical writeup follows this structure: | Section | Content | |---------|---------| | 1. Introduction | Problem description, key objects, motivation | | 2. Preliminaries | Definitions, notation, background results | | 3-N. Main Results | Theorems, proofs, verification tables | | Summary | Table of all formulas and key results | ## Default Preamble If no existing preamble is available, use this as a starting point: ```latex \documentclass[11pt]{article} \usepackage{amsmath, amssymb, amsthm} \usepackage{hyperref} \usepackage{booktabs} \usepackage{geometry} \geometry{margin=1in} ``` This is intentionally minimal — customize for your needs (see Customization below). ## LaTeX Conventions ### Theorem Environments ```latex \newtheorem{theorem}{Theorem}[section] \newtheorem{lemma}[theorem]{Lemma} \newtheorem{proposition}[theorem]{Proposition} \newtheorem{corollary}[theorem]{Corollary} \theoremstyle{definition} \newtheorem{definition}[theorem]{Definition} \theoremstyle{remark} \newtheorem{remark}[theorem]{Remark} ``` ### Verification Tables When documenting computationally verified results, include verification tables: ```latex \begin{table}[h] \centering \begin{tabular}{c|c|c|c} Parameter & Computed & Expected & Match \\ \hline $n=1$ & 0.5000 & 1/2 & \checkmark \\ $n=2$ & 0.3333 & 1/3 & \checkmark \\ \end{tabular} \caption{Numerical verification of [result name]} \end{table} ``` ## Compilation ```bash # Create output directory mkdir -p output/ # Compile (handles cross-references automatically) cd output/ && latexmk -pdf document.tex # Check for errors — always review the log grep -E "^!" document.log || echo "No errors" grep -c "Warning" document.log # Clean build artifacts (keeps .tex and .pdf) latexmk -c ``` `latexmk -pdf` runs pdflatex as many times as needed for TOC and cross-references. `latexmk -c` removes `.aux`, `.log`, `.out`, `.toc`, `.fls`, `.fdb_latexmk`. **Always verify compilation is clean** — no undefined references, no missing packages, no overfull hboxes that break layout. Fix issues before delivering the PDF. ## Customization This skill is designed to be easily modified for your own workflow. Common things to customize: - **Preamble** — replace the default preamble with your own (custom packages, macros, fonts) - **Output directory** — change `output/` to wherever you keep your PDFs - **Document class** — swap `article` for `amsart`, `memoir`, `beamer`, etc. - **Theorem numbering** — adjust the `\newtheorem` definitions to match your convention ## Draft Mode When iterating on a document, compile in **draft mode** with visible labels so the user can easily reference specific equations, theorems, and sections: ```latex \usepackage{showkeys} % displays \label names in the margin \documentclass[draft]{article} % marks overfull boxes, skips images for speed ``` This makes it much easier for the user to say "equation eq:main-bound has a typo" instead of "the third equation on page 2." **Label everything** — every equation, theorem, lemma, section, and table should have a `\label{}`. Use descriptive names: `eq:spectral-gap`, `thm:main-result`, `sec:prelim`. Remove `showkeys` and `draft` option for the final version. ## Delivering the Draft If there's no prior setup for how the user views PDFs, ask: > "How should I share the draft? Options: (1) compile and you open the PDF directly, (2) send to Discord, (3) just share the .tex source. How do you usually view PDFs from the terminal?" Establish this once and reuse for the rest of the session. ## Tips - **No abstract** for short notes — the Introduction covers the description - Keep verification tables large enough to be convincing (10+ data points) - Use `\intertext{}` inside align environments for inline commentary - Prefer `align` over `equation` for multi-line displays