latex
This skill should be used when the user asks to "create a LaTeX document", "convert markdown to LaTeX", "make a PDF from markdown", "format as LaTeX", "write LaTeX", or wants to produce beautifully typeset documents. Handles LaTeX generation from any input source with professional typography, and optionally compiles to PDF.
Best use case
latex is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
This skill should be used when the user asks to "create a LaTeX document", "convert markdown to LaTeX", "make a PDF from markdown", "format as LaTeX", "write LaTeX", or wants to produce beautifully typeset documents. Handles LaTeX generation from any input source with professional typography, and optionally compiles to PDF.
Teams using latex should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/latex/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How latex Compares
| Feature / Agent | latex | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
This skill should be used when the user asks to "create a LaTeX document", "convert markdown to LaTeX", "make a PDF from markdown", "format as LaTeX", "write LaTeX", or wants to produce beautifully typeset documents. Handles LaTeX generation from any input source with professional typography, and optionally compiles to PDF.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# LaTeX Document Creator
Create beautifully formatted LaTeX documents from any input source (markdown files, plain text, structured data, or user instructions). Produce professional-quality typeset output following modern LaTeX best practices.
## Workflow
1. **Analyze input** - Read the source material, identify structure (headings, lists, tables, figures, math, code, citations)
2. **Determine document class** - Select appropriate class based on content type and length
3. **Generate LaTeX** - Produce a complete `.tex` file with proper preamble and body
4. **Compile to PDF** (if requested) - Detect platform and compile using `latexmk`
If the user provides additional formatting instructions, apply them. User instructions override defaults below.
## Document Class Selection
| Content Type | Class | When |
|---|---|---|
| Short documents, articles, memos | `scrartcl` | No chapters needed |
| Reports, theses, long documents | `scrreprt` | Chapter-level structure |
| Books, manuals | `scrbook` | Front/back matter, parts |
| Presentations | `beamer` | Slides |
Use KOMA-Script classes (`scrartcl`, `scrreprt`, `scrbook`) over standard classes for superior typography defaults and built-in customization.
## Standard Preamble
Organize the preamble in this order. Include only packages the document actually needs.
```latex
\documentclass[a4paper, 11pt]{scrartcl}
% --- Typography ---
\usepackage[T1]{fontenc}
\usepackage{lmodern} % Clean, professional font
\usepackage{microtype} % ESSENTIAL: character protrusion + font expansion
% --- Math (include only if document has math) ---
\usepackage{mathtools} % Superset of amsmath with fixes
\usepackage{amssymb}
% --- Layout ---
\usepackage{geometry}
% --- Tables & Figures ---
\usepackage{booktabs} % Professional table rules
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
% --- Lists ---
\usepackage{enumitem}
% --- Language & Quotes ---
\usepackage[english]{babel}
\usepackage{csquotes}
% --- Colors ---
\usepackage{xcolor}
% --- Code Listings (include only if document has code) ---
\usepackage{listings}
% --- Units (include only if document has quantities) ---
\usepackage{siunitx}
% --- Links & References (load near-last) ---
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue!70!black,
citecolor=green!50!black,
urlcolor=blue!70!black,
}
\usepackage{cleveref} % MUST be after hyperref
```
### Package Notes
- `microtype` is non-negotiable for professional output - always include it
- `mathtools` loads `amsmath` automatically; never load both
- `cleveref` must load after `hyperref`
- `hyperref` should load near-last
- For bibliography: use `biblatex` with `biber` backend, not legacy `bibtex`/`natbib`
## Typography Rules
### Fonts
- Default: `lmodern` (Latin Modern) - clean, professional, widely available
- Alternative serif: `libertinus`, `newtxtext`/`newtxmath` (Times-like)
- For system fonts (Unicode): switch to LuaLaTeX with `fontspec`
### Spacing and Punctuation
- En-dash for ranges: `2020--2025` renders as 2020–2025
- Em-dash for breaks: `word---word` renders as word—word
- Non-breaking space (`~`) before `\cite`, `\cref`, and between numbers and units
- Thin space before differentials: `\int f(x) \, dx`
- Use `\enquote{}` from `csquotes` for quotation marks, never manual quote characters
- Use `\emph{}` instead of `\textit{}` - semantic emphasis that adapts to context
- Use `\dots` for ellipses, never three periods
### Sentence Spacing
- After abbreviations (not ending a sentence): `e.g.\ this`, `i.e.\ that`
- After a capital letter ending a sentence: `NASA\@. The next sentence`
## Formatting Standards
### Tables
- Always use `booktabs`: `\toprule`, `\midrule`, `\bottomrule`
- Never use vertical rules (`|`) or `\hline`
- Place table captions **above** the table
- Place figure captions **below** the figure
### Figures
- Use `\centering` inside floats, not `\begin{center}`
- Default float placement: `[htbp]`
- Reference all figures in text before they appear
### Cross-References
- Use `\cref{}` from `cleveref` - automatically produces "Figure 1", "Table 2", etc.
- Label prefixes: `fig:`, `tab:`, `sec:`, `eq:`, `lst:`
- Place `\label` immediately after `\caption` or `\section`
### Lists
- Use `enumitem` for customization
- Avoid nesting deeper than 3 levels - restructure content instead
## Common Pitfalls to Avoid
- Never use `$$...$$` for display math - use `\[...\]` or `equation` environment
- Never use `\\` for paragraph breaks - use a blank line
- Never use `\begin{center}` inside floats - use `\centering`
- Never place `\label` before `\caption` - produces wrong reference numbers
- Never hardcode reference numbers - always use `\cref{}`
- Never use bare function names in math - use `\sin`, `\log`, or `\DeclareMathOperator`
- Escape special characters: `#`, `%`, `$`, `&`, `_`, `{`, `}`
## Markdown-to-LaTeX Conversion
When converting from markdown, apply these mappings:
| Markdown | LaTeX |
|---|---|
| `# Heading` | `\section{Heading}` |
| `## Heading` | `\subsection{Heading}` |
| `### Heading` | `\subsubsection{Heading}` |
| `**bold**` | `\textbf{bold}` |
| `*italic*` | `\emph{italic}` |
| `` `code` `` | `\texttt{code}` |
| `> blockquote` | `\begin{quote}...\end{quote}` |
| `- item` | `\begin{itemize}\item ...\end{itemize}` |
| `1. item` | `\begin{enumerate}\item ...\end{enumerate}` |
| `[text](url)` | `\href{url}{text}` |
| `` | `\begin{figure}...\includegraphics{path}...\end{figure}` |
| `` ```lang ``` `` | `\begin{lstlisting}[language=lang]...\end{lstlisting}` |
| `---` (horizontal rule) | `\bigskip\noindent\rule{\textwidth}{0.4pt}\bigskip` |
| Tables | `\begin{tabular}` with `booktabs` rules |
| `$math$` | `$math$` (same) |
| `$$math$$` | `\[math\]` |
### Conversion Guidelines
- Infer document title from the first `#` heading or filename
- Infer `\author` and `\date` if present in the source, otherwise omit
- Preserve the semantic structure - do not flatten or over-nest headings
- Convert markdown tables to `booktabs`-styled `tabular` environments
- Escape all LaTeX special characters in text content
- For documents with chapters, promote heading levels (`#` → `\chapter`, `##` → `\section`)
## Compiling to PDF
When the user requests PDF output, detect the platform and compile.
### Engine Selection
| Engine | Command | Use When |
|---|---|---|
| pdfLaTeX | `latexmk -pdf` | Default. ASCII/Latin content, standard fonts, fastest compilation |
| XeLaTeX | `latexmk -xelatex` | System fonts via `fontspec`, native Unicode |
| LuaLaTeX | `latexmk -lualatex` | System fonts + Lua scripting, no memory limits |
### Using latexmk (Preferred)
`latexmk` automatically runs the correct number of passes for cross-references, bibliographies, and indices. Always prefer it over manual multi-pass compilation.
```bash
latexmk -pdf document.tex # Compile to PDF (pdflatex)
latexmk -xelatex document.tex # Compile with XeTeX
latexmk -lualatex document.tex # Compile with LuaTeX
latexmk -c document.tex # Clean auxiliary files (keep PDF)
```
### Manual Compilation (When latexmk Is Unavailable)
```bash
# Simple document (no bibliography)
pdflatex document.tex && pdflatex document.tex
# Document with biblatex/biber bibliography
pdflatex document.tex && biber document && pdflatex document.tex && pdflatex document.tex
```
### Platform-Specific Installation
If LaTeX tools are not installed or compilation fails due to missing packages, read the appropriate platform guide for installation instructions:
- **Ubuntu/Debian**: Read `references/pdf-compilation-ubuntu.md`
- **macOS**: Read `references/pdf-compilation-macos.md`
Detect the platform with `uname -s` (`Linux` or `Darwin`).
Package installation requires system permissions — present the installation command to the user and let them confirm before running `sudo` or `brew` commands.Related Skills
skill-latex-implementation
Implement LaTeX documents following a plan. Invoke for LaTeX-language implementation tasks.
latex-research-posters
Create professional research posters in LaTeX using beamerposter, tikzposter, or baposter. Layout design, typography, color schemes, figure integration, accessibility, and quality control for conference presentations. Includes ready-to-use templates. For programmatic figure generation use matplotlib-scientific-plotting or plotly-interactive-visualization.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
swift-human-guidelines
Comprehensive Swift 6 and SwiftUI development guidelines for building iOS 26, iOS 18, iPadOS, macOS, watchOS, visionOS, and tvOS applications. Covers Foundation Models API, BGContinuedProcessingTask, Call Translation API, Liquid Glass design system, data-race safety, typed throws, synchronization primitives, SwiftUI/UIKit interoperability, zoom transitions, and document-based apps. Use when building new Apple platform apps, implementing Apple Intelligence features, optimizing performance with Swift 6 concurrency, following Apple Human Interface Guidelines, creating cross-platform applications, or working with iOS 26/18 APIs. Triggers on Swift code, SwiftUI views, Xcode projects, app architecture, background processing, translation features, Foundation Models, synchronization, actors, Sendable types, or modern Apple platform development.
swift-conventions
Swift coding conventions and best practices for modern Swift development. Use when writing, reviewing, or refactoring Swift code to ensure consistency with naming conventions, access control, async/await patterns, and SwiftUI/framework best practices.
swift-concurrency
Expert guidance on Swift Concurrency best practices, patterns, and implementation. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).
swedish-medications
Look up Swedish medication information from FASS (Farmaceutiska Specialiteter i Sverige). Use when users ask about medications, drugs, läkemedel, dosages, side effects (biverkningar), interactions, or need to understand prescriptions in Sweden. Covers all medications approved for use in Sweden.
swe-programming-elixir-phoenix
Phoenix Framework coding standards from authoritative docs/explanation/software-engineering/platform-web/tools/elixir-phoenix/ documentation
sw-tech-stack-planner
Use when user wants a tech stack recommendation, technology choices, docker-compose setup, or architecture decisions for a software project – reads vision.md, user-stories.md, use-cases.md and generates requirements/tech-stack.yaml silently.
sveltekit
Expert guidance for building modern, performant web applications with SvelteKit.
sveltekit-latest
Quick-reference for SvelteKit + Svelte 5 development (Feb 2026)
svelte-remote-functions
Guide for SvelteKit Remote Functions. Use this skill by default for all SvelteKit projects doing type-safe client-server communication with query (data fetching), form (progressive enhancement), command (imperative actions), or data invalidation/refresh patterns.