243

The two packages address different problems. inputenc allows the user to input accented characters directly from the keyboard; fontenc is oriented to output, that is, what fonts to use for printing characters. The two packages are not connected, though it is best to call fontenc first and then inputenc. With \usepackage[T1]{fontenc} you choose an output ...


87

Yes, you are confused. You should use both packages with pdflatex or a different approach with xelatex or lualatex. pdflatex \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} xelatex \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} lualatex \usepackage{luatextra} \defaultfontfeatures{Ligatures=TeX} Or in a complete ...


86

The error you get is due to a "no-break space" character, according to what I can gather by copying an pasting your message. This character is not usually set up by the [utf8] option and it's invisible to many editors, so it can slip in a document without the typist knowing it. Solution: add in your preamble \DeclareUnicodeCharacter{00A0}{ } if you don't ...


62

As this is one of the top google hits for this error message, here's a more general answer with an example: The cause is a unicode character in one of your input files that isn't mapped to an output. This may -- especially if you're using the (unicode-supporting) biblatex/biber system -- be in your bibliography. This is a good place to look for errors as ....


39

Don't use utf8x; with an up-to-date TeX distribution it could show necessary only for its most obscure features (faking characters with images from the Web, for instance). The problem with Greek, which was probably the main reason for adopting utf8x instead of utf8, have since be solved and \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]...


35

The basic LaTeX/TeX engine expects (or perhaps is meant to process) pure ASCII input. Whenever your file uses any other characters, the inputenc package comes to the rescue, specifying to the engine how to process the symbols you're typing. So it's quite necessary, whenever you use unicode (non ASCII) characters, to use the inputenc package, in order to ...


32

