Get AI summaries of any video or article — Sign up free
Using Pandoc to write PDFs, Word documents, and slideshows in Markdown - Obsidian Community Talk thumbnail

Using Pandoc to write PDFs, Word documents, and slideshows in Markdown - Obsidian Community Talk

5 min read

Based on Obsidian Community Talks's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Pandoc conversions follow a repeatable pattern: specify the input Markdown file (with extension) and an output filename/extension, and expect overwriting if the output name already exists.

Briefing

Pandoc turns an Obsidian-style Markdown file into polished outputs—Word documents, PDFs, and Reveal.js slide decks—by converting the content through a shared internal structure and then rendering it in the target format. The practical takeaway from this community talk is that once the command-line basics are understood (paths, input/output, and options), a repeatable workflow emerges: convert, add citations, apply custom styling, and automate the whole process inside Obsidian.

The session starts with command-line fundamentals that matter specifically for Pandoc usage. Commands follow a pattern: a program name plus arguments (like the input file) and optional flags (like output format or styling options). Just as important is “perspective” in the filesystem: absolute paths start from the computer’s root and work regardless of where the terminal is; relative paths depend on the current working directory. That distinction becomes the lever for shortening commands later.

With that foundation, Pandoc is introduced as a command-line converter that supports many document formats. Conversions follow a consistent structure: call `pandoc`, point it at an input file (including the extension so it knows the source type), specify an output filename and extension, and run. The talk demonstrates Markdown → Word and Markdown → PDF conversions using the same Markdown source. A key practical warning appears early: Pandoc overwrites output files if the target name already exists. Another concrete limitation shows up with embedded images: one embedding style carries over into Word and PDFs, while the other (the wiki-link style) does not.

Citations are handled through a three-part setup. First, citations are inserted into the Markdown using a site key (e.g., square brackets with an `@` prefix and the key). Second, Pandoc must be told where the bibliography data lives—typically by exporting a Zotero library to BibTeX or CSL JSON. Third, Pandoc needs a citation style definition (commonly APA) provided via a URL to a CSL style file. When those pieces are wired together, Pandoc generates both in-text citations and a reference list—though the reference heading must be added manually in the input.

For formatting beyond Pandoc’s defaults, the talk moves to “reference documents,” a Word-oriented template approach. The workflow is: export Pandoc’s default Word reference document, edit only the styles (not the content), then pass that reference document into the conversion command. The result is Word output with customized heading and paragraph styling.

Automation inside Obsidian comes next. The Snippets plugin lets users run shell commands from Markdown code blocks, so conversions can be triggered without leaving the editor. Chaining commands with `&` enables shorter relative-path commands by first switching into a common directory. Adding `start` opens the generated file immediately. Templater then layers on interactivity: it can pull the current file title/path, prompt for which citation style or reference document to use, and generate the final Pandoc command.

Finally, Reveal.js slideshows are produced from Markdown via Pandoc’s `reveal.js` output. The talk explains how YAML metadata becomes the title slide, how heading levels map to slide structure, and how options like theme selection, CSS injection, and reference handling can be combined. The closing Q&A highlights two workflow pain points: setting defaults to avoid repeating bibliography/style flags (via Pandoc’s data directory) and handling Obsidian block embeds (often better supported by an Obsidian Pandoc plugin, with command-line Pandoc as a fallback).

Cornell Notes

Pandoc provides a consistent command-line workflow for converting Obsidian-style Markdown into Word, PDF, and Reveal.js slides. The talk emphasizes two essentials: use the right filesystem paths (absolute vs relative) and follow Pandoc’s input/output command structure, including output overwriting behavior. Citations require three linked pieces: site-key citations in Markdown, a bibliography export from Zotero (BibTeX or CSL JSON), and a CSL citation style (e.g., APA) supplied to Pandoc. For better formatting, Word “reference documents” let users customize styles while keeping the template’s content intact. Automation is achieved by running Pandoc commands inside Obsidian using the Snippets plugin, then adding prompts and variables with Templater, and mapping Markdown headings into Reveal.js slide layouts.

Why does absolute vs relative path handling matter for Pandoc commands in an Obsidian workflow?

