[Tex/LaTex] æ ø å giving “Package inputenc Error: Keyboard character used is undefined”

luatex

I am having a problem with my masters project, i can not write my name as it have a ø in it. when i compile do i get the error.

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.1 ...lly I would like to thank my Father Niels Sø
                                                  gaard and Mia Louise Søga...
You need to provide a definition with \DeclareInputText 
or \DeclareInputMath before using this key.

I have been surfing around and found that people having the problem often have files not encoded in utf8, i am using Sharelatex so everything should be utf8, they files synced with my dropbox are!

my project have

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}    

What else could be causing this error? been trying to fix it for more then 4 hours now 🙁

Update: I have to use the LuaLatex computer for my graphs to work, but if i use PDFLatex dose æ ø å work just fine

Update 2: The official template i am using from my School (a danish school)

%==================================================================================================
% LUKE PHD THESIS LAYOUT STYLE FILE
% ---------------------------------
% Based upon work by: Henrik Aalborg Nielsen, Thomas Fabricius, Jan Larsen and Finn Kuno
% Christensen
% Contact: Luke Herbert (lthhe@imm.dtu.dk)
%==================================================================================================
\typeout{----------------------------------------------------}
\typeout{USING LUKE'S PHD THESIS TEMPLATE 1.2}
\typeout{----------------------------------------------------}
%
%==================================================================================================
% BASE PACKAGES
%==================================================================================================
%\usepackage[utf8]{inputenc}                         %Allows input of tex files encoded in UTF8
%\usepackage[T1]{fontenc}                            %Set font encoding for output PDF
\usepackage[danish,english]{babel}                  %Allows langauge switching (English is default)
\usepackage{graphicx}                               %Support for including graphics
\usepackage{xcolor}                                 %Support for using colours
\usepackage[hang,normalsize,bf]{caption}            %Make pretty captions
\usepackage{varioref}                               %Enhances references (\vref {label})
\usepackage{fancyhdr}                               %Pretty headers/footers
\usepackage{hyperref}                               %References package
\usepackage{amsmath,amssymb,latexsym}               %AMS and other symbols
\usepackage{epic,eepic,epsfig,graphics,psfrag}      %Figure/picture packages
\usepackage{theorem}                                %Allows creation of custom enviroments
%
%==================================================================================================
% PAGE GEOMETRY
%==================================================================================================
\addtolength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}
\pagestyle{myheadings}
\setlength{\paperwidth}{176mm}  %b5
\setlength{\paperheight}{250mm} %b5
\setlength{\textheight}{185mm} % 540pt = 7.5inch = 190.5mm
\setlength{\topmargin}{-5.4mm}
\setlength{\headheight}{8mm}
\setlength{\headsep}{7mm}
\setlength{\footskip}{10.0mm}
\setlength{\textwidth}{121.36mm}  % 129.36 mm  % width and margins must add to 176 mm:
\setlength{\oddsidemargin}{1.24mm} % 1 inch + 1.24 mm = 26.64 mm inside
\setlength{\evensidemargin}{-5.4mm} % 1 inch - 5.4 mm = 20 mm outside
%==================================================================================================
% HEADINGS SETUP
%==================================================================================================
\pagestyle{fancyplain}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\lhead[\fancyplain{}{\sffamily\bfseries\thepage}]%
      {\fancyplain{}{\sffamily\bfseries\rightmark}}
\rhead[\fancyplain{}{\sffamily\bfseries\leftmark}]%
      {\fancyplain{}{\sffamily\bfseries\thepage}}
\cfoot{}
%
%==================================================================================================
% GENERATE DERIVED THESIS PROPERTIES
%==================================================================================================
\newcommand{\derivethesisprops}{
   \def\ttitle{{\sf\textbf{\thesistitle}}}
   \def\thesisdef{IMM-\thesisdegree-\thesisyear-\thesisnumber}
   \def\printversion{print}
   \ifx\thesisversion\printversion
      \special{papersize=176mm,250mm}               %DTU-IMM special paper size
      \hypersetup{pdftitle={\thesistitle},
         pdfauthor={\thesisauthor},
         pdfsubject={\thesisdef},
         pdfkeywords={\thesiskeywords},
         breaklinks,
         bookmarksopen,
         bookmarksnumbered,
         plainpages=false}
      \else
      \hypersetup{pdftitle={\thesistitle},
         pdfauthor={\thesisauthor},
         pdfsubject={\thesisdef},
         pdfkeywords={\thesiskeywords},
         colorlinks,
         linkcolor=blue,
         breaklinks,
         bookmarksopen,
         bookmarksnumbered,
         plainpages=false}
   \fi
}
%
%==================================================================================================
% GENERATE PREFRONTMATTER
%==================================================================================================
\newcommand{\prefrontmatter}{
   \pagenumbering{alph}                                %Set prefrontmatter numbering style
   \thispagestyle{empty}                               %Front page (inside cover)
   \vspace*{\fill}
   \begin{center}
      {\huge\ttitle}\\*[2cm]
      \LARGE\sf\thesisauthor\\*[2.5cm]
      \includegraphics[scale=2]{dtu/DTU-logo} \\*[1cm]
      \small\sf Kongens Lyngby \thesisyear\\
      %\small\sf IMM-\thesisdegree-\thesisyear-\thesisnumber
      \small\sf IMM-\thesisdegree-\thesisyear
   \end{center}
   \vspace*{\fill}
   \newpage                                            %Back of front page
   \thispagestyle{empty}
   \vspace*{11cm}
   {\sf Technical University of Denmark}\\
   {\sf Department of Applied Mathematics and Computer Science}\\
   {\sf Matematiktorvet, building 303B,}\\ 
   {\sf 2800 Kongens Lyngby, Denmark}\\
   {\sf Phone +45 4525 3351}\\
   {\sf compute@compute.dtu.dk}\\
   {\sf www.compute.dtu.dk}
   \vspace*{2.5cm}
   \def\empty{}
   %{\sf IMM-\thesisdegree-\thesisyear-\thesisnumber}
   {\sf IMM-\thesisdegree-\thesisyear}
}
%
%==================================================================================================
% ENVIROMENTS SETUP
%==================================================================================================
\newtheorem{lemma}{Lemma}[chapter]
\newtheorem{proposition}[lemma]{Proposition}
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{corollary}[lemma]{Corollary}{\theorembodyfont{\rmfamily}
\newtheorem{definition}[lemma]{Definition}}\theoremheaderfont{\scshape\bfseries}
\newenvironment{proof}{{\scshape Proof.}}{}
\newcommand{\qed}{\hfill $\square$ \vspace{5mm}}
\newtheorem{example}{Example}[chapter]
%
%==================================================================================================
% CHAPTER AND APPENDIX STYLING SETUP
%==================================================================================================
\renewcommand{\chaptername}{C h a p t e r }
\renewcommand{\appendixname}{A p p e n d i x }
%
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
   \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \large\scshape \@chapapp \space\space \Huge\upshape\thechapter
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \flushleft\parbox{\textwidth}{\raggedleft \sffamily\Huge\bfseries  #1}
     \par\nobreak
     \vskip 15pt
     \hrule height 0.4pt
    \vskip 80\p@
  }}
