Skip to content

Mapaor/copy-latex-chrome-extension

Repository files navigation

CopyLaTeX

A Chrome extension that lets you quickly copy LaTeX code (KaTeX or MathJax) from equations displayed on websites like ChatGPT, DeepSeek, or any blog using mathematical equations. It works simply by hovering over an equation and clicking to copy the LaTeX expression.

Version 1.1: Now it also works with with Wikipedia and Wikiwand images.

How it works technically

  1. Content Script (content.js):

    • Automatically detects all <span class="katex"> elements on the page.
    • Extracts the LaTeX code from <annotation encoding="application/x-tex">.
    • Shows an overlay when hovering over the equation.
    • Allows clicking to copy the code to clipboard using navigator.clipboard.writeText().
    • Uses an inline <svg> to avoid external file dependencies.
  2. CSS (overlay.css):

    • Overlay styling: white background, subtle border and shadow.
    • Large, readable text.
    • Centered over the KaTeX formula.
    • pointer cursor.
  3. Extension declaration manifest.json:

    • Injects content.js and overlay.css.

Example GIFs

KaTeX

Demo-KaTeX

MathJax

Demo-MathJax

Wikipedia images

Demo-MathJax

Popular Sites Using MathJax/KaTeX

Generally any math, physics, or engineering-related blog or website. Some typical examples:

  • KaTeX: ChatGPT, DeepSeek, Notion...
  • MathJax: Math Stack Exchange, ProofWiki...

Host permissions and speed

The javascript source code is extremely simple and available here. It loads after everything and is blazingly fast.

However you can always customize in which hosts (websites) the extension loads or not:

Manage-allowed-hosts

Adding-an-allowed-host

This is done in chrome://extensions in the extension 'Details'.

Recommended websites to add

Links

Related

There is also a Firefox version: https://github.com/Mapaor/copy-latex-firefox-extension

You can also use this extension in Brave and Arc (they support Chrome extensions by default).

I also plan to adapt this code for Edge and Opera and publish in their respective places.

A Safari version is not planned because publishing in Safari is ridiculously expensive.