Markdown for academic writing: citations, math and Pandoc

Writing in Markdown6 min read

Draft academic papers, theses, and technical reports in plain Markdown using $...$ and $$...$$ for equations, \ce{} for chemistry, [^id] for footnotes, and [@key] for citations, then run Pandoc with --citeproc to build formatted .docx drafts or PDFs from a .bib file and .csl stylesheet. Separating drafting from typesetting keeps your manuscript readable in plain text and clean in Git diffs while producing Word Track Changes files for co-authors or LaTeX-grade PDFs. At final camera-ready stage, when a venue demands its own two-column .cls package, tight float placement, or automatic theorem numbering, raw LaTeX or Typst remains the better fit.

How the division of labor works underneath

Drafting directly in LaTeX mixes prose with \emph{}, \cite{}, \begin{itemize}, and package preambles, while drafting in Word locks text inside a binary .docx zip that Git cannot diff line by line.

Pairing Markdown with Pandoc splits the job into two distinct steps:

  1. Your manuscript sits as plain .md files beside refs.bib and a style sheet like ieee.csl. While writing in MiaoYan, cmark-gfm and bundled KaTeX 0.16.47 render headings, tables, math, footnotes, and diagrams offline in split view (⌘\), keeping editor and preview synced to the same source line.
  2. When compiling for co-authors or submission, Pandoc parses the Markdown AST, runs its built-in Citeproc engine against refs.bib and ieee.csl to turn [@key] markers into numbered [1] or author-date citations plus a sorted bibliography, and writes either .docx (with native Word OMML equations) or PDF via xelatex or typst.

Citations and bibliographies with BibTeX and CSL

Declare your bibliography and Citation Style Language file in YAML front matter at the top of the note:

---
title: "Latency Bounds for Replicated Log Compaction"
author: "Lin Chen"
bibliography: refs.bib
csl: ieee.csl
---

## Introduction

Prior consensus protocols bound tail latency under steady load [@lamport1998; @ongaro2014, pp. 4-6]. @knuth1984 [ch. 3] analyzes table growth, while recent measurements show lower variance [-@chen2025].

Pandoc's citation syntax covers parenthetical groups ([@lamport1998; @ongaro2014, pp. 4-6]), narrative citations (@knuth1984 [ch. 3]), suppressed authors ([-@chen2025]), and custom bibliography placement via ::: {#refs} (defaulting to the end of the document).

With Zotero and the Better BibTeX plugin, refs.bib stays auto-exported in your manuscript folder whenever references change. Switching from apa.csl to ieee.csl or nature.csl takes a one-line front matter edit. MiaoYan hides leading YAML front matter in preview and exports while leaving [@lamport1998] visible as plain text during drafting, making citekey typos easy to spot.

Equations, chemistry, footnotes, and word counts in MiaoYan

Most writing hours happen before Pandoc runs, while checking derivations, notes, and length limits.

Math and chemical notation

MiaoYan bundles KaTeX 0.16.47 and its mhchem extension inside the app, rendering math and chemistry offline in both preview and slides:

The Arrhenius rate constant $k = A e^{-E_a / (RT)}$ governs $\ce{2NO2 <=> N2O4}$ at $\pu{298.15 K}$:

$$
\begin{aligned}
\ln k &= \ln A - \frac{E_a}{R} \cdot \frac{1}{T} \tag{1}
\end{aligned}
$$

$...$ and $$...$$ always render as math; \(...\) and \[...\] also render in notes with no dollar math, while staying literal escapes beside dollar formulas so \[1\] references are preserved. KaTeX supports \tag{1} for manual equation numbers, and a malformed \ce{} formula stays as source text without breaking the page. Delimiter details live in LaTeX math in Markdown.

Named footnotes with inline popovers

Named footnotes ([^archive] with [^archive]: ...) avoid renumbering when paragraphs move, and indenting continuation paragraphs by four spaces keeps multi-paragraph notes intact.

