æ ø å 给出“包 inputenc 错误:使用的键盘字符未定义”

æ ø å 给出“包 inputenc 错误:使用的键盘字符未定义”

我的硕士项目遇到了问题,我无法写下我的名字,因为里面有一个 ø。当我编译时我收到错误。

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.

我一直在网上搜索,发现遇到此问题的人通常文件未使用 utf8 编码,我正在使用 Sharelatex,因此所有内容都应该是 utf8,与我的 Dropbox 同步的文件也是如此!

我的项目有

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

还有什么可能导致此错误?我已经尝试修复它超过 4 个小时了 :(

更新:我必须使用 LuaLatex 计算机才能使我的图表工作,但如果我使用 PDFLatex 剂量 æ ø å 工作就很好

更新 2:我使用的学校(丹麦学校)的官方模板

%==================================================================================================
% LUKE PHD THESIS LAYOUT STYLE FILE
% ---------------------------------
% Based upon work by: Henrik Aalborg Nielsen, Thomas Fabricius, Jan Larsen and Finn Kuno
% Christensen
% Contact: Luke Herbert ([email protected])
%==================================================================================================
\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 [email protected]}\\
   {\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 % % %

更新3:我的主要文件:

%==================================================================================================
%   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: [email protected]
%==================================================================================================
%
%==================================================================================================
% 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}

更新 4:你想要一个小测试

\documentclass{book}

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

给出结果

this is a ""

答案:添加以下内容解决了我的问题

\usepackage[utf8]{luainputenc}

答案1

当使用 pdflatex 编译时,它可以完美运行:

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

如果出现 inputenc 错误,则表示带有 ø 的文件不是 utf8 编码的,您需要重新编码。或者创建一个新的 utf8 文档,然后将内容复制并粘贴到其中。

您不需要切换到 lualatex 来获取这样的字符,但是如果您这样做:lualatex 也需要 utf8 格式的文件。

答案2

您不应该使用luainputenc,请确保您的 *.tex 文件是 utf8 编码的,并加载 fontspec 包:

\documentclass[]{article}
\usepackage{fontspec}
\begin{document}
Niels Søgaard
\end{document

相关内容