Study PDFs
How do I turn researched notes into a printable study sheet with formulas and index cards?
A study sheet is one markdown file: settings in YAML frontmatter, notes in the body, index cards as :::card blocks. @getnarro/study turns it into a PDF with the same input giving the same layout every time. It runs offline; nothing is fetched at render time. Raw HTML in the body is dropped.
Quick start
No Narro deck is involved; the commands are narro study.
npx @getnarro/cli study init notes
npx @getnarro/cli study check notes/algebra.md
npx @getnarro/cli study notes/algebra.md
study init [dir] copies a sample and refuses to overwrite an existing one. study check <file> validates without a browser: errors are printed as file › path: message and exit 1, warnings are printed and exit 0. study <file> writes the PDF next to the input (--out picks another path, --html also writes the HTML). Printing needs Chromium, the same browser narro export --pdf uses.
Frontmatter
Only title is required. A key the schema does not list is an error, so a typo does not silently do nothing.
| Field | Type | Required | Description |
|---|---|---|---|
title | string | yes | |
subtitle | string | — | Line under the title |
author | string | — | Shown under the title |
date | string | — | Shown under the title, printed as written |
lang | "de" | "en" | — | Document language, for hyphenation and labels. Default de. |
paper | "A4" | "Letter" | — | Paper size, for notes and cards. Default A4. |
columns | integer | — | Text columns of the whole sheet, 1 to 4. Default 1. |
font | "Inter" | "Source Serif 4" | "IBM Plex Sans" | — | Body font. Default Inter. |
accent | string | — | Hex colour for headings and boxes. Default #2563eb. |
cards | object | — | Index card grid and duplex settings |
cards.columns | integer | — | Cards per row, 1 to 6. Default 2. |
cards.rows | integer | — | Rows per page, 1 to 10. Default 4. |
cards.flip | "long" | "short" | — | Duplex binding edge: long mirrors columns on the back, short mirrors rows. Default long. |
cards.cutMarks | boolean | — | Print cut marks outside the grid. Default true. |
cards.numbered | boolean | — | Number the cards. Default true. |
Math
$…$ is inline math and $$…$$ on its own lines is display math, both rendered with KaTeX. A formula KaTeX cannot parse is an error that names the line.
The solutions of $ax^2 + bx + c = 0$ are
$$
x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$
Plots
A fenced block with the language plot draws function graphs as vector graphics in the PDF. There is no script and no extra dependency; the same text always gives the same picture. A plot works in running text, columns, boxes and cards, and is never split across a page.
```plot
y = x^2 | x²
y = sqrt(x) | Wurzel
y = sin(x)
x: -2pi..2pi
y: -2..4
width: 50%
```
y = <expression> | labelis one curve per line, at least one. The label is optional; a legend appears when a curve has a label or there is more than one curve. Each curve has its own colour and dash pattern, so it stays readable in black and white.x: a..bis the visible x range (default-5..5).y: a..bis the y range; without it, it is chosen from the curves.width: fullorwidth: 50%sets the width of the plot (defaultfull).#starts a comment.
Expressions use + - * / ^, parentheses, the variable x, the constants pi and e, and the functions sqrt abs sin cos tan exp ln log (log is base 10). The product sign may be left out: 2x, 3sin(x), 2(x+1), x(x-1). Unary minus binds looser than ^, so -x^2 is -(x^2). Where a curve is undefined or jumps out of the y range, as tan(x) does, the line is broken instead of joined.
A mistake (unknown key, bad range, bad expression) is an error that names the line in the markdown file; a plot is never silently left blank.
Boxes
A box is a fenced block named after its kind, with an optional title in brackets. The kinds are important, note, tip, warning and definition.
:::definition[Discriminant]
$D = b^2 - 4ac$ decides how many real solutions exist.
:::
Columns
columns: 2 in the frontmatter sets the whole sheet. For one part, wrap it in a columns block; an outer block needs more colons than the blocks inside it. :::column splits the part explicitly.
::::columns{n=2}
:::tip
Check the result by substituting it back.
:::
:::warning
Do not forget the second solution.
:::
::::
Cards
A card is a front, a line --- with a blank line above it (otherwise markdown reads a heading), and a back. The title in brackets is optional.
:::card[Formula]
What is the discriminant?
---
$D = b^2 - 4ac$
:::
Cards are collected from the whole body and printed after the notes, from page 1 on when the body has nothing else. The grid is cards.columns by cards.rows per page with a fixed cell size, so print at 100% scale. A partial last sheet keeps its empty cells so positions still line up. A card whose text would not fit its cell is a warning from study check, not an error; shorten it or use a larger cell.
Printing double-sided
Card pages come in pairs: a page of fronts, then a page of backs with the same cards mirrored, so each answer sits behind its question. Which mirror is right depends on how the printer turns the sheet, and a wrong choice puts every answer behind the wrong question.
cards.flip: long(the default): the sheet turns over its long edge, like a book. Printer dialogs call this “flip on long edge”. The backs reverse the columns of each row.cards.flip: short: the sheet turns over its short edge, like a notepad. Printer dialogs call this “flip on short edge”. The backs reverse the rows.
Print a single test sheet, hold it to the light and check that a front and its back cover each other before printing a stack. Set the scale to 100% (“actual size”), never “fit to page”, or the cut marks no longer match the cell edges.