LaTeX to Quarto Conversion
Convert a full LaTeX .tex article to a Quarto .qmd document that renders correctly
to HTML, PDF (Typst or LaTeX), and Word.
This skill handles the entire conversion pipeline: preamble extraction, document structure,
and all inline/block transformations.
This skill writes the output file (overwriting the input or writing to a second path).
Before writing, tell the user what file will be changed and remind them that git diff or
file history can recover the original.
Input Arguments
| Position |
Required |
Description |
| 1 |
Yes |
Path to the input .tex file (e.g., paper/paper.tex) |
| 2 |
No |
Output .qmd path. Defaults to same directory, .qmd extension. |
Example invocations:
/latex-to-quarto paper/paper.tex
/latex-to-quarto paper/paper.tex paper/paper.qmd
Quick Navigation: Use Which Reference
| Task |
Reference File |
\documentclass, \usepackage, \title, \author → YAML |
01-preamble-yaml.md |
\begin{document}, \maketitle, \begin{abstract}, \appendix |
02-document-structure.md |
\textbf, \emph, \texttt, \footnote, \href |
03-text-formatting.md |
equation, align, gather, inline math delimiters |
04-math.md |
\cite, \citep, \citet, natbib/biblatex commands |
05-citations.md |
\label, \ref, \autoref, \eqref, prefix mapping |
06-cross-references.md |
\includegraphics, figure environment, subfigures |
07-figures.md |
tabular, table, booktabs, \multicolumn |
08-tables.md |
\section, \subsection, itemize, enumerate |
09-sections-lists.md |
Special characters, \newpage, verbatim, \input |
10-misc.md |
Step-by-Step Workflow
1. Parse Arguments
Identify the input .tex path (arg 1) and output path (arg 2).
If arg 2 is omitted, replace the .tex extension with .qmd in the same directory.
2. Read the File
Use the Read tool to load the full .tex file.
Hold the entire content in memory — you will produce one complete .qmd file at the end.
3. Extract and Convert the Preamble
Everything before \begin{document} is the preamble. Extract:
\documentclass options → YAML format: settings
\title{}, \author{}, \date{} → YAML title:, author:, date:
\bibliography{file} / \addbibresource{file} → YAML bibliography:
- Package hints (
geometry, setspace, natbib, biblatex) → YAML format options
See 01-preamble-yaml.md for the full mapping table.
4. Strip Document Wrapper
Remove \begin{document} and \end{document}.
Remove \maketitle (title is rendered from YAML automatically).
Convert \begin{abstract}...\end{abstract} to YAML abstract:.
See 02-document-structure.md.
5. Apply All Body Transformations
Work through the full document body and apply every applicable rule. Key principles:
- Preserve math regions: Never alter content inside
$...$ or $$...$$ except to
move \label{} outside display math and convert delimiters (\(...\) → $...$).
- Handle nesting:
\textbf{\emph{text}} → ***text***. Process inner commands first.
- Be complete: Scan the entire file. Fix every instance of each pattern, not just the first.
- Apply all categories: Work through every reference file. A single paragraph may
require rules from multiple categories.
Apply reference files in this order (structural → inline):
- 09-sections-lists.md — headings and lists
- 05-citations.md — citations
- 06-cross-references.md — labels and references
- 07-figures.md — figures
- 08-tables.md — tables
- 04-math.md — math environments and delimiters
- 03-text-formatting.md — inline formatting
- 10-misc.md — special characters and remaining patterns
6. Assemble the QMD File
Combine:
- YAML front matter (between
--- delimiters)
- Converted document body (blank line after closing
---)
7. Write the Output File
Use the Write tool to write the complete .qmd file in one pass.
Do not use Edit for individual substitutions — a single full write ensures nothing is missed.
8. Report to the User
Tell the user:
- Output path written
- Summary of conversions by category (citation count, figure count, table count, etc.)
- Items requiring manual review with approximate line numbers
- Reminder to run
quarto render to verify the output
Key Conceptual Differences: LaTeX vs. Quarto
Preamble → YAML Front Matter
LaTeX uses a \documentclass preamble; Quarto uses YAML front matter between ---.
% LaTeX preamble
\documentclass[12pt,a4paper]{article}
\usepackage[margin=1in]{geometry}
\title{My Paper}
\author{Jane Doe}
\date{\today}
\bibliography{refs}
# Quarto YAML front matter
---
title: "My Paper"
author: "Jane Doe"
date: today
bibliography: refs.bib
format:
html: default
pdf:
documentclass: article
papersize: a4
fontsize: 12pt
geometry: margin=1in
---
Math Content Is Preserved as LaTeX
Unlike conversion to Typst, Quarto uses LaTeX math directly.
Inline \(...\) → $...$; display \[...\] → $$...$$.
Math content (operators, symbols, matrices) stays unchanged.
Citations Use Pandoc Bracket Syntax
\citep{key} → [@key]; \citet{key} → @key.
The .bib file is referenced in YAML and left unchanged.
Cross-References Use @label Not \ref{}
\ref{fig:map} → @fig-map. Labels move from standalone \label{} commands
into element attribute blocks {#fig-map}.
Minimal Conversion Example
Input (paper.tex):
\documentclass[12pt]{article}
\usepackage{natbib}
\title{My Study}
\author{Jane Doe}
\date{2025}
\begin{document}
\maketitle
\begin{abstract}
We examine the effect of X on Y.
\end{abstract}
\section{Introduction}
Prior work \citep{smith2020} shows that $x > 0$.
See Figure~\ref{fig:map} for an overview.
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{figs/map.pdf}
\caption{Study region.}
\label{fig:map}
\end{figure}
\bibliography{refs}
\end{document}
Output (paper.qmd):
---
title: "My Study"
author: "Jane Doe"
date: 2025
bibliography: refs.bib
---
## Abstract
We examine the effect of X on Y.
# Introduction
Prior work [@smith2020] shows that $x > 0$.
See @fig-map for an overview.
{#fig-map width=80% fig-align="center"}
Patterns Requiring Manual Review
Flag these in your report with a suggested fix but no automatic conversion:
| Pattern |
Suggested Quarto Equivalent |
\begin{theorem}, \begin{proof}, \begin{lemma} |
::: {.callout-note} div, or install a theorem extension |
\newcommand{}{} / \renewcommand{}{} |
Inline the macro expansion throughout; flag remaining uses |
\input{file} / \include{file} |
Inline contents or use {{< include file.qmd >}} shortcode |
\vspace{} / \hspace{} |
Remove or replace with CSS; no direct Quarto equivalent |
\multicolumn{}{}{} in tables |
Requires manual table restructuring |
| TikZ / PGF diagrams |
Remove or replace with Mermaid/Observable JS |
Beamer \begin{frame} |
Switch to format: revealjs with ## slide headings |
\bibliographystyle{} |
Remove; use csl: in YAML if a specific citation style is needed |
Multiple \label in one align block |
Each labeled row may need its own equation block |
What to Preserve Unchanged
- LaTeX math content inside
$...$ and $$...$$
- File paths in
\includegraphics and \bibliography (adjust extension if needed)
- Existing
@ref and [@citation] patterns already in correct Quarto form
- Content inside
\begin{verbatim}...\end{verbatim} (convert to fenced block, keep content)
1---2name: latex-to-quarto3description: 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.4---56# LaTeX to Quarto Conversion78Convert a full LaTeX `.tex` article to a Quarto `.qmd` document that renders correctly9to HTML, PDF (Typst or LaTeX), and Word.10This skill handles the entire conversion pipeline: preamble extraction, document structure,11and all inline/block transformations.1213**This skill writes the output file** (overwriting the input or writing to a second path).14Before writing, tell the user what file will be changed and remind them that `git diff` or15file history can recover the original.1617---1819## Input Arguments2021| Position | Required | Description |22|----------|----------|-------------|23| 1 | **Yes** | Path to the input `.tex` file (e.g., `paper/paper.tex`) |24| 2 | No | Output `.qmd` path. Defaults to same directory, `.qmd` extension. |2526**Example invocations:**27```28/latex-to-quarto paper/paper.tex29/latex-to-quarto paper/paper.tex paper/paper.qmd30```3132---3334## Quick Navigation: Use Which Reference3536| Task | Reference File |37|------|----------------|38| `\documentclass`, `\usepackage`, `\title`, `\author` → YAML | [01-preamble-yaml.md](references/01-preamble-yaml.md) |39| `\begin{document}`, `\maketitle`, `\begin{abstract}`, `\appendix` | [02-document-structure.md](references/02-document-structure.md) |40| `\textbf`, `\emph`, `\texttt`, `\footnote`, `\href` | [03-text-formatting.md](references/03-text-formatting.md) |41| `equation`, `align`, `gather`, inline math delimiters | [04-math.md](references/04-math.md) |42| `\cite`, `\citep`, `\citet`, natbib/biblatex commands | [05-citations.md](references/05-citations.md) |43| `\label`, `\ref`, `\autoref`, `\eqref`, prefix mapping | [06-cross-references.md](references/06-cross-references.md) |44| `\includegraphics`, `figure` environment, subfigures | [07-figures.md](references/07-figures.md) |45| `tabular`, `table`, `booktabs`, `\multicolumn` | [08-tables.md](references/08-tables.md) |46| `\section`, `\subsection`, `itemize`, `enumerate` | [09-sections-lists.md](references/09-sections-lists.md) |47| Special characters, `\newpage`, `verbatim`, `\input` | [10-misc.md](references/10-misc.md) |4849---5051## Step-by-Step Workflow5253### 1. Parse Arguments5455Identify the input `.tex` path (arg 1) and output path (arg 2).56If arg 2 is omitted, replace the `.tex` extension with `.qmd` in the same directory.5758### 2. Read the File5960Use the `Read` tool to load the full `.tex` file.61Hold the entire content in memory — you will produce one complete `.qmd` file at the end.6263### 3. Extract and Convert the Preamble6465Everything before `\begin{document}` is the **preamble**. Extract:6667- `\documentclass` options → YAML `format:` settings68- `\title{}`, `\author{}`, `\date{}` → YAML `title:`, `author:`, `date:`69- `\bibliography{file}` / `\addbibresource{file}` → YAML `bibliography:`70- Package hints (`geometry`, `setspace`, `natbib`, `biblatex`) → YAML format options7172See [01-preamble-yaml.md](references/01-preamble-yaml.md) for the full mapping table.7374### 4. Strip Document Wrapper7576Remove `\begin{document}` and `\end{document}`.77Remove `\maketitle` (title is rendered from YAML automatically).78Convert `\begin{abstract}...\end{abstract}` to YAML `abstract:`.79See [02-document-structure.md](references/02-document-structure.md).8081### 5. Apply All Body Transformations8283Work through the full document body and apply every applicable rule. Key principles:8485- **Preserve math regions**: Never alter content inside `$...$` or `$$...$$` except to86 move `\label{}` outside display math and convert delimiters (`\(...\)` → `$...$`).87- **Handle nesting**: `\textbf{\emph{text}}` → `***text***`. Process inner commands first.88- **Be complete**: Scan the entire file. Fix every instance of each pattern, not just the first.89- **Apply all categories**: Work through every reference file. A single paragraph may90 require rules from multiple categories.9192Apply reference files in this order (structural → inline):93941. [09-sections-lists.md](references/09-sections-lists.md) — headings and lists952. [05-citations.md](references/05-citations.md) — citations963. [06-cross-references.md](references/06-cross-references.md) — labels and references974. [07-figures.md](references/07-figures.md) — figures985. [08-tables.md](references/08-tables.md) — tables996. [04-math.md](references/04-math.md) — math environments and delimiters1007. [03-text-formatting.md](references/03-text-formatting.md) — inline formatting1018. [10-misc.md](references/10-misc.md) — special characters and remaining patterns102103### 6. Assemble the QMD File104105Combine:1061. YAML front matter (between `---` delimiters)1072. Converted document body (blank line after closing `---`)108109### 7. Write the Output File110111Use the `Write` tool to write the complete `.qmd` file in one pass.112Do not use `Edit` for individual substitutions — a single full write ensures nothing is missed.113114### 8. Report to the User115116Tell the user:117- **Output path** written118- **Summary of conversions** by category (citation count, figure count, table count, etc.)119- **Items requiring manual review** with approximate line numbers120- **Reminder** to run `quarto render` to verify the output121122---123124## Key Conceptual Differences: LaTeX vs. Quarto125126### Preamble → YAML Front Matter127128LaTeX uses a `\documentclass` preamble; Quarto uses YAML front matter between `---`.129130```latex131% LaTeX preamble132\documentclass[12pt,a4paper]{article}133\usepackage[margin=1in]{geometry}134\title{My Paper}135\author{Jane Doe}136\date{\today}137\bibliography{refs}138```139140```yaml141# Quarto YAML front matter142---143title: "My Paper"144author: "Jane Doe"145date: today146bibliography: refs.bib147format:148 html: default149 pdf:150 documentclass: article151 papersize: a4152 fontsize: 12pt153 geometry: margin=1in154---155```156157### Math Content Is Preserved as LaTeX158159Unlike conversion to Typst, Quarto uses **LaTeX math directly**.160Inline `\(...\)` → `$...$`; display `\[...\]` → `$$...$$`.161Math *content* (operators, symbols, matrices) stays unchanged.162163### Citations Use Pandoc Bracket Syntax164165`\citep{key}` → `[@key]`; `\citet{key}` → `@key`.166The `.bib` file is referenced in YAML and left unchanged.167168### Cross-References Use `@label` Not `\ref{}`169170`\ref{fig:map}` → `@fig-map`. Labels move from standalone `\label{}` commands171into element attribute blocks `{#fig-map}`.172173---174175## Minimal Conversion Example176177**Input (`paper.tex`):**178```latex179\documentclass[12pt]{article}180\usepackage{natbib}181\title{My Study}182\author{Jane Doe}183\date{2025}184\begin{document}185\maketitle186\begin{abstract}187We examine the effect of X on Y.188\end{abstract}189\section{Introduction}190Prior work \citep{smith2020} shows that $x > 0$.191See Figure~\ref{fig:map} for an overview.192\begin{figure}[h]193 \centering194 \includegraphics[width=0.8\textwidth]{figs/map.pdf}195 \caption{Study region.}196 \label{fig:map}197\end{figure}198\bibliography{refs}199\end{document}200```201202**Output (`paper.qmd`):**203```markdown204---205title: "My Study"206author: "Jane Doe"207date: 2025208bibliography: refs.bib209---210211## Abstract212213We examine the effect of X on Y.214215# Introduction216217Prior work [@smith2020] shows that $x > 0$.218See @fig-map for an overview.219220{#fig-map width=80% fig-align="center"}221```222223---224225## Patterns Requiring Manual Review226227Flag these in your report with a suggested fix but no automatic conversion:228229| Pattern | Suggested Quarto Equivalent |230|---------|------------------------------|231| `\begin{theorem}`, `\begin{proof}`, `\begin{lemma}` | `::: {.callout-note}` div, or install a theorem extension |232| `\newcommand{}{}` / `\renewcommand{}{}` | Inline the macro expansion throughout; flag remaining uses |233| `\input{file}` / `\include{file}` | Inline contents or use `{{< include file.qmd >}}` shortcode |234| `\vspace{}` / `\hspace{}` | Remove or replace with CSS; no direct Quarto equivalent |235| `\multicolumn{}{}{}` in tables | Requires manual table restructuring |236| TikZ / PGF diagrams | Remove or replace with Mermaid/Observable JS |237| Beamer `\begin{frame}` | Switch to `format: revealjs` with `##` slide headings |238| `\bibliographystyle{}` | Remove; use `csl:` in YAML if a specific citation style is needed |239| Multiple `\label` in one `align` block | Each labeled row may need its own equation block |240241---242243## What to Preserve Unchanged244245- LaTeX math *content* inside `$...$` and `$$...$$`246- File paths in `\includegraphics` and `\bibliography` (adjust extension if needed)247- Existing `@ref` and `[@citation]` patterns already in correct Quarto form248- Content inside `\begin{verbatim}...\end{verbatim}` (convert to fenced block, keep content)