![如何修复 Latex 长时间运行的编译时错误](https://linux22.com/image/449009/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%20Latex%20%E9%95%BF%E6%97%B6%E9%97%B4%E8%BF%90%E8%A1%8C%E7%9A%84%E7%BC%96%E8%AF%91%E6%97%B6%E9%94%99%E8%AF%AF.png)
我正在尝试用 latex 写一篇论文。该文档的完整代码如下所示:
% \documentclass[jou]{apa} %use "twoside for two-sided numbering
% %added by me
% \usepackage{subcaption}
% \usepackage{mathptmx}
% \usepackage{gsuthesisETD,multicol,amssymb,amsthm,amsmath,graphicx,geometry}
% %%%MY additions
% \usepackage{caption}
% %for bibliography
% \usepackage[english]{apacite}
% \usepackage[utf8]{inputenc}
% \usepackage{csquotes, ellipsis}
% \MakeOuterQuote{"}
% \usepackage{xurl}
% \usepackage{listings}
% \usepackage{algorithm}
% \lstset{
% basicstyle=\small\ttfamily,
% columns=flexible,
% breaklines=true
% }
% \geometry{letterpaper,left=1.3 true in, right=1.2 true in, top=1in,
% headheight =12pt, headsep =20pt, footskip =1in}
% \usepackage[colorinlistoftodos]{todonotes}
% \usepackage{indentfirst}
% %Toggles: "true" or "false"
% \tablespagetrue
% \figurespagetrue
% \symbolpagefalse
% \dedicationpagetrue
% \acknowledgmentspagetrue
% \copyrightpagetrue
% \sectionnumberstrue
% % Fill in These Fields
% \title{Design and Implementation of an Automatic Generator for Word-Matching Interactives}
% \author{Evan M. Gertis}
% \degree{Master of Science}
% \major{Computer Science}
% \dept{Department of Computer Science}
% \school{Georgia Southern University}
% \thesistype{Thesis}
% \graduatedate{May 2022}
% \graduateyear{2022}
% \keywords{Automatic Programming, Computer Science Education, Online learning, Programming Synthesis, Word Matching}
% \cochair=0 %choose 1 if you have a co-chair
% \symbolfile{symbols} % symbols go in the file "symbols.tex"
% %\captiontype=1 %not used at this time
% \appendname{APPENDICES} % or APPENDIX for just one
% \tocheader{Appendices}
% \mybibname{REFERENCES}
% \def\deansname{Dean's name} % Do NOT use "Dr." here.
% \committeechair{Dr. Daniel Liang} % No. Dr.
% \committeecochair{Co-advisor} % No Dr.
% \memberC{Andrew Allen}
% \memberB{Ryan Florin}
% \degreeA{B.S. Physics, University of North Carolina at Chapel Hill, 2017}
% %%%%%%%%%%%%%%%% MACROS %%%%%%%%%%%%%%%%%%%%%%%
% %\newtheorem{theorem}{Theorem}[section]
% \newtheorem{theorem}{Theorem}[chapter]
% \newtheorem{lemma}[theorem]{Lemma}
% \newtheorem{cor}[theorem]{Corollary}
% \newtheorem{rmk}[theorem]{Remark}
% \newtheorem{prop}[theorem]{Proposition}
% \newtheorem{example}[theorem]{Example}
% \newtheorem{dfn}[theorem]{Definition}
% \newtheorem{ass}[theorem]{Assumption}
% \newcommand{\RR}{{\mathbb R}}
% \newcommand{\CC}{{\mathbb C}}
% \newcommand{\ZZ}{{\mathbb Z}}
% \newcommand{\NN}{{\mathbb N}}
% \newcommand{\rank}{{\rm rank}}
% \usepackage{dirtytalk}
% % \usepackage[options ]{algorithm2e}
% %%%%%%%%%%%%%%%%%%%%% Main Document %%%%%%%%%%%%%%%%%%%
% % \makeatletter
% % \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
% % \if@mainmatter
% % \refstepcounter{chapter}%
% % \typeout{\@chapapp\space\thechapter.}%
% % \addcontentsline{toc}{chapter}%
% % {\protect\numberline{\thechapter}#1}%
% % \else
% % \addcontentsline{toc}{chapter}{#1}%
% % \fi
% % \chaptermark{#1}%
% % % \addtocontents{lof}{\protect\addvspace{10\p@}}% NEW
% % % \addtocontents{lot}{\protect\addvspace{10\p@}}% NEW
% % \if@twocolumn
% % \@topnewpage[\@makechapterhead{#2}]%
% % \else
% % \@makechapterhead{#2}%
% % \@afterheading
% % \fi}
% \begin{document}
% % Version: \today % Comment this out for final version
% \input{abstract}
% \titlep
% \copyrightpage %optional (comment out if not used)
% \approvalpage
% \input{dedication} %optional
% \input{acknowledgments} %optional
% \tableofcontents
% \include{Chapter-1}
% \include{Chapter-2}
% \include{Chapter-3}
% \include{Chapter-4}
% \include{Chapter-5}
% \include{Chapter-6}
% \include{8-Bib}
% \include{appendix}
% %\scriptsize
% %\bibliographystyle{IEEEtran}
% %\bibliography{refs}
% % \renewcommand{\bibsetup}{\thispagestyle{myheadings}}
% % \printbibliography
% \end{document}
% OLD TEMPLATE PROVIDED BY GSU
\documentclass[12pt,oneside]{report} %use "twoside for two-sided numbering
%added by me
\usepackage{subcaption}
\usepackage{mathptmx}
\usepackage{gsuthesisETD,multicol,amssymb,amsthm,amsmath,graphicx,geometry}
%%%MY additions
\usepackage{caption}
%for bibliography
\usepackage[english,backend=biber,style=apa,natbib=true]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes, ellipsis}
\MakeOuterQuote{"}
\usepackage{xurl}
\usepackage{listings}
\usepackage{algorithm}
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true
}
\geometry{letterpaper,left=1.3 true in, right=1.2 true in, top=1in,
headheight =12pt, headsep =20pt, footskip =1in}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{indentfirst}
%Toggles: "true" or "false"
\figurespagetrue
\symbolpagefalse
\dedicationpagetrue
\acknowledgmentspagetrue
\copyrightpagetrue
\sectionnumberstrue
% Fill in These Fields
\title{Design and Implementation of an Automatic Generator for Word Matching Interactives}
\author{Evan M. Gertis}
\degree{Master of Science}
\major{Computer Science}
\dept{Department of Computer Science}
\school{Georgia Southern University}
\thesistype{Thesis}
\graduatedate{May 2022}
\graduateyear{2022}
\keywords{Automatic programming, Computer science education, Online learning, programming synthesis, Word matching}
\cochair=0 %choose 1 if you have a co-chair
\symbolfile{symbols} % symbols go in the file "symbols.tex"
%\captiontype=1 %not used at this time
\appendname{APPENDICES} % or APPENDIX for just one
\tocheader{Appendices}
\mybibname{REFERENCES}
\def\deansname{Dean's name} % Do NOT use "Dr." here.
\committeechair{Daniel Liang} % No. Dr.
\committeecochair{Co-advisor} % No Dr.
\memberC{Andrew Allen}
\memberB{Ryan Florin}
\degreeA{B.S., University of North Carolina at Chapel Hill, 2017}
%%%%%%%%%%%%%%%% MACROS %%%%%%%%%%%%%%%%%%%%%%%
%\newtheorem{theorem}{Theorem}[section]
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{cor}[theorem]{Corollary}
\newtheorem{rmk}[theorem]{Remark}
\newtheorem{prop}[theorem]{Proposition}
\newtheorem{example}[theorem]{Example}
\newtheorem{dfn}[theorem]{Definition}
\newtheorem{ass}[theorem]{Assumption}
\newcommand{\RR}{{\mathbb R}}
\newcommand{\CC}{{\mathbb C}}
\newcommand{\ZZ}{{\mathbb Z}}
\newcommand{\NN}{{\mathbb N}}
\newcommand{\rank}{{\rm rank}}
\usepackage{dirtytalk}
% \usepackage[options ]{algorithm2e}
%%%%%%%%%%%%%%%%%%%%% Main Document %%%%%%%%%%%%%%%%%%%
% \makeatletter
% \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
% \if@mainmatter
% \refstepcounter{chapter}%
% \typeout{\@chapapp\space\thechapter.}%
% \addcontentsline{toc}{chapter}%
% {\protect\numberline{\thechapter}#1}%
% \else
% \addcontentsline{toc}{chapter}{#1}%
% \fi
% \chaptermark{#1}%
% % \addtocontents{lof}{\protect\addvspace{10\p@}}% NEW
% % \addtocontents{lot}{\protect\addvspace{10\p@}}% NEW
% \if@twocolumn
% \@topnewpage[\@makechapterhead{#2}]%
% \else
% \@makechapterhead{#2}%
% \@afterheading
% \fi}
\begin{document}
% Version: \today % Comment this out for final version
\input{abstract}
\titlep
\copyrightpage %optional (comment out if not used)
\approvalpage
\input{dedication} %optional
\input{acknowledgments} %optional
\tableofcontents
\include{Chapter-1}
\include{Chapter-2}
\include{Chapter-3}
\include{Chapter-4}
\include{Chapter-5}
\include{Chapter-6}
\include{8-Bib}
\include{appendix}
%\scriptsize
%\bibliographystyle{IEEEtran}
%\bibliography{refs}
% \renewcommand{\bibsetup}{\thispagestyle{myheadings}}
% \printbibliography
\end{document}
预期:该文档应编译并生成所需的 pdf。
任何有关此问题的帮助都将不胜感激。这是我第一次遇到此错误。
Latex 支持甚至不知道这里该做什么。’
答案1
这对于评论来说太长了。
不幸的是,一些 LaTeX 编译错误可能会完全阻止 latexmk 构建过程,从而导致超时。为了调试此类错误可能需要
latexmkrc
在项目顶层添加一个名为 (不带任何文件扩展名)的文件,其中仅包含以下三行:$pdflatex = 'pdflatex --halt-on-error %O %S'; $lualatex = 'lualatex --halt-on-error %O %S'; $xelatex = 'xelatex --halt-on-error %O %S';
这样,编译就会在出现第一个编译错误消息时停止(尽管不会生成任何输出预览)。然后,您可以调试并更正遇到的每个错误,直到项目没有错误;然后您可以删除此 latexmkrc。(如果即使使用此 latexmkrc 文件,您仍然会遇到超时,则主要原因可能是前面部分讨论的问题之一。)
完成此操作后,也许您应该逐一注释掉各章节,然后尝试单独编译每个章节以发现错误,例如像这样:
\begin{document}
% Version: \today % Comment this out for final version
% \input{abstract}
% \titlep
% \copyrightpage %optional (comment out if not used)
% \approvalpage
% \input{dedication} %optional
% \input{acknowledgments} %optional
% \tableofcontents
\include{Chapter-1}
% \include{Chapter-2}
% \include{Chapter-3}
% \include{Chapter-4}
% \include{Chapter-5}
% \include{Chapter-6}
% \include{8-Bib}
% \include{appendix}
\end{document}
尝试对文档的每一部分执行此操作,即章节、参考书目、附录、摘要、献词、致谢、标题页、版权页、批准页等......
希望能帮助到你。
答案2
OP 将问题缩小到以下几点:
%for bibliography
\usepackage[english,backend=biber,style=apa,natbib=true]{babel}
这似乎是 babel 和 biblatex (或可能是 apacite) 的混合选项,因此应该
\usepackage[english]{babel}
\usepackage[backend=biber,style=apa,natbib=true]{biblatex}
虽然 LaTeX 允许你将多个包合并到一个\usepackage
命令中,但你很少这样做(也许是 AMS 包)。我会将相关的\usepackage
命令放在源代码中彼此靠近的位置。这样可以防止你将选项传递给不需要的包,并防止你删除所需的包。
答案3
我找到了问题所在。我的问题源于 biber 包的使用。
%for bibliography
\usepackage[english,backend=biber,style=apa,natbib=true]{babel}
我不得不完全删除这个包并手动实现 APA 引用。