Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>PyMath PreviewNew to Visual Studio Code? Get it now.
PyMath Preview

PyMath Preview

sankarebarri

|
3 installs
| (0) | Free
Preview LaTeX math in Python docstrings and comments.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PyMath Preview

PyMath Preview demo

PyMath Preview is a lightweight VS Code extension for rendering LaTeX math written inside Python docstrings and comment blocks.

What It Does

  • Renders inline math: $...$
  • Renders display math: $$...$$
  • Designed for Python files:
    • triple-quoted docstrings ("""...""" or '''...''')
    • contiguous # comment blocks
  • Works from explicit selection, or inferred Python blocks when selection is empty

How To Use

def energy():
    """
    Einstein's mass–energy equivalence:

    $$
    E = mc^2
    $$
    """
  1. Open a Python file.
  2. Select math text, or place the cursor inside a docstring/comment block.
  3. Run PyMath Preview: Show Preview from Command Palette.

Default keybinding: Ctrl+Alt+M (Cmd+Alt+M on macOS).

Additional commands:

  • PyMath Preview: Copy LaTeX

Syntax Support

  • Inline math: $E = mc^2$

  • Display math:

    $$
    \frac{a+b}{c}
    $$
    

Break Marker (Display Math Only)

If enabled, <|> inside display blocks is converted to \\allowbreak before rendering.

  • Applies only inside $$...$$
  • Remains literal in inline math and plain text

Settings

  • pymathPreview.breakMarker (default: <|>) Display-only soft-break marker text.
  • pymathPreview.autoSoftBreaks (default: false) Adds conservative \\allowbreak points in display math.
  • pymathPreview.autoFitDisplayMath (default: false) Scales overflowing display equations to fit preview panel (within safe limits).
  • pymathPreview.mathFontScale (default: 1.0) Global math scale fallback.

Troubleshooting

  • If a formula fails, check balanced $$ delimiters.
  • For multi-line derivations, prefer aligned blocks with explicit \\ line breaks.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft