Skip to content

brycewang-stanford/Auto-Empirical-Research-Skills / skills/22-christopherkenny-skills/skills/latex-to-quarto

latex-to-quarto

Verified

Converts LaTeX article-class .tex documents to Quarto .qmd format for multi-format publishing (HTML, PDF, Word). Use when asked to convert, port, migrate, or translate a .tex LaTeX file to Quarto; when porting an academic paper or manuscript from LaTeX to Quarto; when a .tex document needs to render to HTML, Word, or Typst PDF. Covers preamble → YAML front matter, section headings, text formatting, math, citations (natbib/biblatex), cross-references, figures, tables, lists, footnotes, hyperlinks, and special characters.

references/04-math.md

View on GitHub
# Math

Quarto uses LaTeX math syntax directly. Math **content** (operators, symbols, matrices)
is preserved unchanged — only the **delimiters** and **environment wrappers** need conversion.

---

## Inline Math

| LaTeX | Quarto |
|-------|--------|
| `\(x + y\)` | `$x + y$` |
| `$ x + y $` (already `$...$`) | Keep as-is |

---

## Display Math — No Label

| LaTeX | Quarto |
|-------|--------|
| `\[x + y = z\]` | `$$x + y = z$$` |
| `\begin{equation*}...\end{equation*}` | `$$...$$` |
| `\begin{align*}...\end{align*}` | `$$\begin{aligned}...\end{aligned}$$` |
| `\begin{gather*}...\end{gather*}` | `$$\begin{gathered}...\end{gathered}$$` |
| `\begin{multline*}...\end{multline*}` | `$$\begin{multline}...\end{multline}$$` |
| `\begin{flalign*}...\end{flalign*}` | `$$\begin{aligned}...\end{aligned}$$` |

---

## Display Math — With Label

The `\label{}` command must be **removed from inside the math** and placed as a Quarto
attribute **after** the closing `$$` on the same line:

```latex
\begin{equation}
  E = mc^2
  \label{eq:einstein}
\end{equation}
```

Becomes:

```markdown
$$
E = mc^2
$$ {#eq-einstein}
```

### Labeled Environment Conversions

| LaTeX | Quarto |
|-------|--------|
| `\begin{equation}...\label{eq:x}...\end{equation}` | `$$...$$ {#eq-x}` |
| `\begin{align}...\label{eq:x}...\end{align}` | `$$\begin{aligned}...\end{aligned}$$ {#eq-x}` |
| `\begin{gather}...\label{eq:x}...\end{gather}` | `$$\begin{gathered}...\end{gathered}$$ {#eq-x}` |
| `\begin{multline}...\label{eq:x}...\end{multline}` | `$$\begin{multline}...\end{multline}$$ {#eq-x}` |

**Label prefix conversion**: `eq:x` → `eq-x` (colon replaced by hyphen).
See [06-cross-references.md](06-cross-references.md) for the full prefix mapping.

---

## Multiple Labels in One Align Block (Flag for Review)

In LaTeX, each row of an `align` environment can have its own `\label`:

```latex
\begin{align}
  y &= \alpha + \beta x \label{eq:ols} \\
  y &= \alpha + \beta x + \gamma z \label{eq:iv}
\end{align}
```

Quarto supports only one label per display math block.
Flag for manual review with this suggested split:

```markdown
$$
y = \alpha + \beta x
$$ {#eq-ols}

$$
y = \alpha + \beta x + \gamma z
$$ {#eq-iv}
```

---

## Environments to Keep Inside `$$`

These are standard LaTeX math environments that Quarto/MathJax/KaTeX renders inside `$$`:

| Environment | Notes |
|-------------|-------|
| `cases` | Keep `\begin{cases}...\end{cases}` inside `$$` |
| `matrix`, `pmatrix`, `bmatrix`, `vmatrix`, `Vmatrix` | Keep as-is |
| `array` | Keep as-is |
| `split` | Keep `\begin{split}...\end{split}` inside `$$` |
| `subarray` | Keep as-is |

Example — cases environment (no change needed to content):
```latex
\begin{equation}
  f(x) = \begin{cases} 1 & x > 0 \\ 0 & x \leq 0 \end{cases}
  \label{eq:step}
\end{equation}
```
→
```markdown
$$
f(x) = \begin{cases} 1 & x > 0 \\ 0 & x \leq 0 \end{cases}
$$ {#eq-step}
```

---

## Math Spacing Commands

Remove display-math vertical spacing arguments — they are not valid in Quarto:

| LaTeX | Quarto |
|-------|--------|
| `\\[6pt]` (in align/equation) | `\\` (remove spacing argument; note visual spacing is lost) |
| `\\[1em]` | `\\` |
| `\\[2mm]` | `\\` |

Keep these — they are valid LaTeX math spacing and render in MathJax/KaTeX:

| Command | Keep? |
|---------|-------|
| `\quad`, `\qquad` | Yes |
| `\,`, `\:`, `\;`, `\!` | Yes |
| `\text{...}` | Yes |
| `\hspace{1em}` inside math | Flag — may not render in all engines |

---

## What NOT to Change Inside Math

Never modify inside `$...$` or `$$...$$` (except the specific rules above):

- Greek letters: `\alpha`, `\beta`, `\gamma`, `\Delta`, ...
- Operators: `\frac`, `\sqrt`, `\sum`, `\int`, `\prod`, `\lim`, ...
- Math fonts: `\mathbf`, `\mathcal`, `\mathrm`, `\mathbb`, `\mathit`, ...
- Symbols: `\leq`, `\geq`, `\in`, `\subset`, `\cup`, `\cap`, `\to`, `\Rightarrow`, ...
- Subscripts and superscripts: `_`, `^`
- Accents: `\hat`, `\bar`, `\tilde`, `\dot`, `\vec`, ...
- Decorators: `\overline`, `\underbrace`, `\overbrace`, ...
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall