LaTeX formulas display abnormally in Word or web pages, what should I check first?

When formulas turn into source code, blocks, or garbled characters in Markdown, Word, or web pages, there is usually a problem with the delimiters, escape characters, rendering environment, or fonts. This article gives a checklist of what to check first and what to check later, and explains why each step is done.

Key points of this article

  • When the formula is displayed as source code, it is usually because the rendering environment does not recognize the delimiter, not because the formula itself is written incorrectly.
  • Markdown will eat backslashes and underscores in formulas, causing formulas to be distorted when saving or converting.
  • Word does not recognize naked LaTeX text, so it needs to be converted into Word formula objects first, and then the display effect can be discussed.
  • The common reason for web page formula blocks or garbled characters is that the rendering script is not loaded or the command is not supported.
  • First confirm in the source file that the formula can be compiled or rendered independently, and then check the target environment layer by layer, which is highly efficient.

When you move a written paper or handout from Markdown to Word, or paste it on a web page, the formula suddenly changes into a string of \frac{a}{b}, or a box or question mark appears in the middle. This is a situation that many people have encountered. The formula itself was not written incorrectly, it was just not recognized correctly in another environment.

This article is for people who have written LaTeX formulas but encountered display problems when crossing formats or pages. After reading, you can determine which layer the problem lies in: the way the source text is written, the escaping of Markdown, the import method of Word, or the rendering environment of the web page. Then go through the checklist one by one, and most cases can be solved without rewriting the formula.

What I’m talking about here is a general troubleshooting idea that doesn’t depend on a specific software. We’ll mention where OmniDoc’s UniDoc web editor and desktop client can help at the end of the article, but the judgment method applies to any tool.

The formula displays abnormally. Which layer is the problem? One sentence conclusion

Don't rush to rewrite the formula: most exceptions come from one of the three "delimiters, escapes, and rendering environments". First locate which layer it is, and then fix it. The table below gives recommended practices based on your actual situation.

your situationRecommended practicesreason
The formula is the original code in the source file, you can see $ and backslashesFirst check the delimiter and escape, then change the rendering environment previewThe renderer doesn't treat it as a formula, the problem is in the text layer
The Markdown preview is normal, but it gets messed up after exporting to Word.Convert formulas to formula objects in Word and check each formulaWord does not render LaTeX text directly and requires a conversion step
The formulas on the web page become squares, question marks or missing symbolsCheck if the rendering script is loaded and replace unsupported commandsWeb pages rely on scripts and fonts. If any link is missing, this will happen.
Only some formulas are wrongRender each one individually to find the one with the errorUsually it is a mismatch of individual commands or brackets, so there is no need to rework the entire article.
The entire formula is wrongCheck whether the rendering environment has math support enabledThe global problem is often the environment settings, not the way each formula is written.

First determine what kind of problem it is

After getting a document with errors, first make a preliminary judgment based on the table below, and then proceed to specific troubleshooting.

symptomsCommon causesHow to confirm
The formulas are displayed as they are, with $ and \alpha filling the screen.The delimiter is not recognized, or the rendering environment does not enable math support.Put the same text into an editor that supports formulas to see if it works properly.
_ and * in the formula become italicized or disappear.Markdown parses them as emphasis symbolsCheck whether these characters in the source file are escaped or appear in pairs
The backslash is gone and \\ becomes a \The text was escaped or overwritten when copiedCompare the number of backslashes at the same position in the source file and the exported result
What you see in Word is a string of ordinary charactersJust paste the source code into it, not convert it into a formula objectClick on the formula to see if it is selected as an overall formula object
Boxes, question marks, or missing symbols appearThe font is missing, or a command not supported by the rendering environment is used.Change to a standard symbol test, such as \alpha, to see if there is also a problem
Only formulas between rows are abnormal, but within rows are normal.The formula spans lines, or there is a blank line between delimiters.Check whether there are blank lines before and after the formula and the line break position

Check and repair item by item

It is recommended to check in the following order, easy first and then difficult. There is no need to change the content of the formula in the first few steps, and then touch the formula itself after completing it.

  1. Confirm that the source formula itself can be rendered. Copy the problematic formula separately to an editing environment that supports LaTeX for preview. If an error is reported individually, it means there is a problem with formula writing. Jump to the "Formula Writing" section below; if it is normal alone, the problem is in the transmission process.
  2. Check whether the delimiters are paired. Use a pair of $...$ for inline formulas, and $$...$$ for formulas that stand alone on a line. A common mistake is to miss a $, causing all the subsequent text to be regarded as a formula, or Chinese full-width symbols are mixed into the formula. Use the "Find" function to count the number of dollar signs one by one. It should be an even number.
  3. Check Markdown escaping. In Markdown, _ and * will be treated as emphasis tags. If x_1 + y_1 appears in a formula and is rendered in italics, you need to ensure that the delimiter is complete within the formula, or use the corresponding math block syntax in a supported environment. The same goes for backslashes: if the text goes through a certain conversion step, \\ (line feed commands) may be merged into one, causing matrices or multi-line formulas to be misaligned.
  4. Confirm whether the rendering environment has math support enabled. Many Markdown previewers do not parse formulas by default, and math support needs to be turned on in settings or extensions. This is a common reason for "the entire formula is displayed as source code". If you are using OmniDoc's UniDoc web editor (app.unidoc.top), which supports conversion between formulas, Word and LaTeX, you can first check whether the formulas can be displayed normally there.
  5. Convert to formula object when importing into Word. Word will not display bare LaTeX text as formulas. The correct approach is to first make the formula appear in Word as a formula object: select a path that supports formula conversion when exporting or importing, and then click on the formula one by one to check. If you just paste the source code into the text, it will always be text. After conversion, it is recommended to spot-check three to five complex formulas, especially formulas with fractions, summation upper and lower limits, and matrices.
  6. Confirm in the web page that the rendering script has been loaded. If you build your own web page or blog, you need to introduce a mathematical rendering script into the page and confirm that it has been loaded successfully. Open the browser's developer tools to see if there are any loading errors. When the script is not loaded, formulas usually appear as-is.
  7. Check for special commands and fonts. Some commands belong to specific macro packages, such as \mathbb, \mathcal, etc., which are not supported in some renderers and will be displayed as red errors or boxes. When encountering such symbols, you can change to common writing, or check the support list of the renderer used. Missing fonts will cause special symbols to be displayed as squares. Just change a font or confirm that the system has installed the corresponding font.

