Math preview panel for LaTeX and Markdown in VS Code.
This extension renders the math expression at the cursor in a side preview panel. It supports both LaTeX documents and Markdown files, uses MathJax for rendering, and can optionally show a cursor marker inside the rendered output.
- Preview math from LaTeX and Markdown files in a dedicated panel.
- Follow the active editor and refresh as you edit.
- Use a shared math detector for LaTeX and Markdown files.
- Support
$...$,$$...$$,\(...\),\[...\], and TeX math environments such as\begin{align}...\end{align}. - Support user-configured MathJax packages and macros through extension settings.
- Optionally render a cursor marker inside the preview.
This extension is distributed through GitHub Releases as a .vsix package.
- Open the repository's Releases page.
- Download the latest
latex-math-preview-<version>.vsixasset. - Install it with one of the following methods.
Command line:
code --install-extension latex-math-preview-<version>.vsixVS Code UI:
- Open the Extensions view.
- Select the
...menu in the top-right corner. - Choose
Install from VSIX.... - Select the downloaded
.vsixfile.
Open a LaTeX or Markdown file, place the cursor inside a math expression, and run:
LaTeX Math Preview: Open Math Preview PanelLaTeX Math Preview: Toggle Math Preview PanelLaTeX Math Preview: Close Math Preview Panel
Default keybinding:
Ctrl+Alt+Mon Windows and LinuxCmd+Alt+Mon macOS
LaTeX files use the shared math detector.
Markdown files use the same detector and support:
- Inline math with
$...$ - Display math with
$$...$$ - Inline math with
\(...\) - Display math with
\[...\] - TeX math environments such as
\begin{align}...\end{align}
The extension contributes these settings under the latex-math-preview namespace:
latex-math-preview.mathPreviewPanel.cursor.enabledRender a cursor marker directly in the preview panel.latex-math-preview.mathPreviewPanel.cursor.symbolCursor symbol inserted into rendered TeX.latex-math-preview.mathPreviewPanel.cursor.colorCursor color used in rendered preview content.latex-math-preview.mathPreviewPanel.editorGroupChoose where the preview panel opens:current,left,right,above, orbelow.latex-math-preview.mathPreviewPanel.maxLinesMaximum number of lines to scan upward when resolving surrounding math environments.latex-math-preview.mathPreviewPanel.scaleScale factor for rendered math in the preview panel.latex-math-preview.mathJax.packagesAdditional MathJax TeX packages to enable for rendering.latex-math-preview.mathJax.macrosRaw TeX macro definitions supported by MathJax.
Example VS Code settings.json:
{
"latex-math-preview.mathPreviewPanel.cursor.enabled": true,
"latex-math-preview.mathPreviewPanel.cursor.symbol": "\\!{|}\\!",
"latex-math-preview.mathPreviewPanel.selection.startSymbol": "\\!\\{\\!",
"latex-math-preview.mathPreviewPanel.selection.endSymbol": "\\!\\}\\!",
"latex-math-preview.mathPreviewPanel.cursor.color": "magenta",
"latex-math-preview.mathPreviewPanel.editorGroup": "below",
"latex-math-preview.mathPreviewPanel.maxLines": 20,
"latex-math-preview.mathPreviewPanel.scale": 1.5,
"latex-math-preview.mathJax.packages": ["physics"],
"latex-math-preview.mathJax.macros": "\\newcommand{\\R}{\\mathbb{R}}\\n\\DeclareMathOperator{\\sgn}{sgn}"
}Install dependencies and compile:
npm install
npm run compileRun tests:
npm run test:unit
npm run test:integrationRun the extension in an Extension Development Host from VS Code using the Run Extension launch configuration.
Build the installable .vsix package:
npm install
npm run package:vsixAttach the generated .vsix file to a GitHub Release so users can install it directly.
- The extension host entrypoint is bundled with
esbuildtodist/extension.js. - The MathJax worker is bundled separately to
dist/render/mathjax/mathjax.worker.jsbecauseworkerpoolneeds a real worker script on disk. vscoderemains external; runtime dependencies such asmathjax-fullandworkerpoolare bundled into the emitted files.- Packaging excludes
node_modules, so a symlinkednode_modulesdoes not need to be copied into the VSIX.
MIT