LaTeX Special Characters: Escape All 10 Reserved Symbols
November 11, 2026 · 10 min read
LaTeX Special Characters: How to Escape All Ten Reserved Symbols
LaTeX special characters are the ten symbols the engine keeps for its own syntax: #, $, %, &, _, {, }, ~, ^ and \. Seven of them print literally once you put a backslash in front, as in \# or \%. The other three, tilde, caret and backslash, need extra braces or a named command.
What Are the Special Characters in LaTeX?
LaTeX reads these ten characters as instructions, not text. The LaTeX2e reference manual gives each one a job, and typing one bare tells LaTeX to do that job. Usually that's an error. Sometimes, worse, it's silently missing text.
The table below gives each character's job and the escape that prints it. The math column matters because a few text-mode commands are invalid inside $...$.
| Character | What LaTeX does with it | Text mode | Math mode |
|---|---|---|---|
# | Marks a macro parameter, like #1 | \# | \# |
$ | Opens and closes inline math | \$ or \textdollar | \$ |
% | Starts a comment to the end of the line | \% | \% |
& | Separates columns in tables and alignments | \& | \& |
_ | Starts a subscript (math only) | \_ or \textunderscore | \_ |
{ | Opens a group or an argument | \{ or \textbraceleft | \{ or \lbrace |
} | Closes a group or an argument | \} or \textbraceright | \} or \rbrace |
~ | Inserts a non-breaking space | \~{} or \textasciitilde | \text{\textasciitilde} |
^ | Starts a superscript (math only) | \^{} or \textasciicircum | \text{\textasciicircum} |
\ | Begins every command | \textbackslash | \backslash |
The first seven take a plain backslash in both modes. The last three break that rule, and they're where most "just add a backslash" answers go wrong. In LaTeX, \text needs the amsmath package; KaTeX has it built in.
When a compile fails, the log often points straight at the culprit:
Missing $ insertedusually means a bare_,^or$in ordinary text.Misplaced alignment tab character &means an&outside a table or alignment.- An error naming the macro parameter character means a bare
#. - Missing words with no error at all point to an unescaped
%.
Two near-misses aren't on the list. < and > aren't reserved, but under pdflatex's default OT1 font encoding they print in body text as ¡ and ¿. Load \usepackage[T1]{fontenc} or write \textless and \textgreater to get the real signs. Quote marks are a separate trap, covered in our guide to LaTeX quotation marks.
How Do You Write the # Symbol in LaTeX?
Write \#. The escaped LaTeX # sign works in running text and inside math, so Issue \#42 and $\#S = 3$ both compile. A bare hash fails because TeX reserves it for macro parameters.
Issue #42 is fixed.
pdflatex stops on that line with this message:
! You can't use `macro parameter character #' in horizontal mode.
The two meanings meet when you define your own commands. Inside \newcommand, #1 is the slot for the first argument, while \# is a literal hash:
\newcommand{\issue}[1]{Issue~\##1}
See \issue{42} for details.
The output reads See Issue #42 for details, because \# prints the LaTeX # symbol and #1 drops in the 42. Hashtags work the same way: \#LaTeX prints the tag with no complaints.
Percent Symbol in LaTeX: Why Text Disappears After %
Use \% for the percent symbol in LaTeX. A bare % starts a comment, so LaTeX throws away everything after it on that line, including the line break. There's no error message, which makes it the hardest of the ten to spot.
Save 50% on every plan
this week only.
This compiles cleanly, but the output reads Save 50this week only. The words on every plan vanish, and the next line gets glued on with no space. The fix is one character:
Save 50\% on every plan
this week only.
Authors also use the comment on purpose. A % at the very end of a line stops LaTeX from turning that line break into a space, which is handy inside macro definitions. So you can't simply ban the percentage symbol in LaTeX source. We prefer a quick search for a % with no backslash before it (the regex (^|[^\\])%) before sending a document anywhere. It catches the swallowed-sentence bug that no compiler warning will.
What Do Dollar Signs Do in LaTeX?
A dollar sign opens inline math, and the next one closes it. To print the dollar symbol in LaTeX, write \$ in text or math, or \textdollar in text only. A single unescaped price switches the rest of the paragraph into math.
It costs $5 today.
LaTeX enters math at the $, drops the space and sets 5today as a formula, with the letters in math italic. It then stops with ! Missing $ inserted. at the end of the paragraph. Escaped, both modes behave:
It costs \$5 today, or $\$5.99 \times 3$ for three.
Both prices print correctly, and the second one sits inside a formula.
The same rule carries over to Markdown with KaTeX, with one twist. In our editor, a lone price such as $5 stays plain text. Put real math like $x$ later on the same line, though, and the stray $ can pair up with it and break the formula. Our guide to escaping symbols in Markdown covers prices in Markdown prose. For the $...$ and $$...$$ delimiters themselves, see writing equations in Markdown.
The Ampersand, Underscore and Curly Braces
If you searched for the LaTeX and symbol, you most likely want the ampersand: write \&. A bare & is the column separator in tabular and align, so a company name in a normal paragraph breaks the build.
AT&T and R&D both fail. % ! Misplaced alignment tab character &.
AT\&T and R\&D both print.
The underscore fails in a similar way. Outside math it isn't allowed, and LaTeX reports ! Missing $ inserted. because it assumes you forgot to open math. Write \_ for file and variable names, as in report\_final.pdf. In math, a bare _ makes a subscript, which is a separate topic.
Braces are sneakier. A matched pair in text just forms a group and disappears, so a { b } c prints a b c with no warning. A stray closing brace stops with ! Too many }'s. To print them, use \{ and \} in either mode, or \lbrace and \rbrace in math:
The set $\{1, 2, 3\}$ uses \{ and \} in text too.
How Do You Print a Backslash, Tilde or Caret in LaTeX?
These three are the exceptions in the manual's section on printing special characters. Each needs a command, and the obvious guess does something else entirely.
Backslash. Use \textbackslash in text and \backslash in math. Don't type \\: that's a line break. Also, \textbackslash eats the space after it, so follow it with {} when a word comes next:
C:\textbackslash{}Users\textbackslash{}ana % prints C:\Users\ana
a\\b % prints a, then b on a new line
Tilde. A bare ~ is a tie, a space LaTeX won't break a line at, as in Donald~E. Knuth. Print a tilde with \~{} or \textasciitilde. Drop the braces and \~ becomes an accent on the next letter, so Espa\~na prints España.
Caret. Use \^{} or \textasciicircum. Without braces, \^ is the circumflex accent, so h\^otel prints hôtel.
\~{} \^{} \textasciitilde{} \textasciicircum % prints ~ ^ ~ ^
Inside \texttt, all ten still need these escapes; \verb is the command that prints them raw.
LaTeX Special Characters in Math Mode and KaTeX
KaTeX accepts the seven plain escapes inside math: \#, \$, \%, \&, \_, \{ and \}. Text commands are another story. In our test with KaTeX 0.16, a bare \textbackslash in math failed with an undefined control sequence error. Wrapped in \text, it rendered. The KaTeX supported functions list shows the same wrapped forms.
$\# 42$, $50\% \text{ off}$, $\$5.99$, $R\&D$
$\text{file\_name}$ and $\{1, 2, 3\}$
$a \backslash b$ and $\text{\textasciitilde \textasciicircum}$
Each line renders as plain symbols: #42, 50% off, $5.99, R&D, file_name, a set in braces, a backslash, then a tilde and a caret. Edit the demo below and watch the preview update.
There's a limit here. KaTeX renders math only, so text-mode LaTeX outside the dollar signs isn't processed in a Markdown preview. Markdown even reads the backslash as its own escape, so Espa\~na shows up as Espa~na. For those you need a real TeX engine such as pdflatex. To check a single expression, the LaTeX equation editor renders it with KaTeX as you type.
Quick Ways to Avoid Escaping Every Character
When a string is packed with LaTeX special characters, escaping each one gets tedious. Three shortcuts help.
\verbprints its contents raw:\verb!a_b#c%!. It can't sit inside another command's argument, such as\sectionor\footnote.\urlfrom the url package handles web addresses. In our pdflatex test,\urlprinted an address containing_,%,#and~in body text with no escapes, and it can break long lines.- Pandoc escapes these characters for you when it turns Markdown into LaTeX. Pandoc 3.8 wrote
50\%,R\&Dandfile\_namein our test. Our Markdown to LaTeX guide covers the commands.
For anything beyond the reserved ten, such as arrows, accents and dingbats, the Comprehensive LaTeX Symbol List is the reference to search. For everyday math, our LaTeX symbols reference and the list of LaTeX arrow commands are quicker to scan.
LaTeX special characters come down to one rule with three exceptions. Put a backslash before #, $, %, &, _, { and }, and reach for \textbackslash, \~{} and \^{} for the other three. When you're writing math in Markdown, the same escapes work inside dollar signs. Try them in the editor, where the KaTeX preview updates as you type.