Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Markdown Copy TeXNew to Visual Studio Code? Get it now.
Markdown Copy TeX

Markdown Copy TeX

fruiti

| (0) | Free
Copies LaTeX source ($...$, $$...$$) instead of garbled rendered math when copying from VS Code's Markdown preview
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Markdown Copy TeX

Copy LaTeX source from VS Code's Markdown preview — no more garbled math!

When you copy text containing math equations from VS Code's built-in Markdown preview, the result is usually garbled — each symbol ends up on its own line due to KaTeX's internal HTML rendering. This extension fixes that by intercepting the copy event and replacing rendered math with the original LaTeX source.

Before vs After

Without this extension (default VS Code behavior):

The probability density function satisfies
∫
−
∞
∞
f
(
x
)
d
x
=
1

With this extension:

The probability density function satisfies $\int_{-\infty}^{\infty} f(x)dx = 1$

Features

  • Inline math is copied as $...$
  • Block/display math is copied as $$...$$
  • Regular text is copied normally (the extension only activates when math is present in the selection)
  • Zero configuration — just install and it works
  • No dependencies

How It Works

VS Code renders math in Markdown preview using KaTeX, which stores the original LaTeX source in a hidden <annotation> element inside the MathML output. This extension:

  1. Intercepts the copy event in the Markdown preview
  2. Detects KaTeX-rendered math elements in the selection
  3. Extracts the LaTeX source from MathML annotations
  4. Reconstructs clean text with proper $...$ / $$...$$ delimiters
  5. Writes it to the clipboard

Why This Extension?

  • VS Code's GitHub issue #153258 reports this problem, but it was closed as "not planned"
  • KaTeX has an official copy-tex contrib that does exactly this for web pages, but VS Code does not include it in its built-in Markdown preview
  • No existing Marketplace extension solves this specific problem

Requirements

  • VS Code 1.70.0 or later
  • The built-in Markdown math rendering must be enabled ("markdown.math.enabled": true, which is the default)

License

MIT


Markdown Copy TeX (日本語)

VS Code の Markdown プレビューから数式を正しくコピーできるようにする拡張機能です。

VS Code の Markdown プレビューから数式を含むテキストをコピーすると、KaTeX の内部 HTML 構造のせいで文字化け(1文字ずつ改行される)してしまいます。この拡張機能は、コピーイベントを検知して、レンダリングされた数式を元の LaTeX ソースに置き換えます。

機能

  • インライン数式は $...$ としてコピー
  • ブロック数式は $$...$$ としてコピー
  • 数式を含まないテキストは通常通りコピー(数式がある場合のみ動作)
  • 設定不要 — インストールするだけで動作
  • 依存関係なし
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft