My .tex and .sty files were in encoding latin-1. I've converted them [using Emacs] to utf-8.

In my sty file, I replaced




:: The problem: My style file has commands


and the like.

When I run command `pdflatex' from the command line, I get this error message:

! Package inputenc Error: Keyboard character used is undefined
(inputenc)                in inputencoding `utf8'.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.

l.86 \newcommand{°}{\ensuremath{^\circ}}

which is showing the character as


Is there a way to get these characters processed in utf-8, or should I switch back to latin-1?

============ [I'm not sure the stackexchange method to Ulrike Fischer's suggestion, so I'm editing my original question.

Alas, neither solution is working on my system [which is "This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)"], or I may be mis-applying your suggestion.

Running `pdfTeX' on





Test: $ ½ $



This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, arabic, armenian
, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutch, u
kenglish, usenglishmax, esperanto, estonian, farsi, finnish, french, galician, 
german, ngerman, swissgerman, monogreek, greek, hungarian, icelandic, assamese,
 bengali, gujarati, hindi, kannada, malayalam, marathi, oriya, panjabi, tamil, 
telugu, indonesian, interlingua, irish, italian, kurmanji, lao, latin, latvian,
 lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, polish, portuguese, roma
nian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish,
 turkmen, ukrainian, uppersorbian, welsh, loaded.
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/Users/squash/Texdir/Pkgs/newunicodechar.sty) (./de.testing.aux)

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

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.

l.11 $½

This happens whether or not the "\usepackage[T1]{fontenc}" is present, and whether or not the "\usepackage{newunicodechar}" is present.

  • 4
    Use either the newunicodechar package or \DeclareUnicodeCharacter{00B0}{\ensuremath{^\circ}} (after inputenc). – Ulrike Fischer Sep 20 '17 at 16:36
  • Neither solution working on my system. I've edited my question putting in a minimal-example. – gentsquash Sep 22 '17 at 16:31
  • @UlrikeFischer's suggestion is to do \newunicodechar{°}{\ensuremath{^\circ}} and \newunicodechar{½}{\ensuremath{\frac{1}{2}}} and it does work. When you load a package you should give a quick look at its documentation: texdoc newunicodechar. – user4686 Sep 22 '17 at 21:37
  • Thanks jfbu. Running `texdoc newunicodechar' was the first thing I did. On my system, it gave: "Sorry, no documentation found for newunicodechar." (I did eventually get the doc by hand.) – gentsquash Sep 24 '17 at 1:42

Ulrike's comment works like a charm, e.g. package newunicodechar:





Test: $ ½ $



The hexadecimal Unicode number needs to be known without package newunicodechar:


The font encoding TS1, loaded by package textcomp contains a slot for this symbol and uses the text mode character \textonehalf:




Test: ½



| improve this answer | |
  • Ah ha! I need to use \newunicodechar rather than \newcommand. Thank you. – gentsquash Sep 24 '17 at 1:39

Thank you Heiko and Ulrike. I indeed had already tried


without using \DeclareUnicodeCharacter, but I had kept the commands as they were, e.g


This caused an error that was obscure to me. Replacing the latter with


made more of my style-files load.

It turned out that while my former latin-1 setup accepted expressions such as

$ \boldsymbol· $

they now cause an error. My current UTF8 setup only works if I put in braces,

$ \boldsymbol{·} $

That is, it seems that when characters

¼  ±  ·

and the like, are passed as arguments to a macro, they must be in braces. Or perhaps I have mis-set-up something.

In any case, my files are compiling now after a bunch of global search-replacements. Thanks again.

| improve this answer | |

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.