Problems with formula writing itself

If you find in step 1 that the formula alone doesn't render, check the directions below.

  • The curly braces are not paired. Each { must have a corresponding }, especially when fractions and superscripts are nested, missing one will cause an error in the entire paragraph.
  • Chinese punctuation mixed in. If the commas and brackets in the formula are full-width, the renderer may not recognize them. Change uniformly to half-width.
  • The position of the newline. It is not appropriate to break lines in the middle of inline formulas. If it is necessary to separate lines, use interline formula writing instead.
  • Don't write long Chinese sentences in the formula. When you need to insert text, use text command wrapping to avoid putting Chinese directly into the math environment.

Tips for segmented inspection

Don't check formula by formula and line by line when the entire document is wrong. Split the document into chapters, and only keep a part of it for rendering in the target environment at a time, so you can quickly find the erroneous paragraphs. If only one section of a 30-page paper contains an unusual formula, this usually only takes a few minutes.

How to avoid it happening again next time

  • Write standard delimiters at the source first. Use $...$ for in-line and $$...$$ for independent formulas. After writing, preview it in the same environment and then export it.
  • Do a "single formula test" before exporting. Extract two or three complex formulas and confirm them individually in the target environment, which saves time than reworking the entire article after exporting.
  • Record the environment you are using. The same Markdown works fine in one renderer, but may fail when switched to another. Note the renderer, export format and settings at the beginning of the document for easy troubleshooting later.
  • Avoid manual overwriting of backslashes. When copying a formula from elsewhere, first check to see if the backslashes are complete and check in a plain text editor if necessary.
  • Long documents are converted in batches. If you need to convert the entire lecture notes from Markdown to Word, it is recommended to convert them in chapters and check them chapter by chapter instead of exporting them all at once.
  • When you need to process formulas in PDF, first confirm the file type. The formulas in the scanned document cannot be directly copied into LaTeX. OCR recognition is required first. The recognition results also need to be checked one by one. Please review the important content manually. OmniDoc's desktop client (download.omnidoc.top) provides OCR functionality and can be used as a starting point for this step.

❓ Frequently Asked Questions (FAQ)

1. Why is my formula a string of LaTeX code in Word?

This is because Word does not automatically render LaTeX text into equations, it just saves it as normal characters. You need to go through the conversion step to make the formula exist in the form of a formula object in Word before it can be displayed according to mathematical layout.

2. The preview of Markdown formula is normal, but it is messed up after exporting. What should I do?

First confirm whether the export path supports formula conversion, and then check the formulas one by one in the exported file. If only a few formulas are wrong, it is probably because the delimiters or individual commands are not supported by the target format. You can modify these formulas individually.

3. The formulas on the web page are displayed as squares. Is it a font problem?

It's possible, but more commonly the render script isn't loading, or it's using a command that the renderer doesn't support. First test with a standard symbol, if it is also displayed as a square, then check the font and script loading.

4. Why do in-line formulas work normally but inter-line formulas report errors?

Inline formulas are more sensitive to line breaks and blank lines. Check whether there are blank lines before and after the formula, whether the delimiter occupies an exclusive line, and whether there are unsupported line breaks inside the formula.

5. Why can’t the formula copied from PDF be used directly?

PDF copies usually contain characters instead of the original LaTeX code, and the structures of superscripts, subscripts, and fractions will be lost. The safe approach is to find the original source file; if you can only use PDF, you need to rewrite it manually and check it with the original text one by one. You cannot completely rely on the results of automatic recognition.

📝 Summary

Abnormal formula display is usually not because the formula is written incorrectly, but because there is a problem with the delimiter, escaping, or rendering environment during the transmission process. By following the order of "confirm the source formula first, then check delimiters and escapes, and finally check the target environment", most problems can be located in a short time. Developing the habit of spot-checking formulas before exporting can keep LaTeX formulas consistent across Markdown, Word, and web pages.

Open OmniDoc and edit, convert or translate your LaTeX document

Updated 2026-11-11