Your text ---------------> TeX --------------> PDF input encoding font encoding You need an input encoding to tell TeX how to interpret the contents of your text file, you need an font encoding for proper hyphenation. Old TeX can only hyphenate words from one font and therefore you need to squeeze all the characters you use (...


32

With the following setup, you can just type these characters normally, and the copy-paste text in the pdf (the OCR layer) will be correct, too. Your source .tex document should be encoded in UTF8, of course, or you could use latin1, or some other input encoding that includes the characters you desire and is listed in the inputenc documentation. % !TEX ...


31

For UTF-8 input, use soulutf8; don't forget fontenc! \documentclass[a4paper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[french]{babel} \usepackage{soulutf8} \usepackage{color} \definecolor{y}{RGB}{245, 255, 189} \sethlcolor{y} \begin{document} \hl{\'e} \hl{é} \end{document} There is no 15pt option for article.


30

This works: M\^^22arz Indeed TeX interprets ^^xy (where x and y are digits or abcdef) as the character having "xy (hexadecimal) ASCII code. Since the character code of " is 34, hexadecimal 22, typing \^^22 is the same as typing \". This translation happens before TeX starts to make tokens.


29

Essentially in pdf every letter (or run of letters) is positioned by coordinates so even a normal word might be encoded as individual letters positioned to "look" like text, so as to take account of inter-letter kerns etc. Math is no different: the characters are just normal font characters positioned on the page at locations that TeX has determined. ...


27

You need inputenc to specify the character encoding used in your input file if it is not ascii. So latin1 (or more general and modern, utf8). fontenc specifies the encoding used in the fonts. this is (more or less) independent of the input encoding. Classical TeX uses Tex-specific font encodings such as "T1" for 8-bit fonts suitable for "latin1" languages. ...


27

Unfortunately, Latvian is quite poorly supported by babel: the letters with the comma diacritic are wrongly realized with a cedilla. Here's a possibly better realization. \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[latvian]{babel} \makeatletter \DeclareTextCommandDefault\textcommaabove[1]{% \hmode@bgroup \...


27

With the 2018 release of LaTeX the test file below produces as UTF-8 is assumed as the default input encoding unless you specify a different encoding to inputenc and the BOM at the start of the file is handled gracefully (ignored in this case). Original answer With inputenc commented out I get despite typing the input in emacs. \documentclass{article} \...


25

How does LaTeX implement UTF-8? The Unicode character é is encoded as two byte in UTF-8, precisely <C3><A9> (I'll use throughout this to denote bytes, also when they are character tokens for TeX). When \usepackage[utf8]{inputenc} is loaded, the byte <C3> is made active and defined to look for the following byte, because <C3> in UTF-8 ...


25

Package hyperref hyperref encodes correctly, but the options should be set after hyperref is loaded. Otherwise LaTeX expands the options the hard way and hyperref will only see the expanded garbage. \usepackage{hyperref} \hypersetup{ pdfauthor={Erwin Schrödinger}, } Extended example: \documentclass{article} \usepackage[utf8]{inputenc}% utf8, for ...


22

\usepackage[utf8x]{inputenc} Ubuntu: You must install texlive-latex-extra before use it. Fedora: You must install texlive-collection-latexextra before use it.


21

Font encoding Because of deficiencies of the OT1 encoding I also recommend T1 font encoding: \usepackage[T1]{fontenc} For example OT1 contains inconsistencies in the encoding for different families, typewriter is different, … Also \usepackage{textcomp} is useful for getting other symbols (Euro, …). Instead of Computer Modern/EC I would use ...


21

Unhappily utf8.def does not show the numerical representation for the missing Unicode character. The missing character <char> is shown directly in macro \u8:<char>. The following example adds the numerical information in the error message: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{stringenc} \usepackage{pdfescape} \...


21

UTF8 and ASCII are byte for byte identical for characters in the ascii range so if you have a plain text file that is ascii encoded it is also UTF-8 encoded, and similarly if it is UTF-8 encoded but only has characters in the range x00 - x7F then they are encoded directly as themselves with bytes in the same range so are valid ASCII files.


20

File encodings are not always easily determined, and so biblatex sometimes needs some help in deciding on the encoding of the bib file, especially if your bib file is encoded differently from your input file. But you can specify the bib file encoding directly as a biblatex option. If your bib file is UTF-8 encoded, you will need to use biber as the backend. ...


20

To get rid off the warning you can change the input code to utf8 for your .tex-file. With the following changed MWE I have no warnings or errors from biber and only one warning with the .tex-file (because package filecontents generates this warning). I marked the changes with %!!!!!!!! Your MWE with some changes: \RequirePackage{filecontents} \begin{...


20

inputenc is abandoned because it does absolutely nothing with XeTeX or LuaLaTeX. Better said, it would do bad! See fontenc vs inputenc Essentially, the task performed by inputenc is translating input characters into their LICR form. With an 8 bit engine, « is two byte long and inputenc is able to translate them into \guillemotleft and » into \...


20

The error can only be reproduced if the file is saved in UTF-8 encoding. Indeed, in this case, ó is really stored as the bytes 0xC3 and 0xB3. In the latin1 encoding, the first is à and the second is ³, which inputenc translates into \~A and \maththreesuperior. The latter is in turn converted into {^3}, which requires math mode and this is the cause for your ...


20

\DeclareUnicodeCharacter takes the codepoint in hexadecimal notation: \documentclass{article} \usepackage{wasysym} \DeclareUnicodeCharacter{1F600}{\smiley} \begin{document} Hello 😀 \end{document}


20

Actually, LaTeX has a pretty good Unicode support (better yet since the October 2019 update). You just need to define the character you want to type: \documentclass{article} \DeclareUnicodeCharacter{2194}{\ensuremath{\leftrightarrow}} \DeclareUnicodeCharacter{2195}{\ensuremath{\updownarrow}} \begin{document} How can I type ↔ and ↕ in \LaTeX? \end{document} ...


20

I would recommend the newunicodechar package for this: \usepackage{newunicodechar} \newunicodechar{↔}{\ensuremath{\leftrightarrow}} \newunicodechar{↕︎}{\ensuremath{\updownarrow}} You could also write ^^^^2194 for ↔. This package has the advantage of working in PDFLaTeX, LuaLaTeX and XeLaTeX, whereas \DeclareUnicodeCharacter is part of inputenc and only ...


19

To understand this, you need to realize that TeX is a "translator" that translates its input (the text you wrote) into output (PDF, or PS file). Accordingly the encodings of the input and the encoding of the output are two quite different things. inputenc tells TeX the encoding of your .tex file. It can be latin1, or utf8, or koi8r, or whatever. This is ...


18

This is due to a slight incompatibility of utf8x with amsart (that capitalizes the author's name). You have two paths to follow: say \usepackage[utf8]{inputenc} make the offending character known to ucs and utf8x before \begin{document} Path 1 is preferable, if you don't use characters that aren't covered by this option (and even if you do, as it's ...


18

The error happens when LaTeX is reading line 538 in the bibliography file, probably generated by BibTeX. The entry refers to an author named Patrycja Dynarowicz-Łątka (a chemist at the Jagellonian University in Kraków) whose name, in BibTeX-speak, becomes Dynarowicz-{\L}{\k{a}}tka, where you see \k. Just add \usepackage[T1]{fontenc} to your document ...


Only top voted, non community-wiki answers of a minimum length are eligible