LaTeX 错误:只能在序言中使用,尽管所有包都在序言中定义

LaTeX 错误:只能在序言中使用,尽管所有包都在序言中定义

我在这个平台上发现了许多类似的错误,但我的问题有点不同。有一个 main.tex 文件,其中包含两个来自外部源的文件,并且不包含\documentclass{article}。但是,Latex 给出了错误并且没有给出正确的输出。

.\chapters/abstract_v1.tex:1: LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation. 
Type H ≤return> for immediate help.
l.3 \begin{document}
?

以下是我在文件中包含的行main.tex

\documentclass[12pt]{report}
\usepackage{hyperref}
\usepackage{natbib}
\usepackage{xpatch}
\usepackage{url}
\usepackage{enumitem}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{caption}
\usepackage{subcaption}
\usepackage[a4paper, width=150mm, top=25mm, bottom=25mm, bindingoffset=6mm]{geometry}
\usepackage{ragged2e}


\makeatletter
\newcommand\NoWarnNat{
\xpatchcmd{\NAT@citexnum}{\PackageWarning}{\let\PackageWarning\@gobbletwo\PackageWarning}{}{}
\xpatchcmd{\NAT@citex}{\PackageWarning}{\let\PackageWarning\@gobbletwo\PackageWarning}{}{}
\xpatchcmd{\nocite}{\PackageWarning}{\let\PackageWarning\@gobbletwo\PackageWarning}{}{}
}
\makeatother


\NoWarnNat

%\author{Python Buddha}
\date{02 March 2020}

\begin{document}

\input{titlepage}

\pagenumbering{roman}

\chapter*{Dedication}


\addcontentsline{toc}{chapter}{Dedication}

\chapter*{Declaration}

\addcontentsline{toc}{chapter}{Declaration}

\cleardoublepage
\tableofcontents

\listoffigures


\cleardoublepage


\chapter*{Abstract}
\input{chapters/abstract_v3}
\addcontentsline{toc}{chapter}{Abstract}

\chapter*{Foreword}
\input{chapters/abstract_v1}
\addcontentsline{toc}{chapter}{Foreword}

\chapter*{Introduction}
\input{chapters/introduction_v2}
\addcontentsline{toc}{chapter}{Introduction}

\cleardoublepage

\pagenumbering{arabic}

\chapter{Add Language identifier to highlight code}
\input{chapters/chapter1_v1}

\chapter{Put Returns between paragraphs}
\input{chapters/chapter2_v1}

\chapter{For Linebreak add 2 spaces at end}
\input{chapters/chapter3_v1}

\chapter{Indent code by 4 spaces}
\input{chapters/chapter4_v1}

\chapter{To make Links}
\input{chapters/chapter5_v1}

\chapter*{Formatting Help}
\addcontentsline{toc}{chapter}{Formatting Help}

其他文件如下所示:

abstract_v2.tex


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\\


`abstract_v1.tex`

```\chapter*{Foreword}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\\

相关内容