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
Best Answer
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:
My example doesn't give an error, but its possible that your python code insert an utf8 char tex can't handle.