Skip to content

[FEATURE] Add LaTeX / Math formula rendering support to Claude Code for VS Code using KaTeX #21433

Description

@Sirius1994

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

The Claude Code VS Code extension's chat panel (Webview) renders Markdown well (bold, lists, code blocks with highlighting), but does not render LaTeX/Math formulas. Claude frequently outputs formulas using standard delimiters like $...$ (inline) or $$...$$ / \[...\] (display), but they appear as plain text or unparsed code blocks.
This is a significant limitation for users in math-heavy domains (e.g., physics, engineering, data science, ML theory, education), as formulas become hard to read compared to claude.ai web version (which supports LaTeX rendering in preview).

Proposed Solution

Integrate a lightweight KaTeX renderer into the chat Webview:

  • Use KaTeX (preferred over MathJax for performance/size in Webview)
  • Automatically detect and render LaTeX in streamed Markdown responses
  • Support both inline ($...$) and display ($$...$$ or \[...\]) modes
  • Handle common environments (e.g., align, cases, matrix)

Implementation sketch (high-level):

  1. Bundle KaTeX (via CDN or npm in extension build)
  2. In the Webview's HTML/JS (likely in src/webview or similar):
    • After receiving streamed Markdown, use markdown-it + markdown-it-katex plugin (or direct KaTeX render)
    • Or post-process the rendered HTML to find math delimiters and replace with KaTeX output
  3. Respect VS Code Webview CSP: use vscode.Uri for local assets if bundled
  4. Add optional setting: “Claude Code: Enable Math Rendering” (default: true)

This would align the extension experience closer to the web version and greatly improve usability for scientific/STEM users.

Alternative Solutions

No response

Priority

Medium - Would be very helpful

Feature Category

Other

Use Case Example

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions