我嘗試將序言新增到一個名為 的新類別檔案中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
錯誤。