Umlauts and accents in LaTeX (ä, ö, ü, ß, é)
Type umlauts and accented letters directly: a current LaTeX reads UTF-8 without any package. Add \usepackage[T1]{fontenc} so words with these letters are hyphenated correctly. On a keyboard without the characters, accent commands such as \"a print them.
Type the characters directly
LaTeX has read source files as UTF-8 by default since 2018. \usepackage[utf8]{inputenc} is only needed for older installations and does no harm in new ones. The file has to be saved as UTF-8.
Complete document:
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Größe, Übung, Äpfel, café, señor, garçon, Ångström
\end{document}Accent commands
An accent command is a backslash, a symbol for the accent and the letter: a straight quote for the umlaut, an apostrophe for the acute, a backtick for the grave, ^ for the circumflex and ~ for the tilde. \c{c} prints a cedilla, \ss the sharp s, and \aa, \o and \ae the Scandinavian letters.
Gr\"o\ss{}e, \"Ubung, caf\'e, tr\`es, h\^otel, se\~nor, gar\c{c}on, \aa{}, \o{}, \ae{}Short form with babel
With babel and the option ngerman, a straight quote in front of a vowel prints the umlaut and "s the sharp s. Many older German documents are written this way.
Complete document:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\begin{document}
Gr"o"se, "Ubung, "Apfel
\end{document}Accents in formulas
Math mode has its own accent commands: \hat, \bar, \tilde, \dot, \ddot, \vec, \acute, \grave, \check and \breve.
$\hat{a}$, $\bar{x}$, $\tilde{n}$, $\dot{x}$, $\ddot{x}$, $\vec{v}$Pitfalls
- Without
\usepackage[T1]{fontenc}, pdfLaTeX builds an umlaut from a letter and a separate accent, and a word that contains one is hardly hyphenated at all. - A text accent such as
\"ainside a formula stops with "Please use \mathaccent for accents in math mode". Write\ddot{a}there. - A character that pdfLaTeX has no definition for, such as a Greek or Cyrillic letter, stops with Unicode character α (U+03B1) not set up for use with LaTeX.
- The error "Invalid UTF-8 byte" means the file is saved in another encoding, for example Latin-1. Save it as UTF-8.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
inputenc - Package
fontenc - Package
babel - Error Unicode character α (U+03B1) not set up for use with LaTeX
- How-to Quotation marks in LaTeX