skip to content
Suraj Sahu
How to Series

Writing maths and citations in markdown.

This is a dirty, cheap and easy way to maintain docs including equations and sources in Markdown or Jupyter notebook and export to HTML (opens in a new tab) or PDF (opens in a new tab). You may choose not to use LaTeX at all.

1. Install the tools

  • Install VS Code and Pandoc.
  • For notebooks, install Microsoft’s Python and Jupyter extensions in VS Code.

2. Create your document model.md

Create a Markdown file model.md.

# Model notes
For this example, $c(x,t)$ is concentration, $x$ is position,
$t$ is time, and $D$ is a constant diffusion coefficient.
$$
\frac{\partial c}{\partial t}
= D\frac{\partial^2 c}{\partial x^2}.
\tag{1}
$$

3. Choose a citation method

Use direct links if you want to write the source labels yourself. Use Zotero if you want Pandoc to generate the citations and reference list.

Link the author’s name beside the claim. Add a short Sources: line for supporting references. For example, from your model notes:

In his 1905 paper, [Einstein](https://doi.org/10.1002/andp.19053220806)
connected the random motion of particles suspended in a liquid to molecular motion.
Sources: [Einstein (1905), Brownian motion](https://doi.org/10.1002/andp.19053220806).

This needs no Zotero or bibliography file. You write the labels and Sources line yourself. Local PDFs can also be linked using paths relative to the Markdown file.

To display an @ in the label, escape it:

[\@einstein1905](https://doi.org/10.1002/andp.19053220806)

Option B: Zotero bibliography

A citation key is a label for a source. Here, einstein1905 connects the citation in your document to the paper in references.bib.

  1. Install Zotero and its browser Connector, then Better BibTeX through Zotero > Tools > Plugins > Install Plugin From File.
  2. Create a Zotero collection and save your papers or webpages into it. Check the imported authors, title, date, and URL.
  3. For this example, import DOI 10.1002/andp.19053220806 and set its Citation Key to einstein1905. Keep automatic key regeneration off.
  4. Right-click the collection: Export Collection > Better BibLaTeX > Keep updated. Save as references.bib beside your document.
  5. Insert the matching citation key in your text:
Example paper citation [@einstein1905].
  1. Add this at the end of the document. Pandoc will place the reference list here:
## References
::: {#refs}
:::

Keep Zotero running for automatic updates. Edit records in Zotero, rather than its exported file. A .bib file is citation data; it does not require LaTeX.

You can mix both citation methods. Use Option B’s export command when the document contains bibliography citations.

4. Export to HTML

Save your document. In the terminal, run the matching command from your document folder. For Option B, keep references.bib in that folder too.

Option A: direct links

pandoc model.md --standalone --mathjax --metadata pagetitle="Model" -o model.html

Option B: bibliography citations

pandoc model.md --standalone --mathjax --citeproc --bibliography=references.bib --metadata link-citations=true --metadata pagetitle="Model" -o model.html

Both commands create model.html beside your document. --mathjax enables equation rendering; Option B also uses --citeproc to turn citation keys into formatted citations.

For Jupyter Notebooks, replace model.md in either command with:

model.ipynb --from=ipynb+citations+fenced_divs

5. Save as PDF

Choose with LaTeX or without LaTeX. The direct methods below start from model.md; the HTML method uses the file from Step 4. Each creates model.pdf.

With LaTeX

Install a LaTeX distribution, then run:

pandoc model.md --citeproc --bibliography=references.bib -o model.pdf

Pandoc converts the equations, citations and reference list into a PDF.

Without LaTeX

Method 1: Pandoc and Typst

Install Typst, then run:

pandoc model.md --pdf-engine=typst --citeproc --bibliography=references.bib -o model.pdf

This exports the equations and citations, but drops the manual \tag{1} number in this example. Use LaTeX or the HTML method below to keep it.

For direct links only, omit --citeproc --bibliography=references.bib from either command. For notebooks, replace model.md as shown in Step 4.

Method 2: HTML to PDF

Create model.html using Step 4. Install Python and run these once:

python -m pip install playwright
python -m playwright install chromium

Save html_to_pdf.py beside your document, then run:

python html_to_pdf.py model.html model.pdf

On macOS or Linux, use python3 if python is not available. The script waits for MathJax to render the equations, then creates the PDF. The HTML from Step 4 needs internet access to load MathJax.

Open model.pdf and check the equations and references. After editing your document, repeat the export commands.

Here is the output: HTML (opens in a new tab) and PDF (opens in a new tab).