我正尝试通过为我的大学学习创建自定义论文类来尝试一些更高级的 LaTeX,因为现有示例有些过时,并且不符合当前样式指南的规范。作为附加方面,我添加了一些选项,允许我根据我是否将该类用于个人项目或正式论文来稍微更改标题页的措辞。
我遇到了一个问题,重新\maketitle
定义\end
了center
被截断并渗透到整个文档中。
main.tex
:
\documentclass[project]{diythesis}
\title{Construction of a Difficult, Error-Prone LaTeX Thesis Class}
\author{Not Another Author}
\degreeName{Bachelor of Science}
\majorName{Unknown Studies}
\date{August 2022}
\begin{document}
\maketitle
\section{Introduction}
blah blah blah
\end{document}
diythesis.cls
:
% --------------------------------------------------------------------------- %
% Configure basic class information and options. %
% --------------------------------------------------------------------------- %
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{diythesis}[2022/08/16]
\RequirePackage{etoolbox}
\newtoggle{project}
\newtoggle{thesis}
\newtoggle{strict}
\DeclareOption{project}{\toggletrue{project}\togglefalse{thesis}}
\DeclareOption{thesis}{\toggletrue{thesis}\togglefalse{project}}
\DeclareOption{strict}{\toggletrue{strict}}
\ProcessOptions\relax
\LoadClass[12pt,titlepage,twoside]{report}
\RequirePackage{fontspec,geometry,fancyhdr,afterpage,graphicx}
\RequirePackage{amsmath,amssymb,amsbsy}
\RequirePackage{dcolumn,tocloft}
% --------------------------------------------------------------------------- %
% Configure basic page geometry and XeLaTeX font options. %
% --------------------------------------------------------------------------- %
\geometry{
top = 1.00in,
left = 1.25in,
right = 1.25in,
bottom = 1.00in
}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}
\newcommand{\doublespace} {
\renewcommand{\baselinestretch}{1.66}\small\normalsize
}
\newcommand{\oneandhalfspace} {
\renewcommand{\baselinestretch}{1.24}\small\normalsize
}
\newcommand{\singlespace} {
\renewcommand{\baselinestretch}{0.9}\small\normalsize
}
% --------------------------------------------------------------------------- %
% Redefine the titlepage per the graduate school formatting manual. %
% Add additional options and commands to allow the configuration of the %
% titlepage as a self-study project rather than a required dissertation. %
% --------------------------------------------------------------------------- %
\newlength{\fiveblanklines}\setlength{\fiveblanklines}{0.7 in}
\newlength{\tenblanklines}\setlength{\tenblanklines}{1.5 in}
\makeatletter
\newcommand{\defensemonth}[1]{\renewcommand{\@defensemonth}{#1}}
\newcommand{\@defensemonth}{\tt$\backslash$\string defensemonth}
\newcommand{\gradmonth}[1]{\renewcommand{\@gradmonth}{#1}}
\newcommand{\@gradmonth}{\tt$\backslash$\string gradmonth}
\newcommand{\gradyear}[1]{\renewcommand{\@gradyear}{#1}}
\newcommand{\@gradyear}{\tt$\backslash$\string gradyear}
\newcommand{\chair}[1]{\renewcommand{\@chair}{#1}}
\newcommand{\@chair}{\tt$\backslash$\string chair}
\newcommand{\memberOne}[1]{\renewcommand{\@memberOne}{#1}}
\newcommand{\@memberOne}{\tt$\backslash$\string memberOne}
\newcommand{\memberTwo}[1]{\renewcommand{\@memberTwo}{#1}}
\newcommand{\@memberTwo}{\tt$\backslash$\string memberTwo}
\newcommand{\memberThree}[1]{\renewcommand{\@memberThree}{#1}}
\newcommand{\@memberThree}{\tt$\backslash$\string memberThree}
\newcommand{\memberFour}[1]{\renewcommand{\@memberFour}{#1}}
\newcommand{\@memberFour}{\tt$\backslash$\string memberFour}
\newcommand{\degreeName}[1]{\renewcommand{\@degreeName}{#1}}
\newcommand{\@degreeName}{\tt$\backslash$\string degreeName}
\newcommand{\majorName}[1]{\renewcommand{\@majorName}{#1}}
\newcommand{\@majorName}{\tt$\backslash$\string majorName}
\newcommand{\paperType}[1]{\renewcommand{\@paperType}{#1}}
\newcommand{\@paperType}{\tt$\backslash$\string paperType}
\renewcommand{\maketitle}{
\doublespace
\begin{center}
{\MakeUppercase\@title} \\ by \\ \@author \\
\vspace{\fiveblanklines}
\iftoggle{thesis}{
A \@paperType Presented in Partial Fulfillment \\
of the Requirement for the Degree \\
\@degreeName \\
}
\iftoggle{project}{
An Investigatory Project Supplementing the Studies\\
of the \@degreeName Degree in \\
\@majorName \\
}
\end{center}
\clearpage
}
\makeatother
错误发生在 75-92 行之间,其中\maketitle
被重新定义。XeLaTeX 报告的特定错误是典型的神秘 LaTeX 风格“ ”。鉴于该语句在第 90 行上清晰可见,\begin{center} on input line 10 ended by \end{document}
我不太确定该如何处理。\end{center}
答案1
你误用了\iftoggle
它
\iftoggle{name}{yes}{no}
所以\end
被视为无参数。因此在这种情况下,latex 消息非常清晰准确。