107

No matter how I try to do it I always get the following error :

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

I have tried using ­­­$^{\circ}$, \deg, \textdegree, pasting the ° symbol directly, to no avail.

Here is the header of my document, in case one of those could be causing the errors :

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[francais]{babel}
%\FrenchItemizeSpacingfalse
\frenchbsetup{CompactItemize=false}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
5
  • I had the same issue. In my case it was an issue due to a misleading character in my bibdesk library. After exchange and a new run with BibTex everything was fine again.
    – user12684
    Commented Mar 16, 2012 at 12:10
  • A quick solution is to use the "Zap Gremlins" feature in the fantastic (and free to use) TextWrangler. This removes non-ASCII, control and NULL characters. IF you want a simple ASCII input file this will save you lots of time looking for invisible characters.
    – boyfarrell
    Commented Jul 1, 2014 at 10:55
  • As noted by Antal Spector-Zabusky at the very end of his answer, compiling with xelatex should solve the issue. Just make sure to remove the \usepackage[utf8]{inputenc} line. Commented Jul 4, 2017 at 10:23
  • 3
    You don’t need \usepackage[utf8]{inputenc} in any engine. It’s been the default since 2018.
    – Davislor
    Commented Jun 9, 2020 at 15:56
  • 2
    In XeLaTeX or LuaLaTeX, though, you would want to \usepackage{fontspec} instead of fontenc and lmodern.
    – Davislor
    Commented Jun 9, 2020 at 15:57

4 Answers 4

95

If you're getting literally that error—with no visible character after the \u8:—then what's probably happening is that you have some sort of invisible or space unicode character in your document. For instance, on my Mac, if I hit option-space, I get a non-breaking space, which gives an error that looks like that. You also might have some other character; a zero-width breakable space, for instance. If you copied and pasted your error, looking at the source of this page indicates that you might have a soft hyphen in your source (Unicode character 0xAD, representing a valid hyphenation point but not typeset unless there's a word-break). Thus, find the line it's occurring on, and comb through that line until you find it. Retype it if necessary, but a good editor should let you find it. Once you delete it, then your first three methods should work.

When I use your header (commenting out \frechbsetup, which doesn't seem to exist, and using \documentclass{article}), $^{\circ}$ renders as a largeish circle in the superscript position, $\deg$ renders as the upright text "deg", and \textdegree renders as a smaller circle. A literal ° doesn't work by default. To make it work, you can use \DeclareUnicodeCharacter{B0}{\textdegree}. This tells inputenc to treat the Unicode character 0xB0, the °, as though it were \textdegree, which is what you want. You could also use this to see if your problem is the soft hyphen; insert \DeclareUnicodeCharacter{AD}{\Huge [ICI]} to get the text [ICI] rendered into your document in huge letters wherever there's a soft hyphen. (Of course, if there's some other invisible character, you'll just get the error.)

Also, although I've never used it, you could try using XeLaTeX instead of PDFLaTeX; it has full UTF-8 support out of the box.

13
  • 10
    Indeed, an invisible character seemed to be the source of my problem. Thanks!
    – levesque
    Commented Oct 18, 2010 at 17:14
  • 9
    No problem. I remember how befuddled I was the first time I ran into this problem; I'm glad I could help someone else out with it. Commented Oct 18, 2010 at 17:35
  • 2
    @AntalS-Z Is there a way to detect which symbol is causing this error ? It is giving this error in the first line where there is plain text. Thanks.
    – Anusha
    Commented Oct 15, 2014 at 9:40
  • 3
    @Anusha: Not that I can think of off the top of my head – depending on your editor, you could (a) retype the line, (b) step through it with the arrow keys until you hit something strange, (c) turn on some sort of "show invisible characters" setting, or (d) put the file through some sort of shell filter like cat -v or xxd to see where the first wrong character is. Commented Oct 16, 2014 at 20:09
  • 2
    @Anusha: In Emacs, if your document is mostly in ASCII (that is, the basic 26 characters of the Latin alphabet in upper- and lower-case, the 10 digits, and a handful of punctuation), then you could search for a non-ASCII character: C-M-s [ -~] (C-M-s searches for a regular expression, and [ -~] looks matches the printable ASCII range). This will match most possible culprits, in addition to tabs and newlines. Commented Oct 16, 2014 at 20:23
51

Using

\usepackage[utf8x]{inputenc} 

instead of [utf8] solved the problem for me.

6
  • 14
  • 3
    Adding to Paul Gaborit's comment: This "solves" the problem but introduces ut8x, which is undesirable. This answer should not be upvoted. Commented Sep 6, 2016 at 20:07
  • it doesn't work me:-( Commented Dec 14, 2016 at 23:03
  • 4
    And I'm getting Package biblatex Error: Incompatible package 'ucs'. \begin{document}
    – hola
    Commented Jun 30, 2017 at 5:33
  • 1
    Just introduces other problems, such as issues with ščřžýáí in the reference name. Do not use.
    – atapaka
    Commented Jan 29, 2022 at 8:55
23

\usepackage{textcomp} is missing.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\begin{document}
 °
\end{document}
3
  • 1
    Adding textcomp worked for me, but so did using $^{\circ}$ in the text. Which is cleaner? Commented Aug 31, 2015 at 17:19
  • It depends on how often you are going to be using the character. Commented Apr 16, 2019 at 20:23
  • 1
    As of 2020, textcomp is integrated into the LaTeX kernel, and no longer needs to be included explicitly. So your solution, which was correct when you posted it, is now applied automatically.
    – Davislor
    Commented Jun 9, 2020 at 15:59
5

I got this error after copying a word from my browser and pasting it into my editor. Just retyped it an the problem was solved.

You must log in to answer this question.

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