2

I would like to type accented letters directly in my tex file, and I would like them to be displayed correctly in the output. Neither of the solutions that I found online with inputenc / fontenc work. Please find enclosed a minimal example:

\documentclass{article}

\begin{document}

\title{Title}
\author{Author}
\maketitle

à

\end{document}

What lines of code shall I insert on the top of the document for "à" to be displayed correctly?

  • 2
    \usepackage[<encoding>[inputenc} should work fine here, provided you choose the right encoding. For most modern files it is utf8 but perhaps you've saved in some other form ... – Joseph Wright Jun 15 '16 at 9:38
  • 1
    Michael, notice that how the file is encoded depends on your editor configuration, not on LaTeX or TeX. So you have to tell it exactly which encoding your are using. As a personal suggestion, your best bet is using usepackage[utf8]{inputenc} and change the editor to use utf8 --- will save you a lot of problems in the future. – Rmano Jun 15 '16 at 9:55
  • 1
    This works, indeed: I added % !TEX encoding = UTF-8 Unicode at the beginning of the document to set the encoding in TexShop, and then \usepackage[utf8]{inputenc}. Thank you. – James Jun 15 '16 at 10:31
  • @Rmano An answer? – cfr Jun 16 '16 at 1:58
3

A TeX input file is, basically, a plain text file: that is, an unstructured sequence of bytes. For any program or application using this kind of files, they are just sequences of numbers from 0 to 255. The fact that you, TeX, and your text editor see them as symbols and letters is because there is a convention that associates every number to a letter - the encoding. This is well until you realize that there are scores of encodings, and if the set of applications you are using do not agree about it, things happen.

Unfortunately, there is no standard way to say which encoding a file is using - you have to know it. And the package inputenc is the way to tell LaTeX which encoding you are using.

Unicode utf8 is a de-facto standard nowadays, so the beat option is to convince your editor to use it, and add

\usepackage[utf8]{inputenc}

to your input file. And if you use a modern engine like xelatex or luatex the encoding must be utf8 and you do not even have a choice (so you shouldn't use inputenc there).

A must-read about encoding is this blog post by Joel Sposky: http://www.joelonsoftware.com/articles/Unicode.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.