Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have an odd problem with special characters (in this case the Swedish åäö), that pops up in my .toc file. If I remove the .toc file everything works OK except I get an empty table of contents. When I re-run pdflatex, I get errors on every line in the .toc file that has either of åäö in it (which, as it happens, is every line...).

I've tried to produce a MWE example of this, but I'm unable to reproduce the problem with other files. However, I've noticed that for other files, åäö in the .toc file are replaced as follows:

å -> \IeC {\r a}
ä -> \IeC {\"a}
ö -> \IeC {\"o}

In the .toc file for the failing document, only å is replaced. Why could this be? What can I do about it?

Clarification: As I said, I have tried but been unable to reproduce this error in a MWE. (The full version is a pretty advanced structure with templates, frame and content files compiled by a python script calling pdflatex via os.system(), so I can't really just "scale off" one piece after another...) However, I can give the following information:

  • All files are saved in utf-8.
  • I'm using \usepackage[utf8]{inputenc} and \usepackage[swedish]{babel}.
  • The python file starts with #coding: utf8
share|improve this question
    
Perhaps post a minimal code example that produces this problem. Until now, we don't know the encoding you're using neither we know if you're using babel or not. –  Stefan Kottwitz Nov 1 '10 at 23:11
    
What error message do you get? –  Caramdir Nov 2 '10 at 0:47
    
@Caramdir: I get lots of variations of ! Package inputenc Error: Unicode char \u8:„ not set up for use with LaTeX. in the log file, along with things like Missing character: There is no  in font cmcsc10!. –  Tomas Lycken Nov 2 '10 at 1:02
    
In addititon, there are problems with rendering these letters in some headings, particularly within \textsc{}. –  Tomas Lycken Nov 2 '10 at 1:04
add comment

3 Answers

up vote 6 down vote accepted

When the non-ascii-chars like ä or ö get in the toc, this means that they are not active. Perhaps you are storing some of your titles in commands before inputenc has been loaded:

\documentclass{article}
\def\test{ÅÄÖ}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\tableofcontents

\section{\test}

\end{document}

My example doesn't give an error, but its possible that your python code insert an utf8 char tex can't handle.

share|improve this answer
    
This is very likely the cause - I'll do some testing and get back... –  Tomas Lycken Nov 2 '10 at 13:51
1  
Thanks! I had to rewrite quite a lot of my code to handle this, but when I include inputenc before setting up all the titles etc, everything works as expected =) –  Tomas Lycken Nov 12 '10 at 19:52
add comment

From the inputenc documentation:

1.3.3 Unicode char <charcode> is not set up for use with LaTeX

This is the dreaded error message that one will receive if the document contains an UTF-8 character that isn't known to LATEX. It is quite possible that the character looks very unsuspicious and is rendered perfectly in the editor.

...

However, even if LATEX can type that character in question it may not have been set up in which case you would need to do that yourself via \DeclareUnicodeCharacter.

So, something like \DeclareUnicodeCharacter{00E4}{\"a} might work. You'd probably need to see which Unicode glyph is the one you're trying to use (this example straight from the manual, section 1.2).

Hope this helps.

share|improve this answer
    
OK. I'm unable to find what numbers and glyphs I should use for the other five characters. Any clues? –  Tomas Lycken Nov 2 '10 at 8:53
    
See this: utf8-chartable.de . Does it work otherwise? –  Martin Tapankov Nov 2 '10 at 8:57
    
I added \DeclareUnicodeCharacter{00E4}{\"a} as well as one command for each of the other (ÅÄÖåö) troubling characters, but with no positive results - I still have warnings in my log file about undefined characters (\u8:Å, among others) and I still get an exit code that suggests failure. –  Tomas Lycken Nov 2 '10 at 9:13
add comment

Use a meaningful encoding such as

\usepackage[utf8]{inputenc}

but also take care that your editor uses the same encoding and that the file itself has this encoding too. For instance, one may download a latin1 encoded file but edit it with utf8 option and the other way round.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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