我正在为我的大学制作硕士/博士论文模板,我正在根据从 sharelatex 中的论文模板中学到的知识进行构建。但是,我遇到了一个错误,导致我无法编译。我做了一些更改,导致它停止编译,删除了错误,但仍然无法编译...所以,有人能告诉我我做错了什么吗?我正在从 .cls 和 .tex 文档中粘贴我认为相关的内容。
目标格式为此处引用的链接中的 UML 样式指南 PDF 第 16 和 17 页
在 UMLThesis.cls(如下)中,使用 \committeemembers 时出现问题。注释掉这些行可以编译,但我仍然收到错误,其中某处有“缺少 $”,还有另一个错误,提示“没有要结束的行”。编译需要一对额外的文件(空白),称为“lstpatch.sty”和“vector.sty”。我不知道为什么需要它们。
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{UMLThesis}
[2007/22/02 v1.0
LaTeX document class]
\def\baseclass{book}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\baseclass}}
\def\@checkoptions#1#2{
\edef\@curroptions{\@ptionlist{\@currname.\@currext}}
\@tempswafalse
\@tfor\@this:=#2\do{
\@expandtwoargs\in@{,\@this,}{,\@curroptions,}
\ifin@ \@tempswatrue \@break@tfor \fi}
\let\@this\@empty
\if@tempswa \else \PassOptionsToClass{#1}{\baseclass}\fi
}
\@checkoptions{11pt}{{10pt}{11pt}{12pt}}
%\PassOptionsToClass{a4paper}{\baseclass}
\ProcessOptions\relax
\LoadClass{\baseclass}
\newcommand{\supervisorSig}[1]{%
\justifying
Signature of Thesis Supervisor: \xleaders\hbox{\underline{ }}\hfill\kern0pt \\
\newlength{\remaining}
\setlength{\remaining}{\textwidth-\widthof{Name Typed:\quad\quad\quad\quad#1}}
Name Typed:\quad\quad\quad\quad\underline{#1\hspace{\remaining}}\par \\
\vspace{\baselineskip}
Signatures of Other Thesis Committee Members: \\}
\newcommand{\committeeMember}[1]{%
\justifying
Committee Member Signature: \xleaders\hbox{\underline{ }}\hfill\kern0pt \\
%\newlength{\remaining}
%\setlength{\remaining}{\textwidth-\widthof{Name Typed:\quad\quad\quad\quad#1}}
%Name Typed:\quad\quad\quad\quad\underline{#1\hspace{\remaining}}
#1}
\newcommand{\prevDegree}[3]{%
#1 \uppercase{#2} \left( #3 \right)}
\newcommand\SignaturePage[6]{%
\thispagestyle{empty}
\singlespacing
\vspace*{1 in}
\uppercase{%
\centering
% Title of thesis
\large{#1} \\
\vspace{2\baselineskip} \\
%Author section, and previous degrees
\normalsize{BY \vspace{2\baselineskip} \\ \MakeUppercase{\authornames} \\ #2 \vspace{3\baselineskip} \\
submitted in partial fulfillment of the requirements \\
% degree title
for the degree of \MakeUppercase{\degreeName} \\
% department name
\MakeUppercase{\deptName} \\
\MakeUppercase{\univName}}}
\vfill
\small{%
\newlength{\authline}
\setlength{\authline}{3.75 in-\widthof{\small{Author: }}}
\newlength{\autharea}
\setlength{\autharea}{\widthof{\small{Author: }}+\authline}
\newlength{\dateline}
\setlength{\dateline}{5.75 in-\autharea-\widthof{\small{Date: }}}
%\underline{#1\hspace*{\remaining}}\par
\justifying
Signature of \\
Author: \underline{\hspace{\authline}}Date: \underline{\hspace{\dateline}}
\\
#3
\committeeMember{#4}
\committeeMember{#5}
\committeeMember{#6}}
\cleardoublepage}
\newcommand*{\authors}[1]{\newcommand{\authornames}{#1}}
\newcommand*{\faculty}[2]{\newcommand{\facName}{#1}\newcommand{\facTitle} {#2}}
\newcommand*{\degree}[2]{\newcommand{\degreeNameShort}{#1}\newcommand{\degreeName}{#2}}
\newcommand*{\department}[1]{\newcommand{\deptName}{#1}}
\newcommand*{\university}[1]{\newcommand{\univName}{#1}}
\usepackage{setspace}
\usepackage{vmargin}
\doublespacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\setmarginsrb { 1.5in} % left margin
{ 0.6in} % top margin
{ 1.0in} % right margin
{ 1.0in} % bottom margin
{ 20pt} % head height
{0.25in} % head sep
{ 9pt} % foot height
{ 0.3in} % foot sep
\raggedbottom
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{amsmath,amsfonts,amssymb,amscd,amsthm,xspace,bm}
\usepackage[centerlast,small,sc]{caption}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[scriptsize]{subfigure}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{listings}
\usepackage{lstpatch}
\usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=false,colorlinks,linkcolor={blue},citecolor={blue},urlcolor={red},pdfstartview={FitV},unicode,breaklinks=true]{hyperref}
\usepackage{longtable}
\usepackage{tikz}
\usepackage[square, numbers, comma, sort&compress]{natbib} % Use the "Natbib" style for the references in the Bibliography
\usepackage{verbatim} % Needed for the "comment" environment to make LaTeX comments
\usepackage{vector} % Allows "\bvec{}" and "\buvec{}" for "blackboard" style bold vectors in maths
\hypersetup{urlcolor=blue, colorlinks=true} % Colours hyperlinks in blue, but this can be distracting if there are many links.
\usepackage{titlesec}
\usepackage{lipsum,calc,xcolor}
\usepackage{array, makecell} % <--- changed
\setcellgapes{5pt}
\usepackage{tikz}
\usepackage{xfrac}
\newcolumntype{M}{>{$}c<{$}}
\usepackage{algorithm2e}
\renewcommand*{\algorithmautorefname}{Algorithm}
\usepackage{ragged2e}
以下是 UMLThesis.tex,错误归因于 \SignaturePage 的第 4 个输入选项
\documentclass[letterpaper, 12pt, oneside]{UMLThesis}
\begin{document}
\frontmatter % Begin Roman style (i, ii, iii, iv...) page numbering
% Set up the Title Page
\title {This is a formattable \\ thesis title, and seems to \\ work without error}
\authors {My name} %call with \authorNames
\faculty {My PI}{King professor guy} %call with \facName and \facTitle
\department {Department within College} %call with \depName
\degree {M.S.}{Masters of Science} %call with \degreeNameShort and \degreeName
\university {University of Massachusetts Lowell} %call with \univName
\setstretch{1.3} % It is better to have smaller font and larger line spacing than the other way round
% Define the page headers using the FancyHdr package and set up for one-sided printing
\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header
\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers
\SignaturePage{
% Input the name of the title, using '\\' as a manual linebreak
Manually labeling the \\ manually spaced \\ title page
}{
% Input your previous degrees from least to most prestigious using the \prevdegree{abbreviation}{university}{year} function as show, and '\\' as manual line breaks between each degree
\prevDegree{B.S.}{University of Massachusetts Lowell}{2014}
}{
% Create the signatures
\supervisorSig{\facName, Ph.D.} % Use this for a master's thesis
%\dissertationSig{\facName, Ph.D.} % Use this for a doctorate thesis
}{
% First committee member
\facName, Ph.D.
}{
% Second committee member
Committee member 2, Ph.D.
}{
% Third committee member
Committee member 3, Ph.D.
}
\clearpage % Declaration ended, now start a new page
\end{document}
辅助问题:
我是否需要通过“\LoadClass{\baseclass}”完成整个“\def\baseclass{book}”操作?
如何让第一页不在前言中列为“i”?这一页就像封面,而不是真正的第一页。
为什么将 \newcommand{\SignaturePage} 中的 '\' 更改为 '\newline' 会导致居中混乱?如果这很重要的话,文档的左边距为 1.5 英寸
答案1
lstpatch
关于和的错误vector
是由于
\usepackage{lstpatch}
\usepackage{vector} % Allows "\bvec{}" and "\buvec{}" for "blackboard" style bold vectors in maths
它们大概是本地可用的类,但是如果您不使用它们,则只需删除这些行即可。(通常,您应该删除所有不使用的包,这样可以使类更接近基类book
。例如,希望您不会lipsum
在实际文档中使用它们。
切勿\\
在段落末尾使用(会产生错误的输出并警告水平盒子未满)或在垂直模式下使用(会产生错误)。
}\par \\
由于 ,所以\\
会一直处于垂直模式,因此\par
会出现错误。只需删除\\
那里的 即可。
size 命令不接受参数,因此诸如\small{Author: }
括号之类的使用不会产生任何作用,并且\small
会延伸到文档末尾,除非(如此处)存在一些限制范围的外部环境或组。
关于缺失的数学错误$
是由于\left
这里使用的不合适,这是一个数学模式命令,并且您不希望在这里使用缩放括号。
不严格,而且有错误,但在另一个宏中使用是不好的做法\newlength
,所以我将声明移到了外面。实际上,您只使用一次宏,因此不会造成太大的危害,但一般来说,您只想分配一次寄存器,而不是每次使用宏时都分配寄存器。
对类进行这些更改后,它运行起来没有错误
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{UMLThesis}
[2007/22/02 v1.0
LaTeX document class]
\def\baseclass{book}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\baseclass}}
\def\@checkoptions#1#2{
\edef\@curroptions{\@ptionlist{\@currname.\@currext}}
\@tempswafalse
\@tfor\@this:=#2\do{
\@expandtwoargs\in@{,\@this,}{,\@curroptions,}
\ifin@ \@tempswatrue \@break@tfor \fi}
\let\@this\@empty
\if@tempswa \else \PassOptionsToClass{#1}{\baseclass}\fi
}
\@checkoptions{11pt}{{10pt}{11pt}{12pt}}
%\PassOptionsToClass{a4paper}{\baseclass}
\ProcessOptions\relax
\LoadClass{\baseclass}
\newcommand{\supervisorSig}[1]{%
\justifying
Signature of Thesis Supervisor: \xleaders\hbox{\underline{ }}\hfill\mbox{}\par
\newlength{\remaining}
\setlength{\remaining}{\textwidth-\widthof{Name Typed:\quad\quad\quad\quad#1}}
Name Typed:\quad\quad\quad\quad\underline{#1\hspace{\remaining}}\par
\vspace{\baselineskip}
Signatures of Other Thesis Committee Members: \par}
\newcommand{\committeeMember}[1]{%
\justifying
Committee Member Signature: \xleaders\hbox{\underline{ }}\hfill\mbox{}\par
%\newlength{\remaining}
%\setlength{\remaining}{\textwidth-\widthof{Name Typed:\quad\quad\quad\quad#1}}
%Name Typed:\quad\quad\quad\quad\underline{#1\hspace{\remaining}}
#1}
\newcommand{\prevDegree}[3]{%
#1 \uppercase{#2} (#3)}
\newlength{\authline}
\newlength{\autharea}
\newlength{\dateline}
\newcommand\SignaturePage[6]{%
\thispagestyle{empty}
\singlespacing
\vspace*{1 in}
\uppercase{%
\centering
% Title of thesis
\large{#1} \par
\vspace{2\baselineskip} \par
%Author section, and previous degrees
\normalsize{BY \vspace{2\baselineskip} \par \MakeUppercase{\authornames} \par #2 \vspace{3\baselineskip} \par
submitted in partial fulfillment of the requirements \par
% degree title
for the degree of \MakeUppercase{\degreeName} \par
% department name
\MakeUppercase{\deptName} \par
\MakeUppercase{\univName}}}
\vfill
{\small
\setlength{\authline}{3.75 in-\widthof{\small Author: }}
\setlength{\autharea}{\widthof{\small Author: }+\authline}
\setlength{\dateline}{5.75 in-\autharea-\widthof{\small Date: }}
%\underline{#1\hspace*{\remaining}}\par
\justifying
Signature of \par
Author: \underline{\hspace{\authline}}Date: \underline{\hspace{\dateline}}
\par
#3
\committeeMember{#4}
\committeeMember{#5}
\committeeMember{#6}
\par}
\cleardoublepage}
\newcommand*{\authors}[1]{\newcommand{\authornames}{#1}}
\newcommand*{\faculty}[2]{\newcommand{\facName}{#1}\newcommand{\facTitle} {#2}}
\newcommand*{\degree}[2]{\newcommand{\degreeNameShort}{#1}\newcommand{\degreeName}{#2}}
\newcommand*{\department}[1]{\newcommand{\deptName}{#1}}
\newcommand*{\university}[1]{\newcommand{\univName}{#1}}
\usepackage{setspace}
\usepackage{vmargin}
\doublespacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\setmarginsrb { 1.5in} % left margin
{ 0.6in} % top margin
{ 1.0in} % right margin
{ 1.0in} % bottom margin
{ 20pt} % head height
{0.25in} % head sep
{ 9pt} % foot height
{ 0.3in} % foot sep
\raggedbottom
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{amsmath,amsfonts,amssymb,amscd,amsthm,xspace,bm}
\usepackage[centerlast,small,sc]{caption}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[scriptsize]{subfigure}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{listings}
\usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=false,colorlinks,linkcolor={blue},citecolor={blue},urlcolor={red},pdfstartview={FitV},unicode,breaklinks=true]{hyperref}
\usepackage{longtable}
\usepackage{tikz}
\usepackage[square, numbers, comma, sort&compress]{natbib} % Use the "Natbib" style for the references in the Bibliography
\usepackage{verbatim} % Needed for the "comment" environment to make LaTeX comments
\hypersetup{urlcolor=blue, colorlinks=true} % Colours hyperlinks in blue, but this can be distracting if there are many links.
\usepackage{titlesec}
\usepackage{calc,xcolor}
\usepackage{array, makecell} % <--- changed
\setcellgapes{5pt}
\usepackage{tikz}
\usepackage{xfrac}
\newcolumntype{M}{>{$}c<{$}}
\usepackage{algorithm2e}
\renewcommand*{\algorithmautorefname}{Algorithm}
\usepackage{ragged2e}