编译书籍文档类时出错

编译书籍文档类时出错

这不是我第一次与documentclass。显然,我没有做任何不同的事情,但这次我收到了一个奇怪的错误消息:我当然有一个主文档和一系列在不同文件上的章节。如果我从主文档编译文档,一切都会顺利进行,我会得到一个包含所有章节的漂亮 .pdf。但是,如果我从其中一个章节进行编译,我经常(但并非总是)会得到一系列错误。这没什么大不了的,因为我可以返回主文档进行编译,一切都会得到修复,但它不应该以这种方式运行,而且在我以前的书中从未出现过这种情况。

这是我的主要文件:


    \documentclass[a5paper,12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{indentfirst}



\begin{document}

\author{Me}
\title{My life}
\date{January 2021}

\frontmatter
\maketitle
\tableofcontents

\mainmatter
\include{./TeX_files/capitolo01}
\include{./TeX_files/capitolo2}

%la "casa"
%a scuola (Aldo Moro, Campanile boia)
%i libri

\backmatter
% bibliography, glossary and index would go here.

\end{document}

章节格式很简单:

\chapter{Capitolo primo}
text

以及错误信息:

Undefined control sequence. \chapter
Missing \begin{document}. \chapter{C
Corrupted NFSS tables. ...qualcuno: scrivo a un ipotetico "voi" ma è
Missing \begin{document}. P
Missing \begin{document}. S
Missing \begin{document}. I
Missing \begin{document}. P
Emergency stop.
Font shape `/cmr/m/n' undefined(Font) using `/cmr/m/n' instead
Font shape `/cmr/m/n' undefined(Font) using `OT1/cmr/m/n' instead
Overfull \hbox (20.0pt too wide) in paragraph
Overfull \hbox (9.44446pt too wide) in paragraph
Overfull \hbox (6.80557pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.55557pt too wide) in paragraph
Overfull \hbox (4.44444pt too wide) in paragraph
Overfull \hbox (4.44444pt too wide) in paragraph
Overfull \hbox (4.44444pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.55557pt too wide) in paragraph
Overfull \hbox (5.55557pt too wide) in paragraph
Overfull \hbox (5.55557pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (20.0pt too wide) in paragraph
Overfull \hbox (4.44444pt too wide) in paragraph
Overfull \hbox (4.44444pt too wide) in paragraph
Overfull \hbox (4.44444pt too wide) in paragraph
Overfull \hbox (20.0pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (2.77779pt too wide) in paragraph
Overfull \hbox (2.77779pt too wide) in paragraph
Overfull \hbox (20.0pt too wide) in paragraph
Overfull \hbox (5.00002pt too wide) in paragraph
Overfull \hbox (2.77779pt too wide) in paragraph
Overfull \hbox (5.55557pt too wide) in paragraph
Overfull \hbox (5.55557pt too wide) in paragraph

看起来它不明白该章节是与主文档相链接的。

答案1

如果我编写其中一章...

您无法单独编译这些章节,因为它们没有文档类和使它们成为有效 Latex 文档的其余前言。前言定义了类似的命令\chapter,这就是您收到undefined command sequence错误的原因。

因此,您无法运行 pdflatex capitolo01.tex并获得仅一章的格式良好的版本。如果您的编辑器提供使用 latex 处理当前文件,则它需要处理整本书,而不是一次只处理一章。

如果您只想预览一章,您可以创建一个简短的存根主文件,其中包含 documentclass 和其余的序言,但只导入一章。或者您可以使用命令\includeonly从主文档中选择特定章节。但由于计算机可以在眨眼间处理整本书,因此这样做的好处有限。

答案2

谜题解开了!我已将目录复制到其他位置,并从旧目录中打开了一章。这就是导致无法正确编译该特定章节的原因。

相关内容