copy-latex-firefox-extension

CopyLaTeX

A Firefox 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

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

Host premissions 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-extension-permissions

This is done in “Firefox Settings > Extensions & Themes” (or simply search about:addons), clicking the extension and choosing the tab “Premissions and Data”.

In case you turn off the “all sites” toggle option, you can also add manual sites that are not in the default list.

Manage-extension-permissions

And now the custom site should appear as a new toggle in the “Permissions and data” tab.

Related

There is also a Chrome version of this extension: https://github.com/Mapaor/copy-latex-chrome-extension