我尝试将我的序言添加到与labs.cls
我的文件位于同一目录中的新类文件中lab1.tex
。然后我将 tex 文件的序言更改为\documentclass{labs}
。当我尝试编译 tex 文件时,出现此错误:
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9)
entering extended mode
(F:\Coding\phy-182\formal_lab_reports\1_formal_lab\lab1.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic,
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2012-05-30, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, latin, latvian,
lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerman, n
german-x-2012-05-30, nynorsk, oriya, panjabi, pinyin, polish, portuguese, roman
ian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swissgerm
an, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, usengl
ishmax, welsh, loaded.
(F:\Coding\phy-182\formal_lab_reports\1_formal_lab\labs.cls
Document Class: labs 2014-03-16 Formal lab style for Miami University
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\size10.clo"))
(C:\Users\Nate\AppData\Roaming\MiKTeX\2.9\tex\latex\fancyhdr\fancyhdr.sty)
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\mh\mathtools.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\tools\calc.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\mh\mhsetup.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsmath\amsmath.sty"
For additional information on amsmath, use the `?' option.
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsmath\amstext.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty"))
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty")))
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\was\gensymb.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\geometry\geometry.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\geometry\geometry.cfg")))
! Missing = inserted for \ifnum.
<to be read again>
-
l.2
?
这是我的课程文件:
\ProvidesClass{labs}[2014-03-16 Formal lab style for University]
\NeedsTeXFormat{LaTeX2e}
\LoadClass[letterpaper]{article}
\RequirePackage{fancyhdr}
\RequirePackage{mathtools}
\RequirePackage{gensymb}
\RequirePackage[margin=1in]{geometry}
\fontsize{12}{14}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\linespread{2}
\AtBeginDocument{\thispagestyle{empty}}
\lhead{Nathan Mara}
我在这个类文件中做错了什么吗?
我甚至在这个 tex 文件上也遇到了同样的错误:
\documentclass{labs}
\begin{document}
\end{document}
答案1
命令\ProvidesClass
、\ProvidesPackage
和\ProvidesFile
具有强制参数(文件名,前两个命令不带扩展名,因为.cls
和.sty
是隐含的)和一个可选参数,用于说明文件的版本。可选参数应采用以下形式
<date>
<info>
该<info>
部分不是必需的;如果存在,应将其与日期用空格分隔。
例如,我们可以简单地做
\ProvidesClass{foo}
但这不是好的编程风格:应该始终提供日期。因此
\ProvidesClass{foo}[2014/03/19]
或者
\ProvidesClass{foo}[2014/03/19 Some information]
请注意,日期的格式如下所示,带有斜线而不是连字符:
YYYY/MM/DD
即年份为四位数,月份为两位数,日期为两位数。任何其他输入都会导致错误\ifnum
。