How to Convert an Image to LaTeX Code in Any Editor

A formula that lives in a screenshot is useless for writing. You can retype it, but retype a 3 by 3 matrix with nested fractions and you will…

A formula that lives in a screenshot is useless for writing. You can retype it, but retype a 3 by 3 matrix with nested fractions and you will introduce an error somewhere. Converting the image to LaTeX source instead takes seconds, and the result is text you can paste into Overleaf, a Markdown note, or a code comment.

What you are actually asking the model to do

Optical character recognition reads glyphs. A formula is not a sequence of glyphs — it is a tree: a numerator over a denominator, a radical whose body extends over an expression, a summation with limits above and below. That is why general-purpose OCR (the kind built into your phone's camera app) mangles maths: it returns the characters in reading order and loses the structure.

A maths-aware recogniser rebuilds the structure first, then renders it in LaTeX, because LaTeX is the notation that encodes that structure unambiguously.

The shortest reliable path

  1. Crop the image so the equation fills most of the frame — whitespace and page margins are noise to the model.
  2. Upload it and take the LaTeX field from the result.
  3. Paste it into your editor and compile once. A quick render is the cheapest check there is: a wrong fraction bar or missing brace shows up immediately.
  4. If it is wrong, re-shoot with a tighter crop rather than trying to fix by hand. A second clean image beats ten minutes of guessing.

Wrapping it for your editor

Inline maths uses \( ... \) or a single $; display maths uses \[ ... \], $$ ... $$, or an equation environment when you need a number. Most note apps want the fenced form, most journals want the environment form.

\begin{equation}\n  \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\n  \label{eq:quadratic}\n\end{equation}

The recogniser gives you the inner expression. Wrapping it is a one-line edit you make once per document class, not once per formula.

latexocrimage to latex

Keep reading

Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.