§0 A free extension for VS Code
See your math while you write it.
Math Inline renders $…$ and $$…$$ formulas right inside the Markdown editor, not only in the preview. Put the cursor in a formula to edit its TeX. Move away and it renders again.
ext install polecoder.math-inline
Paste into Quick Open (Ctrl+P) in VS Code. Needs VS Code 1.90+.
- Type TeX
- Leave it: rendered
- Click in: edit
§1 Before / after
Same file. Now you can read it.
Drag the handle. On the right is your Markdown as VS Code shows it by default. On the left is the same file with Math Inline on. The text on disk is identical.
§2 Features
Built for people who think in TeX.
Each card has a small live demo. Hover it, or tab to it with the keyboard.
-
Euler: $e^{i\pi} + 1 = 0$Edit in place
Move the cursor into a formula and its TeX comes back, with a live preview after the closing $. If the TeX is half-typed, the preview keeps the last version that rendered.
-
Half: $\frac{1}{2$Errors, underlined
Invalid TeX gets a squiggly underline, even while you're typing it. Hover it to read the error. Hover a formula's source to see it rendered larger.
-
$R = \begin{pmatrix}…\end{pmatrix}$“∑ show formula”
Formulas too tall for a line, like matrices or stacked fractions, fold into a chip. Hover the chip to see the full display-mode render.
-
$$ \begin{aligned} … \end{aligned} $$Tables, row by row
Multi-line
$$blocks withaligned,cases,arrayor matrices are drawn one row per line, with the columns lined up. Edit one row and the rest stay rendered. -
Lunch $5, coffee $10, and $x^2$.Smart about dollars
It uses Pandoc's rules, so
$5 and $10stays text. Escaped\$, code, front matter, HTML and link URLs are left alone. -
\bboxrenders here, but VS Code's Markdown preview (KaTeX) can't render it. notes.md [Ln 12, Col 4]KaTeX compatibility warnings
Math Inline renders with MathJax, but VS Code's built-in preview uses KaTeX. When a formula uses something KaTeX can't render, like
\bbox, a warning in the Problems panel points to the command. Turn it off withmathInline.katexWarnings.
§3 Playground
Works the way you write.
Type Markdown with $…$ and $$…$$ and see each line rendered in place. It uses the same dollar rules as the extension. This page uses KaTeX; the extension uses MathJax.
Each line is rendered on its own. Invalid TeX is underlined.
In the editor, with Math Inline
§4 Settings
Four settings. One shortcut.
The defaults work for most people. If you want to change them, these go in your settings.json.
{
// Render $…$ and $$…$$ math in Markdown editors.
"mathInline.enabled": true,
// Formula size relative to the editor font (0.25–4).
"mathInline.scale": 1,
// CSS color, e.g. "#ffcc00". Empty = based on the theme.
"mathInline.color": "",
// Warn about formulas the KaTeX preview can't render.
"mathInline.katexWarnings": true
}
Toggle every formula
Press Ctrl+Alt+M (Cmd+Alt+M on macOS) in a Markdown editor to show the TeX source of every formula. Press it again to render them.
The command is Math Inline: Toggle Inline Math Rendering. To change the shortcut, search for mathInline.toggle in Keyboard Shortcuts.
§5 Known limitations, honestly
- VS Code can't change line heights. Tall formulas are scaled down to fit the line or folded into a “∑ show formula” chip. Use
mathInline.scaleto change the overall size. - Multi-line $$ blocks are drawn inside the lines they already use. Tall rows can overlap neighbouring empty lines, and the $$, \begin and \end lines stay blank.
- Only formulas near the visible area are rendered. During a very fast scroll you may see TeX for a moment.
- With word wrap on, VS Code wraps lines by the length of the hidden TeX, so lines with many formulas can wrap early.
§6 FAQ
Questions
Is it free?
Yes. Math Inline is free and open source under the MIT license. There's no account, no telemetry and no paid tier.
Does it work in Cursor or VSCodium?
Math Inline is published on the Visual Studio Marketplace and needs VS Code 1.90 or newer. Editors based on VS Code don't always use the same extension registry. If you can't find it in yours, open an issue on GitHub.
Does it change my files?
No. It only changes what you see in the editor. Your .md files stay plain Markdown and TeX, and Git sees no changes.
Does it replace the Markdown preview?
No, the preview keeps working. Math Inline renders inside the editor with MathJax. It can also warn you when a formula won't render in the KaTeX-based preview.
I wrote a price and it became math. Or the other way round.
The extension follows Pandoc's rules. The opening $ can't be followed by a space. The closing $ can't come after a space or be followed by a digit. Write \$ for a literal dollar sign.