Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Comment FormulaNew to Visual Studio Code? Get it now.
Comment Formula

Comment Formula

Casper Huang

|
1,407 installs
| (2) | Free
Preview LaTeX formulas within the line of your editor.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

logo

Comment Formula

Visual Studio Marketplace Version Visual Studio Marketplace Downloads Visual Studio Marketplace Installs
GitHub last commit GitHub issues GitHub stars

Introduction

A VSCode extensions to preview LaTeX formulas within the lines of your editor.

Render Engine: MathJax

Feature

feature

Usage

You are supposed to write formulas between $$ and $$.

HIGHLIGHT: Install MathJax Highlight to highlight LaTeX code in comments. Reload the Window to make the highlight work when update comment-formula.languages or comment-formula.capture.

Configurations

comment-formula.defines

{
  "comment-formula.defines": {
    "matlab": [
      "*.m",
    ],
    "quarto": [
      "*.qmd"
    ],
    "foo": [
      "*.bar"
    ]
  }
}

comment-formula.capture

  1. Set 'marker' or set 'prefix' and 'suffix' simultaneously. When prefix and suffix are the same, you can use marker instead.
  2. strict is a boolean value to determine the last character of captured content isn't the escape character \. (default to true)
  3. breakable is boolean value to control whether the captured content can be split across multiple lines. (default to true)
  4. If a language haven't set capture patterns, we will use the pattern of default.
{
  "comment-formula.capture": {
    "default": [
      {
        "marker": "$$",
        "breakable": true,
      },
      {
        "marker": "$",
        "breakable": false,
      }
    ],
    "cpp": [
      {
        "marker": "\\f$",
        "breakable": false,
      },
      {
        "prefix": "\\f[",
        "suffix": "\\f]",
        "breakable": true,
      }
    ],
    "foo": []
  }
}
Key Description Type Default
comment-formula.color Color of rendered formulas. string "auto"
comment-formula.inline When will the inline formula preview be displayed. string "all"
comment-formula.languages Enable extension in these languages id. array ["c","cpp","java","python"]
comment-formula.interval Formula update interval(ms). number 200
comment-formula.code Style of matched LaTeX code. string "font-weight: bold;"
comment-formula.preview Style of the inline formula preview. string ""
comment-formula.annotation Enable render formula for preview or not. boolean true
comment-formula.completion Enable intelligent completion. boolean true
comment-formula.multiple Set preview position of multiple line LaTeX or disable it. string "after"
comment-formula.single Set preview position of single line LaTeX or disable it. string "after"
comment-formula.hidden Enable hiding code when selections are out of range. string "scope"
comment-formula.autotab Enable auto tabbing rendered formulas. boolean true
comment-formula.scale Scale factor of the preview formula. number 1
comment-formula.defines Define Language with glob file patterns, where key is language id, value is a list of glob pattern. object {}
comment-formula.capture Set RegExp for capturing math for rendering in comments. object {}
comment-formula.message.playground Display link of mathjax-playground in hover message. boolean true
comment-formula.message.preview Display rendered formula in hover message. string "partial"
comment-formula.api.prefix API prefix (Experimental). string ""
comment-formula.api.suffix API suffix (Experimental). string ""
comment-formula.preload Paths to files containing LaTeX preamble to preload. array []

Feel free to open an issue if you encounter any problem or have any suggestion.

Reference

VSCode Iconify | MathJax | KaTeX | VSCode Markdown | LaTeX Workshop | VSCode Markdown Math

License

Code is under the MIT License.

Logo using carbon:function as an element is under the Apache License 2.0.

Fonts used in feature image are Dancing Script (for Before and After) under the Open Font License and Input (for code) under the Input Font License.

Support

If you find this project useful, please consider giving it a star on GitHub. Your support is greatly appreciated! GitHub stars

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