我有一个使用了很多包的很长的文档,我用\include{chapter}
它来使它易于管理,但我不知道错误可能来自哪里,所以我真的不知道如何制作 MWE。
出现此错误时,我撤消了自上次编译以来对章节(单独文件)所做的所有更改,但错误仍然存在。这些更改主要是添加引文(“\parencite{citation}”)。如果我在不删除所有辅助文件的情况下编译其他章节,错误仍然存在;如果我删除它们,其他章节就可以编译正常。所以我猜错误一定在主文件的序言中,尽管我没有做任何更改,至少不是故意的。如果我使用 overleaf 编译文档,它只会在编译同一章节时给出相同的错误,因此问题不应该是因为缺少任何升级(我无论如何都升级了 MikTek)。错误指向章节中没有代码的一行(如果我注释掉错误周围的代码,错误仍然存在),它没有告诉我 Latex 无法理解什么,所以我不知道在哪里搜索。
这是序言(抱歉,我不知道要为 MWE 保留什么):
\documentclass[11pt, a4paper, oneside]{report}
%-----------------Packages used-----------------------
\usepackage[utf8]{inputenc} % which type of code to use to input special characters and accepts accents!
\usepackage[T1]{fontenc} % better fonts, less problems with copy-paste with accents, straight quotes
\usepackage{chngcntr} % to be able to change the numbering "depth"
\counterwithin{figure}{subsection} % make figures show subsection number
\counterwithin{table}{subsection} % make tables show subsection number
\usepackage{blindtext}
\usepackage{enumitem} % To control enumerate style
\usepackage{graphicx} % for managing the graphics
\graphicspath{{images/}} % for 'graphicx' to know where the images are
\usepackage{rotating} % to allow sideways figures ¿and tables? (rotated 90º)
\usepackage{caption} % to use \captionof{figure}{Test figure.} which in minitap allows figures and equations side by side
\usepackage[left=4cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry} % control the geometry of the page
\usepackage[backend=biber, style=apa]{biblatex}
\addbibresource{bibliography/Institutions.bib}
\addbibresource{bibliography/Thesis.bib}
%\bibliographystyle{unsrt}
\usepackage{fancyhdr} % to have and control headers and fooders
\pagestyle{fancy}
%\fancyhead{} % These and the two next come from the Annual review
%\fancyhead[L]{\ttl}
%\fancyhead[R]{\nom}
\usepackage{setspace} % to control the space between lines
\onehalfspacing % for package 'setspace' to set 1.5 space between lines (from setspace)
\usepackage{amsmath} % More options for writing equations
\usepackage{amssymb} % access to many symbols, check (tick) symbol
\usepackage{ragged2e}
%%%%%% TABLES %%%%%%%
\usepackage{booktabs} % nicer tables stuff
\usepackage{array} % More options for tables
\newcolumntype{B}[1]{>{\centering\arraybackslash}b{#1}} % to be able to center (bottom) content of cells with defined width
\usepackage{multirow} % Allows cells to spand in multiple rows.
\usepackage[table]{xcolor} % Allows rows to be coloured
\usepackage{tabularx} % To be able to adjust the total width of the table
%\newcolumntype{b}{X} % For wider columns
\newcolumntype{s}{>{\hsize=.6\hsize}X} % For narrower columns of indicators
\newcolumntype{S}{>{\hsize=1.1\hsize}X} % For narrower columns
\newcolumntype{a}{>{\hsize=.35\hsize}X} % For narrower columns of indicators
\newcolumntype{A}{>{\hsize=1.85\hsize}X} % For narrower columns
\newcolumntype{L}[1]{>{\RaggedRight\hsize=#1\hsize\linewidth=\hsize}X}
\usepackage{makecell} % You can make a cell with various text lines: \makecell{line1\\line2}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{xltabular} % long tabularx
%\usepackage{tabulary} % automatic column widths
%%%%%%%%%%%%%%%%%%%%%%
\usepackage{float} % To be able to use H in figures (H tells latex to put the figure exactly where the code is
\usepackage{color,soul} % To be able to highlight or make coloured text
\usepackage{afterpage} % To be able to force an image to be in the next page instead of in Cuenca
\usepackage{pdfpages} % To be able to include .pdf's, see: https://tex.stackexchange.com/questions/440005/includepdf-jumps-to-new-page-can-i-avoid-that
\usepackage{ragged2e} % To be able to use \justify and other
\sethlcolor{olive}
\DeclareRobustCommand{\hlr}[1]{{\sethlcolor{red}\hl{#1}}}
\DeclareRobustCommand{\hlp}[1]{{\sethlcolor{pink}\hl{#1}}}
\usepackage[all]{nowidow}
\usepackage{textcomp} % access \textquotesingle
\usepackage{hyperref}
%--------- What is compiled? -------------------------
\includeonly{
% titlepage,
% abstract,
% chapters/chapter1,
% chapters/chapter2,
% chapters/chapter3,
chapters/chapter4,
% chapters/chapter5,
% chapters/chapter6,
% chapters/chapter7,
% chapters/chapter8,
% chapters/chapter9,
% chapters/appendix0,
% chapters/appendix00,
% chapters/appendix1,
% chapters/appendix2
}
我想包含所有日志文件,但文本太长,我无法将其粘贴到这里。我认为这是与错误相关的部分:
[220]
! Undefined control sequence.
\UseRawInputEncoding ...tencodingname \@undefined
\let \DeclareFontEncoding@...
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Missing \endcsname inserted.
<to be read again>
\let
l.342
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing \endcsname inserted.
<to be read again>
\let
l.342
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing \endcsname inserted.
<to be read again>
\let
l.342
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Undefined control sequence.
<argument> \@undefined
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
\UseRawInputEncoding ...tencodingname \@undefined
\let \DeclareFontEncoding@...
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Missing \endcsname inserted.
<to be read again>
\let
l.342
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing \endcsname inserted.
<to be read again>
\let
l.342
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing \endcsname inserted.
<to be read again>
\let
l.342
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Undefined control sequence.
<argument> \@undefined
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Package inputenc Error: Unicode character € (U+0080)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.342
You may provide a definition with
\DeclareUnicodeCharacter
! Undefined control sequence.
<argument> ...ont encoding \let }\global \def \T@
\let \endcsname {\protect ...
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
<argument> ...tinue without it.}}\global \def \M@
\let \endcsname {\def 7{7}...
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Package inputenc Error: Invalid UTF-8 byte "9C.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.342
The document does not appear to be in UTF-8 encoding.
Try adding \let utf8\let \GenericError { }{LaTeX Error: Can be us
ed only in preamble}{See the LaTeX manual or LaTeX Companion for explanation.}{
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.}\GenericInfo {(Font) }{LaTeX
Font Info: Redeclaring font encoding \let }\global \def \let \endcsname {\G
enericError { }{LaTeX Error: Can be used only in preamble}{See th
e LaTeX manual or LaTeX Companion for explanation.}{Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.}}\global \def \let \endcsname {\def 7{7}}
\xdef PD1{\let }\@tempcnta =1 \def \iterate {\catcode \@tempcnta =15 \advance \
@tempcnta \@ne }\iterate \let \iterate \relax \catcode 0=15 \catcode 9=10 \catc
ode 10=12 \catcode 12=13 \catcode 13=5 \@tempcnta =128 \def \iterate {\catcode
\@tempcnta =12 \advance \@tempcnta \@ne }\iterate \let \iterate \relax as the f
irst line of the file
or specify an encoding such as \GenericError { }{LaTeX Error: Can
be used only in preamble}{See the LaTeX manual or LaTeX Companion for explanat
ion.}{Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.}[latin1]{inputenc}
in the document preamble.
Alternatively, save the file in UTF-8 using your editor or another tool
! Package inputenc Error: Unicode character € (U+0080)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.342
You may provide a definition with
\DeclareUnicodeCharacter
! Undefined control sequence.
<argument> ...ont encoding \let }\global \def \T@
\let \endcsname {\protect ...
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
<argument> ...tinue without it.}}\global \def \M@
\let \endcsname {\def 7{7}...
l.342
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Package inputenc Error: Invalid UTF-8 byte "9D.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.342
The document does not appear to be in UTF-8 encoding.
Try adding \let utf8\let \GenericError { }{LaTeX Error: Can be us
ed only in preamble}{See the LaTeX manual or LaTeX Companion for explanation.}{
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.}\GenericInfo {(Font) }{LaTeX
Font Info: Redeclaring font encoding \let }\global \def \let \endcsname {\G
enericError { }{LaTeX Error: Can be used only in preamble}{See th
e LaTeX manual or LaTeX Companion for explanation.}{Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.}}\global \def \let \endcsname {\def 7{7}}
\xdef PD1{\let }\@tempcnta =1 \def \iterate {\catcode \@tempcnta =15 \advance \
@tempcnta \@ne }\iterate \let \iterate \relax \catcode 0=15 \catcode 9=10 \catc
ode 10=12 \catcode 12=13 \catcode 13=5 \@tempcnta =128 \def \iterate {\catcode
\@tempcnta =12 \advance \@tempcnta \@ne }\iterate \let \iterate \relax as the f
irst line of the file
or specify an encoding such as \GenericError { }{LaTeX Error: Can
be used only in preamble}{See the LaTeX manual or LaTeX Companion for explanat
ion.}{Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.}[latin1]{inputenc}
in the document preamble.
Alternatively, save the file in UTF-8 using your editor or another tool
[221] [222] [223
]
Appendix E.
[273
]
编辑:如果我注释掉,错误就会消失\printbibliography
,所以它一定与此命令有关。但这没有任何意义,因为之前它运行良好,对于其他章节(单独的文件)以及同一章节也是如此。