Absolute paths start from the computer’s root and work regardless of the current directory, so they’re unambiguous but long. Relative paths depend on where the terminal is “standing” (the current working directory). The talk uses this to shorten commands: by chaining a `cd` into a common folder (like a shared OneDrive/Obsidian vault parent), the subsequent Pandoc command can reference inputs, reference documents, bibliography exports, and output folders with shorter relative paths.

What are the three components needed to get citations working through Pandoc?

Citations require: (1) site-key citations embedded in the Markdown (square brackets with an `@` prefix and the site key), (2) a bibliography export location from Zotero (BibTeX or CSL JSON), and (3) a citation style definition (a CSL file URL such as APA). Pandoc uses the site key to match the citation to the exported bibliography entry, then formats in-text citations and the reference list according to the selected CSL style.

What limitation shows up with image embedding when converting Markdown to Word/PDF?

The talk notes that one image embedding style survives conversion, while the wiki-link style does not. The practical implication is that image syntax in Obsidian Markdown may need adjustment so Pandoc can resolve and embed the images correctly in Word and PDF outputs.

How do “reference documents” customize Word output without rewriting the whole template?

The workflow is to export Pandoc’s default Word reference document, then edit only style settings (e.g., heading fonts, colors, paragraph formatting) in the Word style tabs. The content should remain unchanged. Pandoc is then run with an option pointing to this custom reference document, so conversions inherit the customized Word styles.

How can Obsidian reduce the friction of running long Pandoc commands?

The Snippets plugin allows executing shell commands from inside Obsidian via a fenced code block (e.g., a ```sh block). This keeps the workflow in the editor. Additional convenience comes from chaining commands with `&` (like `cd` followed by `pandoc`) and from using `start` so the generated file opens immediately. Templater can further automate by pulling the current file title/path and prompting for citation style/reference document choices.

How does Markdown structure map to Reveal.js slides when using Pandoc?

Reveal.js output uses heading levels to define slide layout: YAML metadata becomes the title slide, level one headings create horizontal slide sections, and level two headings create new slides “down” (vertical progression). Level three headings can remain on the same slide depending on the configured slide level. A horizontal/vertical slide break can also be forced using `---`.

Review Questions

  1. When would you prefer relative paths over absolute paths for Pandoc, and what command-line step makes that safe?
  2. What exact inputs must be provided to Pandoc to format citations in APA, and where do they originate?
  3. How does a Word reference document differ from a full Pandoc template, and what should be edited (styles vs content) to avoid breaking the template?

Key Points

  1. 1

    Pandoc conversions follow a repeatable pattern: specify the input Markdown file (with extension) and an output filename/extension, and expect overwriting if the output name already exists.

  2. 2

    Absolute paths are unambiguous but long; relative paths become practical once the terminal changes into a common working directory.

  3. 3

    Citations require three linked pieces: site-key citations in Markdown, a Zotero-exported bibliography (BibTeX or CSL JSON), and a CSL citation style (e.g., APA) provided to Pandoc.

  4. 4

    Word formatting customization is best done via Word “reference documents,” where only style settings are edited and the template content remains intact.

  5. 5

    Obsidian automation can be layered: Snippets runs shell commands inside notes, and Templater adds variables and prompts to generate the final Pandoc command.

  6. 6

    Reveal.js slide decks can be generated from Markdown by mapping heading levels to slide structure, using YAML metadata for the title slide, and optionally applying themes/CSS and citation handling.

  7. 7

    Some Obsidian-specific content (like block embeds) may require an Obsidian Pandoc plugin rather than relying solely on command-line Pandoc.

Highlights

Pandoc’s command-line workflow becomes manageable once absolute vs relative paths are understood and relative paths are enabled by `cd` into a shared directory.
Citations aren’t a single setting: they depend on site-key markup in Markdown, a Zotero bibliography export, and a CSL style definition (such as APA) supplied to Pandoc.
Custom Word styling is achieved by editing a Pandoc-exported Word reference document’s styles—not its content—then passing that reference document into the conversion command.
Snippets + Templater turns repetitive Pandoc commands into one-click conversions inside Obsidian, including interactive citation-style selection.
Reveal.js slide structure can be controlled directly from Markdown heading levels, with YAML metadata feeding the title slide and `---` forcing slide breaks.

Topics

Mentioned

  • PDF
  • AST
  • CSL
  • CSL JSON
  • BibTeX
  • APA
  • YAML
  • CSS
  • ODR
  • GUI