5

I have a problem with the following character

ẽ: e with tilde

I am using UTF-8 encoding and I get the following error

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

I am aware of this solution: \~e but the problem is that the that concerns me is the name of an author that is inside a bibtex that is automatically generated by mendeley...

I could, however, modify it in mendeley and cahnge for \~e, but is not a very elegant solution...

Anyway, I can let go this and simply replace it for e if there is no solution. I am just curious as to why UTF-8 does not handle this? I thougth UTF-8 handled every possible character.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}

This does not work:  ẽ

This works: \~e

\end{document}
2
  • 2
    Maybe you could have a look at this question. The provided solution is to use \usepackage[utf8]{inputenc}, and if this is not sufficient, which seems to be your case, to use \DeclareUnicodeCharacter to replace a unicode character with a latex sequence Nov 12, 2012 at 13:47
  • You could use utf8x, but avoid it. Better use XeTeX. It worse being used.
    – m0nhawk
    Nov 12, 2012 at 13:48

1 Answer 1

7

The range of Unicode characters is quite large. Therefore utf8.def limits itself to the characters that can be displayed using one of the font encodings that are loaded. The disadvantage that some characters, that can be constructed via accents can slip through. Therefore \DeclareUnicodeCharacter allows to add these characters:

\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{1eBC}{\~E}
\DeclareUnicodeCharacter{1EBD}{\~e}

Addition (see egreg's comment):

Package newunicodechar provides \newunicodechar that declares the character without specifying its explicit code number:

\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}
\newunicodechar{Ẽ}{\~E}
\newunicodechar{ẽ}{\~e}

Also version 1.3 of package selinput (updated on CTAN with next bundle release, .dtx is attached and the .sty file extracted by running plain tex on the .dtx file) provides this feature via \DeclareInputUnicodeChar. The following example adds a key value interface for setting the Unicode characters, making it easier to type, if lots of additional Unicode character declarations are needed:

\usepackage[utf8]{inputenc}
\usepackage{selinput}[2012/09/29]
\usepackage{kvsetkeys}
\makeatletter
\kv@parse{
  Ẽ=\~E,
  ẽ=\~e,
}\DeclareInputUnicodeChar
\makeatother

The new version 1.12 of inputenx will add support for these characters by

\usepackage[utf8]{inputenc}% or inputenx
\input{ix-utf8enc.dfu}% 2012/11/12 or later needed
6
  • 2
    A way that avoids looking for the Unicode point is to use newunicodechar: \usepackage{newunicodechar} and then \newunicodechar{ẽ}{\~e}.
    – egreg
    Nov 12, 2012 at 14:09
  • Is there any pros and cons if we compare these two solutions? Which one is better? newunicodechar or DeclareUnicodeCharacter? Nov 12, 2012 at 14:40
  • I've just uploaded version 1.1 of newunicodechar that sports compatibility with inputenx
    – egreg
    Nov 12, 2012 at 17:10
  • @FelipeAguirre The two are equivalent; with \newunicodechar you don't need to know the Unicode point of the character you want to give a meaning to.
    – egreg
    Nov 12, 2012 at 17:11
  • "One of the font encodings that are loaded" I think either this is wrong, or you mean "will be loaded when \begin{document} is executed"? tex.stackexchange.com/questions/13067/utf8x-vs-utf8-inputenc/…
    – user202729
    Dec 28, 2021 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .