How to convert formula recognition results into LaTeX code

Explain how to organize the results of formula recognition into usable LaTeX source code and put it into a LaTeX document or Word document. Including pre-operation judgment, conversion steps, verification methods, and handling of common errors.

Key points of this article

  • The result of formula recognition may not be legal LaTeX. Check it with compilation or rendering first, and then decide whether to use it directly.
  • Superscripts and subscripts, brackets, matrices and Greek letters are prone to errors and should be checked one by one against the original image.
  • The formulas in LaTeX papers should be placed in the mathematical environment, using $...$ within the line, and in the equation environment for independent lines.
  • Before putting it into Word, confirm the rendering effect in an editor that can preview it to avoid complex formulas being deformed after importing.

Many people encounter a formula in a paper, handout or test paper. There are only pictures or scanned copies and no editable source code. After recognizing it as text, a common next step is to get the LaTeX code so you can put it into your own .tex file. The problem is that the recognition results are often mixed with extra spaces, missing parentheses, or some intermediate format, and an error will be reported when pasted directly into LaTeX.

This article is written for readers who need to migrate formulas from pictures, scanned PDFs, or other people's documents to LaTeX or Word. After reading, you will know how to judge whether the recognition result is usable, how to organize it into standard LaTeX writing, and complete the verification before putting it into the document.

Formula recognition itself cannot ensure that every symbol is correct, so the focus of conversion is "checking" and "placing in the right position", rather than directly finalizing the code after one recognition.

How to use the formula recognition results? One sentence conclusion

First use compilation or rendering to confirm that the source code is available, and then decide to put it into LaTeX or Word. LaTeX papers give priority to retaining source code form, and Word documents can be imported using UniDoc's formula editing and LaTeX round-trip functions.

your situationRecommended practicesreason
To be included in a LaTeX paper or handoutDirectly use the recognized LaTeX, put it into the mathematical environment and compile and checkThe source code can be directly inspected by the compiler and can be easily modified.
To put into a Word documentFirst edit the formula in UniDoc, confirm the rendering and then export it to WordAvoid errors when manually rearranging complex formulas in Word
Only formulas in scanned PDFFirst OCR recognize the entire page, and then extract the formula part from the resultFull-page recognition preserves the context of formulas
The formula is very long or contains matrices or piecewise functionsSegmented inspection, each segment is rendered separatelyErrors are usually concentrated in one place, and segmentation makes them easier to locate.
Need to collaborate with others to modifyKeep the LaTeX source code and attach the original imageThe other party can check it against the original picture without guessing the writing method.

Before you start: Confirm these points first

Judging a few things before taking action can save you a lot of detours.

Is the formula a picture or editable text? If the formula in the PDF can select and copy characters, it means it is a text layer and can be taken out directly; if it is just an image after selection, it needs to be identified. The way to judge is to try to select a symbol of the formula and see if it can be highlighted.

Do you need the source code or the typesetting result? Writing a LaTeX paper requires source code. If you just want to see the formula in Word, you don’t have to worry about the complete writing method of LaTeX. Just import the rendered formula.

Is the original picture clear? Blurred, skewed or low-resolution images will cause a large number of substitution errors in the recognition results, such as recognizing "1" as "l" and "α" as "a". Try to use clear screenshots or original files before identification.

What environment do you use for your target document? Inline formulas and independent formulas are written differently in LaTeX. Formula objects in Word also have their own formats, which need to be decided in advance.

Do you need to check the content? Machine recognition will make errors, especially at subscripts, superscripts, and bracket nesting. Formulas involving examinations, papers or official publications must be compared item by item with the original drawings, and do not directly trust the identification results.

Steps to convert the recognized formula into LaTeX code

