Margin
A second window for the mathematics in a Claude session. Claude stays where it is, in the terminal or on the web; every display formula it writes appears here, rendered by a real TeX engine, and stays.
Using it with Claude Code
-
One line, Node 20 or newer. It clones the repo, links the margin command, installs the hook and the skill, and opens the desk.
git clone git@github.com:tomburgerch/pr-margin.git ~/margin && cd ~/margin && npm install && npm link && margin install && margin
margin install changes exactly two things: a Stop hook in the Claude Code settings, and a skill symlink at ~/.claude/skills/margin. Both come back out with margin uninstall.
-
Margin runs beside Claude Code, not inside it. Keep the conversation on one screen and the desk on the other; margin wants a terminal of its own and nothing else.
-
Restart any Claude Code session that was already open. Hooks are read when a session starts, so a session you opened before margin install captures nothing. That is the usual reason a new desk stays empty.
-
Then talk about mathematics the way you would anyway. As each turn ends, every display formula in it lands here. You never ask Claude to send anything, and you never type a Margin command unless you want something deliberate.
-
The deliberate things are sentences, not commands. You say them; Claude runs the verb.
- Pin that.
margin pin 42
- Let us try the Hamiltonian route.
margin path "Hamiltonian route"
- The sign in #57 is wrong, fix it.
margin push --replaces 57
- What did we try?
margin list
-
Everything lives in one file, ~/.margin/store.json. If the desk is not running when Claude writes, the turn waits in ~/.margin/spool.jsonl and lands the next time you start it, so beginning with Claude costs nothing.
What you are looking at right now
This page is standalone. There is no server behind it: what you see is kept in this browser and nowhere else, and nothing leaves it. Paste a Claude reply into the field at the bottom of the stream and it pulls the mathematics out.
The real thing is the local one described above. It watches a Claude Code session and captures formulas without being asked.
This desk is connected to the Margin server on your machine, the dot at the end of the top bar. It is watching a live Claude Code session: formulas arrive over an event stream as Claude writes them, and everything is kept in ~/.margin/store.json.
The replay demo runs on the hosted page at latex.cedricwaldburger.com, never here, so nothing of yours is written for the sake of a demonstration.
How it works
- The Stop hook reads the last turn of the transcript and posts it to the local server.
- The server keeps one JSON store in
~/.margin and pushes every change to this page.
- The page renders with MathJax, as SVG, in the page's own ink.
- The skill teaches Claude the handful of
margin commands and when to reach for them.
Without Claude Code
There is no hook on claude.ai, but the page reads any text you hand it. Copy a Claude reply and press Cmd/Ctrl+V anywhere outside a field: every $$ block, \[ \] block and bare align or equation environment becomes a formula, with the line above it as its label. The slim field at the bottom of the stream does the same for text you type.
Keyboard
Margin is keyboard first, and the list is kept in one place: or press ?.