\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?

allttwithutf8and 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\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\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