The following is a general process that applies to most identification results.

  1. Open the original file in the desktop client or web version of OmniDoc, find the page where the formula to be converted is located, and confirm whether it is selectable text.
  2. Perform OCR recognition on the scanned document or picture formula, obtain the text result, and find the formula part in the result.
  3. Copy the formula content to the formula editing area of the UniDoc web editor (app.unidoc.top) and observe whether the rendering result is consistent with the original image.
  4. Check the superscripts, subscripts, fractions, brackets and Greek letters against the original image. If any inconsistencies are found, correct them in the editor first.
  5. After confirming that the rendering is correct, copy the corresponding LaTeX source code and put it into the .tex file. Inline formulas are wrapped with $...$, and independent row formulas are wrapped with equation environment.
  6. Compile the LaTeX file and check the error report. Common problems include mismatched parentheses, misspelled command names, and Chinese characters appearing in math mode.
  7. If you need to put it into Word, you can first complete the formula editing in UniDoc, then export it through the Word round-trip function, and finally open it in Word to check the typesetting.
  8. Compare the converted formula and the original diagram side by side to confirm that there are no missing symbols and numbers.

Check each item after completion

After the conversion is complete, don't just see if it compiles, but also check whether it is consistent with the original formula.

Check itemsHow to seeWhat to do if there is a problem
Whether the rendering result is consistent with the original imageCompare symbols, positions, and levels side by sideGo back to the editor and modify it until the rendering is consistent with the original image
Whether the superscript and subscript belong correctlyCheck whether the curly braces after ^ and _ enclose the complete content.Specify the scope with curly braces, such as x^{2n} instead of x^2n
Whether the parentheses are matchedCount the number of left and right parentheses to check whether \left and \right are paired.Complete the missing parentheses, or use a parenthesis command that highly matches the content
Greek alphabet and special symbolsConfirm whether it is the correct command such as \alpha, \in, etc., against the original drawing.Fix the command name and check the display effect after compilation
Numbering and citationCheck whether the formula number is continuous and whether the reference points to the correct formula.Re-establish the reference using \label and \eqref
Typesetting in WordOpen it in Word to see if the formula is deformed or line wrapping errorGo back to UniDoc and re-export after adjustment

# which method is suitable for you?

If you are writing a LaTeX paper, the safe way is to keep the source code and use the compilation results to determine whether the formula is correct. The source code can be modified repeatedly and is easy for others to review.

If you only need to show the formula in the Word document, you don't have to pursue the complete LaTeX writing, import the rendered formula, but be careful to check the line wrapping and alignment of the complex formula after import.

If you only have scanned copies and have more formulas, it is recommended to identify them on the whole page first, and then check them one by one according to the chapters. Do not directly submit the manuscript after dealing with the full text at once.

# frequently asked questions (FAQ)

1. Can Word directly identify the image formula as LaTeX?

Word itself is not a specialized formula recognition tool. Usually, you need to use the recognition tool to get the content of the formula, then organize it into LaTeX or Word formula objects in the editor, and finally check the rendering results.

2. Why did the identified LaTeX code compile to report an error?

Common reasons are mismatched parentheses, misspelled commands, or the use of characters that should not be present outside the mathematical model. Check the error position line by line, and you can usually locate it quickly.

3. What if the symbol in the recognition result is different from the original picture?

First go back to the original image to confirm the real symbol, and then modify the source code. Machine recognition is easy to be confused between similar characters, such as the letter "l" and the number "1", the letter "O" and the number "0", which need to be judged manually.

4. The formula is very long. Can it be converted by stages?

Sure. Divide the long formula into several segments according to the equal sign or plus sign, render and check respectively, confirm and then merge. This makes it easier to locate errors and to align with the aligned environment in LaTeX.

5. Can the transformed formula be applied to formal papers?

It can be used as a starting point, but it must be checked item by item with the original data before formal submission, and the content must be confirmed by the author himself. Content involving machine translation or recognition needs to be manually checked before use.

# Summary

When the formula recognition result is converted into LaTeX code, the key is to check whether the source code is rendered correctly, and then put it into the appropriate LaTeX environment or Word document. Edit and check with UniDoc, which allows you to find most of the problems before importing. No matter what tool is used, it should be compared with the original picture item by item to ensure that the content of the formula is accurate.

Open OmniDoc to edit, convert or translate your LaTeX document

Updated 2026-11-12