Document Fundamentals

Special Characters

Learn how to handle special characters, input encoding, diacritics, and symbols in LaTeX.

This chapter assumes you are using the latex or pdflatex engines and need to concern yourself with TeX's various encodings. lualatex and xelatex, on the other hand, accept Unicode input and can usually typeset documents using the correct glyphs without further user intervention. See the Fonts chapter's discussion of encoding for additional information.

Modern LaTeX (2018+): Since the April 2018 release, pdfTeX handles UTF-8 input natively. The \usepackage[utf8]{inputenc} line is no longer required for most documents. If you're using a modern TeX distribution (TeX Live 2018 or later, MiKTeX 2.9 or later), UTF-8 is the default encoding.

In the following document, we will refer to special characters for all symbols other than the lowercase letters a-z, uppercase letters A-Z, figures 0-9, and English punctuation marks.

The rules for producing characters with diacritical marks, such as accents, differ somewhat depending whether you are in text mode, math mode, or the tabbing environment.

Input Encoding

Modern LaTeX assumes UTF-8 source input. Older documents and legacy workflows may use other encodings:

  • ASCII: a 7-bit subset of UTF-8. It covers basic English characters.
  • ISO-8859-1 (a.k.a., Latin 1): 8-bits encoding. It supports most characters for Latin languages.
  • UTF-8: a Unicode multi-byte encoding. Supports the complete Unicode specification.

In the following we will assume that you want to use UTF-8.

There are some important steps to specify encoding:

  1. Make sure your text editor decodes the file in UTF-8.
  2. Make sure it saves your file in UTF-8.
  3. If you are working in a terminal, make sure it is set to support UTF-8 input and output.
  4. Tell LaTeX that the source file is UTF-8 encoded (only needed for TeX distributions older than 2018):
% Only needed if your TeX distribution is older than 2018
% \usepackage[utf8]{inputenc}

Note: Since April 2018, pdfTeX handles UTF-8 natively. The inputenc package is only needed for legacy systems.

Important: If you check the character encoding, be sure that your file contains at least one special character, otherwise it will be recognized as ASCII.

The inputenc package allows the user to change the encoding within the document as well:

\usepackage[utf8]{inputenc}
% ...
\inputencoding{latin1}
% ...
\inputencoding{utf8}

Extending the Support

UTF-8 can encode every Unicode character, but pdfLaTeX can typeset only characters supported by its LaTeX input mappings and loaded fonts. You might encounter:

! Package inputenc Error: Unicode char \u8:ũ not set up for use with LaTeX.

You can define the characters yourself:

\DeclareUnicodeCharacter{'codepoint'}{'TeX sequence'}

Example:

\DeclareUnicodeCharacter{0177}{\^y}

Escaped Codes

In addition to direct UTF-8 input, LaTeX supports the composition of special characters as well. The following accents may be placed on letters:

LaTeX commandSampleDescription
\`{o}ògrave accent
\'{o}óacute accent
\^{o}ôcircumflex
\"{o}öumlaut, trema or dieresis
\H{o}őlong Hungarian umlaut (double acute)
\~{o}õtilde
\c{c}çcedilla
\k{a}ąogonek
\l{}łbarred l (l with stroke)
\={o}ōmacron accent (a bar over the letter)
\b{o}obar under the letter
\.{o}ȯdot over the letter
\d{u}dot under the letter
\r{a}åring over the letter
\u{o}ŏbreve over the letter
\v{s}šcaron over the letter
\t{oo}o͡o"tie" (inverted u) over the two letters
\o{}øslashed o (o with stroke)
{\i}ıdotless i (i without tittle)

Note: Current versions of LaTeX do not need \i and \j for dotless i/j when adding diacritics (older versions required this).

For example, to achieve easier coding of umlauts, the babel package can be configured:

\usepackage[german]{babel}

This provides the shorthand "o for \"o.

Less Than < and Greater Than >

The two symbols '<' and '>' are actually ASCII characters, but you may have noticed that they will print '¡' and '¿' respectively. This is a font encoding issue. If you want them to print their real symbol, use another font encoding such as T1:

\usepackage[T1]{fontenc}

Alternatively, they can be printed with dedicated commands:

\textless
\textgreater

Euro € Currency Symbol

The textcomp package features a \texteuro command. An official version of the euro symbol is provided by eurosym:

\usepackage[official]{eurosym}

then you can insert it with the \euro{} command.

Alternatively, you can use the marvosym package:

\usepackage{marvosym}
\EUR{}

To make the '€' on your keyboard actually print the euro sign:

\DeclareUnicodeCharacter{20AC}{\euro{} }
% or
\DeclareUnicodeCharacter{20AC}{\EUR{} }

Complete example:

\usepackage[utf8]{inputenc}
\usepackage{marvosym}
\DeclareUnicodeCharacter{20AC}{\EUR{} }

Degree Symbol for Temperature and Math

The easiest way to print temperature and angle values is to use the \SI{value}{unit} command from the siunitx package:

\usepackage{amsmath}
\usepackage{siunitx}

A $\SI{45}{\degree}$ angle.

It is $\SI{17}{\degreeCelsius}$ outside.

Warning: A common mistake is to use the \circ command. It will not print the correct character (though $^\circ$ will). Use the textcomp package instead.

Other Symbols

LaTeX has many symbols at its disposal. For the more common text symbols, use the following commands:

CommandCharacter
\%%
\$$
\{{
\__
\P
\ddag
\textbar|
\textgreater>
\textendash--
\texttrademark
\textexclamdown¡
\textsuperscript{a}Xᵃ
\pounds£
\##
\&&
\}}
\S§
\dag
\textbackslash\
\textless<
\textemdash
\textregistered®
\textquestiondown¿
\copyright©

To get a printed tilde sign, write \~{} or \textasciitilde{}. And a visible space can be created with \textvisiblespace.

In Special Environments

Math Mode

Several accents can also be produced in math mode:

LaTeX commandDescriptionText-mode equivalence
\hat{o}circumflex\^
\widehat{oo}wide version of \hat
\check{o}vee or check\v
\tilde{o}tilde\~
\widetilde{oo}wide version of \tilde
\acute{o}acute accent\'
\grave{o}grave accent\`
\dot{o}dot over the letter\.
\ddot{o}two dots over the letter\"
\breve{o}breve\u
\bar{o}macron\=
\vec{o}vector (arrow) over the letter

When applying accents to letters i and j, you can use \imath and \jmath to keep the dots from interfering:

\hat{\imath}  % circumflex on letter i without upper dot
\vec{\jmath}  % vector on letter j without upper dot

Tabbing Environment

Some of the accent marks used in running text have other uses in the tabbing environment:

  • \a' for an acute accent
  • \a` for a grave accent
  • \a= for a macron accent

Unicode Keyboard Input

Some operating systems provide a keyboard combination to input any Unicode code point:

  • Linux/BSD: Many X applications support the Ctrl+Shift+u combination. Type the code point and press enter or space.
  • Windows: Hold Alt and type a codepoint, e.g. Alt + 0252 will print ü.
Copyright © 2026