Clicking a footnote superscript in MiaoYan's Mac preview or iPhone and iPad reader opens a floating popover right under the marker, so you can check a source note without scrolling to the end. Pressing Esc or scrolling closes it, and Option-clicking on Mac jumps to the bottom .footnotes list instead; see Markdown footnotes.

Word counts excluding front matter

Pressing ⌥⌘I on Mac (Show Info, or Note Info on iPhone and iPad) counts words, non-newline characters, paragraphs, and reading time at 300 words per minute after stripping YAML front matter and Markdown syntax marks, counting each CJK character alongside contiguous Latin words. Offline Mermaid and Markmap diagrams also support KaTeX math inside nodes.

Compiling to Word or PDF

When co-authors want .docx for Word Track Changes, run Pandoc from the manuscript folder:

sed 's#](/i/#](i/#g' paper.md | \
  pandoc --citeproc --reference-doc=custom-reference.docx -o paper.docx

sed rewrites MiaoYan's /i/figure.png local image links into relative i/figure.png paths so Pandoc finds figures inside your folder, while --citeproc builds the bibliography and converts TeX math into editable Word OMML equations. Styling custom-reference.docx is covered in Markdown to Word.

For sections without .bib citekeys yet, MiaoYan's browser-based Markdown to Word converter turns Markdown headings, tables, 2x Mermaid images, and $...$ math into a .docx with editable Word equations locally in your browser.

For a single-column PDF preprint or thesis draft, compile with xelatex or typst:

sed 's#](/i/#](i/#g' paper.md | \
  pandoc --citeproc --pdf-engine=xelatex -V papersize=a4 -V geometry:margin=25mm -o paper.pdf

For seminar handouts without BibTeX, File > Export > PDF in MiaoYan prints directly to A4; see Markdown to PDF on Mac.

When raw LaTeX or Typst fits better

Switch to native LaTeX or Typst when layout rules dominate:

  • Venues requiring publisher .cls files (IEEEtran, acmart, revtex4-2) or hand-tuned .tex source uploads on arXiv.
  • Two-column float placement (table*, subcaption) and tight conference page caps.
  • Heavy cross-referenced theorem, lemma, and equation numbering (amsthm, cleveref), which otherwise requires external filters like pandoc-crossref.

MiaoYan for Mac is open source on GitHub, and the App Store build runs on Mac, iPhone, and iPad.

What goes wrong and how to fix it

  1. Raw [@knuth1984] in output means --citeproc was omitted; bold (**knuth1984?) means the key is missing or misspelled in refs.bib.
  2. Wide $$...$$ formulas scroll horizontally in MiaoYan's preview, whereas PDF pages clip at the margin. Break long equations across lines with \begin{aligned} ... \end{aligned}.
  3. Bare \begin{align} stays plain text in MiaoYan; wrap aligned inside $$...$$ so both KaTeX and Pandoc render it.
  4. Pandoc treats ```mermaid fences as code unless a filter renders them; export SVG or PNG figures for Pandoc, or use MiaoYan's PDF export and Markdown to Word tool.

FAQ

Can I split a thesis into one Markdown file per chapter?

Yes. Keep 01-intro.md, 02-methods.md, and sibling chapters in one folder for fast editing in MiaoYan, then compile them together (pandoc metadata.yaml 01-intro.md 02-methods.md --citeproc -o thesis.pdf) for unified citations and numbering.

Are Word equations from Pandoc and MiaoYan's web tool editable?

Yes. Both output native Office Math Markup Language (OMML) equations rather than images, so collaborators in Word can click into any formula and edit symbols.

Do \ce{} chemistry formulas work when compiling PDF via xelatex?

MiaoYan's preview and web tool bundle mhchem automatically; for Pandoc plus xelatex, add header-includes: ["\\usepackage[version=4]{mhchem}"] to YAML front matter.

How do I fold an advisor's Word Track Changes back into Markdown?

Send the generated .docx out for review, then apply accepted edits back into your .md master file so .md and refs.bib remain the single source for the next build.