Skip to content

Getting Started

Sebastian Skov Nielsen edited this page Aug 1, 2026 · 1 revision

Getting Started

This guide creates a multi-chapter PDF project using the package directly from npm. You do not need to install Leafmark globally.

1. Install system tools

Leafmark needs Node.js 20+, Pandoc, and a LaTeX engine for PDF output. Follow Installation, then verify the machine:

pnpx @skxv/leafmark doctor

Every required line should say ok. HTML-only and DOCX workflows do not require LaTeX.

2. Create a project

pnpx @skxv/leafmark init ./my-report
cd my-report

Leafmark creates:

my-report/
├── .leafmark/
│   └── config.json
├── introduction.md
└── sources.bib

3. Add metadata

Edit .leafmark/config.json, or create _frontmatter.md:

---
title: My First Report
subtitle: A Leafmark example
author:
  - Your Name
date: 2026-08-01
toc: true
number-sections: true
---

If both locations define a metadata key, _frontmatter.md wins.

4. Write chapters

Edit introduction.md:

# Introduction

Leafmark combines ordinary Markdown files into one document.

## Purpose

This report demonstrates the basic workflow.

Add findings.md:

# Findings

The document can contain tables, images, links, citations, and code.

5. Choose chapter order

Run the interactive organizer:

pnpx @skxv/leafmark order

Use ↑/↓ to select, Space to grab or release a chapter, Enter to save, and q to cancel. The resulting order is stored in .leafmark/config.json.

6. Build

pnpx @skxv/leafmark

The output is dist/my-report.pdf. Other common builds are:

pnpx @skxv/leafmark --html
pnpx @skxv/leafmark --html-only
pnpx @skxv/leafmark --output-format docx
pnpx @skxv/leafmark watch

7. Apply a theme

pnpx @skxv/leafmark theme list
pnpx @skxv/leafmark theme use classic
pnpx @skxv/leafmark

The theme is copied into .leafmark/theme/, so the installed result is local and inspectable. See Themes.

Next steps

Clone this wiki locally