%
\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \interlinepenalty\@M
     \sffamily\huge\bfseries  #1
     \par\nobreak
     \vskip 15pt
     \hrule height 0.4pt
    \vskip 80\p@
  }}
% % % EOF % % %

Update 3: My main file:

%==================================================================================================
%   LUKES THESIS TEMPLATE 1.2
%   -------------------------
%   This template is based upon the offcial IMM PhD Thesis template, it is enhanced with a number
%   of new features and a number of errors have fixed. This template is intended to be complied to
%   PDF using PDFLATEX and is tested using the MiKTeX 2.9 LaTeX distribution.
%   It is based on the official DTU-IMM Thesis template by Finn Kuno Christensen in 2009.
%   Small bugfixes by Kasper Laursen in 2012 and 2013.
%   -------------------------
%   Last Updated: 2012-09-19
%   Contact: lthhe@imm.dtu.dk
%==================================================================================================
%
%==================================================================================================
% DOCUMENT SETUP
%==================================================================================================
\documentclass[10pt,twoside]{book}                  %Official DTU-IMM Thesis document setup
%\usepackage[utf8]{inputenc}
%\usepackage{fontspec}
%
%Set to 'print' for printed version, use 'net' for online version
\def\thesisversion{print}
%
%==================================================================================================
% PACKAGES
%==================================================================================================
\usepackage{LukeThesis}                             %Import Thesis base style
%input{PhDMacros}                                   %Thesis specific macros
%
%==================================================================================================
% THESIS PROPERTIES (Modifiy these fields with your details)
%==================================================================================================
\def\thesisauthor{Kasper Rune Søgaard}                     %Author
\def\thesistitle{Schema Evolution for Automatic Migration}               %Title
\def\thesishandin{31-July}                       %Submission date (Day-Month}
\def\thesisdegree{M.Sc.}                            %Degree ('B.Eng', 'B.Sc.', 'M.Sc.' or 'PhD')
\def\thesisyear{2014}                               %Submission year
\def\thesisnumber{????}                             %DTU-IMM Serial number (do not include year)
\def\thesisISSN{0000-0000}                          %ISSN number
\def\thesiskeywords{Keywords are, comma separated}  %PDF keywords
\derivethesisprops                                  %Derive dependent properties
%
%==================================================================================================
% SECTION NUMBERING SETUP
%==================================================================================================
\setcounter{tocdepth}{2}                            %2 adds sections up to subsections
\setcounter{secnumdepth}{3}                         %Subsubsections get a number when this is 3
%

%==============================
% My stuff
%==============================
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{forest}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\usepackage{adjustbox}

\usepackage{listings}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{algorithmicx}

\tikzset{highlightcircle/.style={circle, draw, ultra thick, minimum size=0.75cm}}

\usepackage{color}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}

\lstset{
    basicstyle=\ttfamily,
    columns=fullflexible,
    showstringspaces=false,
    commentstyle=\color{gray}\upshape
}

\lstdefinelanguage{XML}
{
    morestring=[b]",
    morestring=[s]{>}{<},
    morecomment=[s]{<?}{?>},
    stringstyle=\color{black},
    identifierstyle=\color{darkblue},
    keywordstyle=\color{cyan},
    morekeywords={xmlns,version,type}% list your attributes here
}
\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%

%==================================================================================================
% THESIS STRUCTURE  (Modifiy to include more chapters etc)
%==================================================================================================
\begin{document}

Update 4: You wanted a small test

\documentclass{book}

\begin{document}
this is a "æ"
\end{document}

Give the result

this is a ""

Anwser: adding the following fixed my problem

\usepackage[utf8]{luainputenc}

Best Answer

This works perfectly when compiled with pdflatex:

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}  
\begin{document}
Niels Søgaard
\end{document}

If you get an inputenc error then the file with the ø is not utf8 encoded and you need to reencode it. Or create a new utf8 document and copy and paste the content to it.

You don't need to switch to lualatex to get such chars but if you do it: lualatex too needs files in utf8.

Related Question