Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up

Accents and special characters

Writing “é”, “à”, “ç” without trouble is a matter of encoding. Your files are now in UTF-8: you simply need to declare it correctly. This is also the number-one cause of accents that display as gibberish.

In pdfLaTeX: two lines are enough

Compile This modern preamble handles accents in pdfLaTeX. Compile and check that everything displays correctly.

The pitfall: latin1

An old preamble sometimes declares latin1 while the file is in UTF-8. The result: broken accents or the error “ Invalid UTF-8… ”.

Fix This document declares latin1 and fails on the accents. Replace latin1 with utf8, then recompile. Learn more →
Show the solution
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
With utf8, the accents work: été, à, ç.
\end{document}

In XeLaTeX: nothing to declare

With fontspec (XeLaTeX / LuaLaTeX), UTF-8 is native: inputenc is no longer needed.

Compile This example is set to XeLaTeX. Compile: the accents work without inputenc.
Key takeaway: in pdfLaTeX, \usepackage[utf8]{inputenc} + \usepackage[T1]{fontenc}. In XeLaTeX/LuaLaTeX, \usepackage{fontspec} is enough. Never latin1 on a modern file.