How to Enter Special Characters Such as &, %, $, _ in LaTeX
Explain how to write the four special characters &, %, $, and _ in LaTeX in body text, in formulas, and in tables. Describe how to escape them, and give a method for checking the compiled output to find missing characters and errors.
Key Points of This Article
- In body text, to display &, %, $, or _, prefix it with a backslash to write \&, \%, \$, or \_. This is called escaping.
- Inside formulas, _ and ^ denote subscripts and superscripts and do not need escaping. $ is the switch for math mode.- An unescaped % in a line turns everything after it on the same line into a comment. After compiling, the text seems to have vanished.- In tables and alignment environments, & separates columns. To display a literal &, write it as \&.- After compiling, first check the log for the "Missing $" and "Misplaced alignment tab" errors, then check each location against the source file.
If you are writing a LaTeX paper, report, or assignment and get a compilation error after typing & or %, or a passage in the PDF mysteriously disappears, the cause is most likely that these symbols have special meanings in LaTeX. Many people search for "how to use & in LaTeX" or "how to write % in LaTeX," but what they actually want to solve is not how to write mathematical symbols, but "I want this character to appear in the body text; how should I write it?"
This article explains escaping: telling LaTeX that the symbols here are just ordinary characters, not commands. After reading it, you will be able to judge which symbols need escaping, how they should be written after escaping, and what to watch out for in formulas and tables. The rules in this article are the general LaTeX conventions and do not depend on any specific software.
How do I type &, %, $, _ in LaTeX? One-sentence answer
To display these four symbols in the body text, just put a backslash in front of each one, writing them as \&, \%, \$, and \_. Subscripts inside formulas and column separators in tables follow their own rules; the table below gives the approach for your case.
| Your situation | Recommended Practices | Cause |
|---|---|---|
| The text to display in the body is & or % | Write \& or \% | Bare & is used for splitting table columns; bare % indicates a comment. |
| Need to display the dollar sign $ in the body text | Write \$ | A lone $ character opens math mode. |
| The text is Chinese: "The body text needs to display an underscore _" means "The body text needs to display an underscore _". : "I need the underscore _ to display in the body text" Translation: I need the underscore _ to display in the body text. | Write \_ | In text mode, a bare _ causes an error; it can only be used as a subscript inside a formula. |
| Write subscripts or superscripts in formulas | Write $a_i$ and $x^2$ directly, without adding backslashes. | In math mode, _ and ^ are typesetting commands. |
| Splitting columns in a table or align environment | Use a bare & as the column separator; write a literal & as \&. | "&" in these environments is the alignment symbol. |
Before You Begin: Confirm These Points First
Before making any changes, first determine the following few things, so you avoid editing the wrong place.
- Confirm the mode you are in. The same symbol means different things in body text (text mode) and in formulas (math mode, such as $...$, \[...\], or equation environments). Writing \$ in a formula produces a dollar sign, while writing $ ends the formula, so the two cannot be mixed.
- Confirm the environment you are in. In environments such as tabular and align, & is a column or alignment character. Deleting it directly will misalign the table. To display a literal &, you must write \&.
- Determine whether you want to display a character or express a mathematical structure. Subscripts, superscripts, and summation symbols are mathematical structures and should not be escaped. Escaping is only needed when you want the character to appear on the page.
- Watch for % at the end of a line. % comments out all remaining content on the same line, including the line break. This is a common cause of missing text, so pay special attention to it when writing.
- If you convert between Word and LaTeX in the UniDoc web editor (app.unidoc.top), the conversion results still follow the rules of the LaTeX source. Special characters must be kept in the source as described in this document.
Steps to Escape Special Characters in LaTeX Source Files
Process in the order below; usually one pass is enough to get it fixed.
- Search for the symbols that need checking. In the .tex source files, search for the four symbols &, %, $, and _. For each occurrence, mark whether it appears in body text, in a formula, or in a table.2. Handle & and % in body text. Change "Smith & Lee" to "Smith \& Lee". Write the percent sign in sentences such as "the proportion is a certain percentage" as \%, for example "the proportion is about x\%".3. Handle $ and _ in body text. Write the dollar sign before a monetary amount as \$, and place it directly before the amount, so that \$ is followed immediately by the amount content rather than leaving a standalone $. Write underscores in file names as \_, for example my\_data.csv.
- Keep the notation inside formulas. The _ in $x_i$ is a subscript, and the _ in $\sum_{i=1}^n$ is also structural; do not change them. Write percent signs in formulas as \%.
- Check the column separators in tables. Keep bare & between table columns, and end each row with \\ to start a new line. If a cell needs to display a literal &, write it as \&.
- Delete stray %. If a % at the end of a line is not an intended comment, delete it so that the following text is not swallowed.
- Handle backslashes shown in text separately. To display a backslash in body text, use \textbackslash, not \, because \ introduces a command or a line break.
- Recompile and check the log. After making changes, recompile, then go to the next section and verify each item.
Verify each item when finished
Compiling successfully does not mean the content is correct; it is recommended to check each item against the table below.
| Inspection item | How do you see it? | What should I do if I have a problem? |
|---|---|---|
| Is the body text character set complete? | Find the paragraphs containing &, %, $, and _, and compare them against the source file to check whether the second half of a sentence is missing. | This is probably a bare % that comments out the rest of the line, so delete it or escape it. |
| Compilation log error | Check the "Missing $ inserted" and "Misplaced alignment tab character &" messages, etc. | Missing $ usually means a bare _ or ^ in body text, or an unclosed formula; Misplaced & means & appears outside a table, so change it to \& |
| Official display | Are the subscripts, superscripts, and percent signs correct? | In formulas, write the percent sign as \%, keep the subscript _, and do not add extra backslashes. |
| Table alignment | Do the number of columns match in each row, and are the columns misaligned? | Check whether a literal & has been mistakenly treated as a column separator; a literal & should be written as \& |
| File name and URL | Are the underscores preserved, and is the URL truncated? | The underscore in file names should be written as \_; URLs can use the \url command from the url package. |
If you have processed a LaTeX source package with a translation tool and the compiled output fails after translation, first check whether the escape symbols were altered during translation, then return to the source file and correct them one by one. Technical terms and symbols in the translation also need to be verified manually before use.
❓ Frequently Asked Questions (FAQ)
1. What does $ mean in LaTeX?
The $ sign is the math-mode delimiter: the content between a pair of $...$ is typeset as a formula. If you only need to display a dollar sign, write it as \$.
2. Why did the text after % on the same line disappear after I wrote it?
Because % is the comment character in LaTeX, everything after it is ignored during compilation. To display a percent sign, write \%; when a comment is not needed, delete the extra %.
3. How do I type _ in LaTeX, and do I also need to escape it in file names?
In the body text or file names, underscores must be written as \_; otherwise compilation will raise an error. In formulas, _ denotes a subscript and can be written directly, with no escaping needed.
4. Can I directly input full-width & or % instead of escaping?
Fullwidth characters by themselves do not trigger any special meaning in LaTeX, but whether they display correctly depends on the font and the compilation environment. To ensure stable display across different environments, it is still recommended to use escaped forms such as \& and \% instead.
📝 Summary
Remember three rules: to display &, %, $, or _ in body text, put a backslash in front of it; the _ and ^ in formulas are structural and should not be escaped; in tables, & is used to separate columns, and a literal & is written as \&. Check each spot step by step following this article, and rely on the compilation log, and you can quickly fix special-character problems.
Open OmniDoc to edit, convert, or translate your LaTeX documents


