我正在尝试使用 htlatex 编译 HoTT 书籍,并试图重现使用 htlatex 而不是 pdflatex 时出现的问题。但是,我甚至无法使用 pdflatex 获得一个小的可行示例。
我想知道为什么这段代码不起作用,以及如何修复它。
\documentclass{article}
\usepackage{amsthm}
\usepackage{aliascnt}
\usepackage[capitalize]{cleveref}
\usepackage{hyperref}
\newtheorem{thm}{Theorem}[section]
\crefname{thm}{Theorem}{Theorems}
\theoremstyle{remark}
\newaliascnt{rmk}{thm}
\newtheorem{rmk}[rmk]{Remark}
\aliascntresetthe{rmk}
\crefname{rmk}{Remark}{Remarks}
\begin{document}
.
\begin{thm}
.
\end{thm}
\begin{rmk}
.
\end{rmk}
\end{document}
它给了我
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9 64-bit)
entering extended mode
(D:\Documents\GitHub\book\test.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.
("D:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("D:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("D:\Program Files\MiKTeX 2.9\tex\latex\amscls\amsthm.sty")
("D:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\aliascnt.sty"
("D:\Program Files\MiKTeX 2.9\tex\latex\carlisle\remreset.sty"))
(D:\Documents\GitHub\book\cleveref.sty)
("D:\Program Files\MiKTeX 2.9\tex\latex\hyperref\hyperref.sty"
("D:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\hobsub-hyperref.sty"
("D:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\hobsub-generic.sty"))
("D:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
(D:\Documents\GitHub\book\ifxetex.sty)
("D:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\auxhook.sty")
("D:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty")
("D:\Program Files\MiKTeX 2.9\tex\latex\hyperref\pd1enc.def")
("D:\Program Files\MiKTeX 2.9\tex\latex\00miktex\hyperref.cfg")
("D:\Program Files\MiKTeX 2.9\tex\latex\ltxmisc\url.sty"))
Package hyperref Message: Driver (autodetected): hpdftex.
("D:\Program Files\MiKTeX 2.9\tex\latex\hyperref\hpdftex.def"
("D:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\rerunfilecheck.sty"))
(D:\Documents\GitHub\book\test.aux)
("D:\Program Files\MiKTeX 2.9\tex\latex\hyperref\nameref.sty"
("D:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\gettitlestring.sty"))
(D:\Documents\GitHub\book\test.out) (D:\Documents\GitHub\book\test.out)
! LaTeX Error: No counter 'r' defined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.20 \begin{rmk}
?
! Emergency stop.
...
l.20 \begin{rmk}
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.
为什么它要寻找计数器“r”,我该如何解决这个问题?
答案1
我无法提供深入的技术答案,但根据其手动的 第13节:
cleveref 包必须在所有不支持它的包之后加载,即
\usepackage{cleveref}
行通常应该是文档序言中的最后一个 \usepackage 命令。
答案2
解决方案是移至\usepackage{hyperref}
顶部。如果有人想向我解释为什么会出现这种情况,我很乐意将其标记为可接受的答案。