2
\documentclass[a4paper]{report}
\usepackage[utf8x]{inputenc}
\begin{document}
\tableofcontents
\chapter{ø}
\end{document}

First time I compile this, I get an ø in the table of contents. Second time I compile this, the ø turns into [Pleaseinsertintopreamble], and this goes on and on.

What should I do in order to get an ø every time?

Coolwater
  • 233

2 Answers2

4

Like Harish I would suggest to use utf8 instead of ucs/utf8x, but if for some reason you really need utf8x you must prerender the offending unicode character:

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\PrerenderUnicode{ø}
\begin{document}
\tableofcontents
\chapter{ø}
\end{document}
Ulrike Fischer
  • 327,261
  • Perfect, the thing is I do need utf8x – Coolwater Apr 27 '15 at 09:01
  • Why do you need it? – Ulrike Fischer Apr 27 '15 at 09:03
  • I use package "alltt" to include txt-files with æøå, which fails with utf8 – Coolwater Apr 27 '15 at 09:06
  • I don't see a reason why these chars should fail, you should better ask about it in a new question (with an example). – Ulrike Fischer Apr 27 '15 at 09:22
  • @Coolwater I tried alltt with utf8 and had no problem. You should also do \usepackage[T1]{fontenc}, but this just improves the typesetting, without it I have no problem either. – egreg Apr 27 '15 at 09:50
  • @egreg when i type \input{doc.txt} in alltt environment, compiling gives error when using utf8 without x: ! Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.. – Coolwater Apr 27 '15 at 13:08
  • @Coolwater A minimal example is needed. Does the input file have Greek letters? – egreg Apr 27 '15 at 14:01
  • @egreg The error occurs when i compile: \documentclass[a4paper]{report} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{alltt} \begin{document} \begin{alltt} \input{doc.txt} \end{alltt} \end{document}

    Where doc.txt is saved in UTF-8-format by notepad.exe. It doesnt matter whether doc.txt is just empty or as usual contains the characters æ ø å ž š õ ü ö ä ÿ. Using utf8x makes it work though.

    – Coolwater Apr 27 '15 at 14:24
  • 2
    @Coolwater Notepad is known for adding the BOM to its UTF-8 encoded files and that is the cause of your problem. See UTF-8 encoding and Notepad with LaTeX Better cure the disease than just the symptoms. – egreg Apr 27 '15 at 15:10
1

Use \usepackage[utf8]{inputenc} instead of utf8x

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\begin{document}
\tableofcontents
\chapter{ø}
\end{document}

enter image description here