Back to Notesnook

Math & formulas

docs/help/contents/rich-text-editor/math-and-formulas.md

3.4.10-android4.0 KB
Original Source

Math & formulas

Notesnook renders LaTeX math with KaTeX, so you can write \frac{a}{b} in a note and see a real fraction. There are two kinds: inline math, which sits inside a line of text, and a math block, which is centered on its own line in display mode.

Insert inline math

Inline math flows with the sentence around it, the way $E = mc^2$ would in a paper.

  1. Put the cursor where the formula should go.
  2. Click the {{more}} button in the first toolbar group (the one holding {{bold}}, {{italic}} and {{underline}}) and choose {{mathInline}}.
  3. Type the LaTeX into the editor that opens under the formula.
  4. Click anywhere outside it to render.

There is no keyboard shortcut for inline math. With Markdown shortcuts on, typing $$2 + 2 = 4$$ converts to inline math as soon as you close the second pair of dollar signs.

The {{mathInline}} button is disabled while the cursor is inside a code block.

Insert a math block

A math block is rendered in display mode — centered, on its own line, with full-size operators.

  1. Place the cursor on an empty line.
  2. Click the + (Insert) button in the toolbar.
  3. Choose {{mathAndFormulas}}.
  4. Type the LaTeX and click outside the block.

Ctrl+Shift+M (⌘+Shift+M on macOS) inserts a math block from anywhere in the note.

With Markdown shortcuts on, typing $$$ followed by a space also creates a math block.

::: info Markdown shortcuts need Essential The $$…$$ and $$$ shortcuts are Markdown shortcuts, part of the Essential plan and above, and they are off by default on web and desktop — switch on {{mardownShortcuts}} in {{settings}}{{customization}}{{editor}}. They are on by default on mobile. The toolbar buttons and Ctrl+Shift+M work on every plan.

:::

Edit a formula you already wrote

Click (or tap) a rendered formula. It expands to show its LaTeX source in a small editor in place, with the rendered result above it. Change the source, then click outside the formula — or move the cursor away — and it re-renders immediately.

An empty formula renders as an empty placeholder rather than disappearing, so you can always find it again.

Write chemistry equations

The mhchem extension is loaded alongside KaTeX, so \ce{...} notation works out of the box:

\ce{2H2 + O2 -> 2H2O}
\ce{SO4^2- + Ba^2+ -> BaSO4 v}

What happens when the LaTeX is invalid

Notesnook never throws away your input over a typo. KaTeX renders unrecognized commands in red inside the formula and leaves everything it could parse rendered normally, so a stray \frac{1} shows you exactly where the problem is. The raw LaTeX you typed is untouched — click the formula and fix it.