我在编译文档时遇到了一个奇怪的错误。我已经在这个文档上工作了一段时间,在通过 tlgmr 更新我的 texlive 2018 安装后不久遇到了这些问题。
这个 MWE 为我重现了错误:
\documentclass[]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[]{csquotes}
\MakeAutoQuote{»}{«}
\MakeAutoQuote*{>}{<}
\usepackage{hyperref}
\begin{document}
\section{Introduction}
test test test
\section{Conclusion}
\end{document}
错误:
(c:/texlive/2018/texmf-dist/tex/latex/oberdiek/bkm-pdftex.def File: bkm-pdftex.def 2016/05/17 v1.26 bookmark driver for pdfTeX (HO) Package auxhook Info: \AddLineBeginMainAux comes a little late, (auxhook) because the main .aux file is already opened on input lin e 164. \BKM@id=\count107 )) ! Missing = inserted for \ifnum. <to be read again>
\begingroup l.14 \section{Introduction}
I was expecting to see `<', `=', or `>'. Didn't.
! Missing number, treated as zero. <to be read again>
\begingroup l.14 \section{Introduction}
A number should have been here; I inserted `0'. (If you can't figure out why I needed to see a number, look up `weird error' in the index to The TeXbook.)
! Missing = inserted for \ifnum. <to be read again>
\begingroup l.14 \section{Introduction}
I was expecting to see `<', `=', or `>'. Didn't.
! Missing number, treated as zero. <to be read again>
\begingroup l.14 \section{Introduction}
A number should have been here; I inserted `0'. (If you can't figure out why I needed to see a number, look up `weird error' in the index to The TeXbook.)
Package bookmark Warning: Unknown document division name (1) (bookmark) for option `level' on input line 14.
! Missing = inserted for \ifnum. <to be read again>
\begingroup l.14 \section{Introduction}
I was expecting to see `<', `=', or `>'. Didn't.
! Missing number, treated as zero. <to be read again>
\begingroup l.14 \section{Introduction}
A number should have been here; I inserted `0'. (If you can't figure out why I needed to see a number, look up `weird error' in the index to The TeXbook.)
! Undefined control sequence. \GenericError ...
#4 \errhelp \@err@ ... l.14 \section{Introduction}
The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.
! Undefined control sequence. \GenericError ...
\let \@err@ ... l.14 \section{Introduction}
(继续)
当我注释掉hyperref
其中一行makeautoquote
或将 documentclass 更改为时,article
所有内容都可以正常编译。
答案1
问题是,这\MakeAutoQuote*{<}{>}
会使<
和处于活动状态并重新定义它们。因此,在进行此更改后,在类似比较中>
使用<
或的所有操作都将失败。因此,这总是很危险的,即,如果在选择语言后读取此类代码,例如:>
\ifnum … < … \else … \fi
\begin{filecontents*}{\jobname1.tex}
\ifnum \value{page}>0 \relax\fi
\end{filecontents*}
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[]{csquotes}
\MakeAutoQuote{»}{«}
\MakeAutoQuote*{>}{<}
\AtBeginDocument{\input{\jobname1.tex}}
\begin{document}
\section{Introduction}
test test test
\section{Conclusion}
\end{document}
如果您仍然使用引号字符<
和>
,则应该避免延迟加载包或配置或驱动程序文件等,因为这在任何情况下都不容易或不可能。
在你的情况下,问题在于隐式加载bookmark
via \AtBeginDocument
。因此你可以尝试以下任一操作:
\documentclass[]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[]{csquotes}
\usepackage{hyperref}
\usepackage{bookmark}
\MakeAutoQuote{»}{«}
\MakeAutoQuote*{>}{<}
\begin{document}
\section{Introduction}
test test test
\section{Conclusion}
\end{document}
或者
\documentclass[bookmarkpackage=false]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[]{csquotes}
\usepackage{hyperref}
\MakeAutoQuote{»}{«}
\MakeAutoQuote*{>}{<}
\begin{document}
\section{Introduction}
test test test
\section{Conclusion}
\end{document}
但是,\MakeAutoQuote*{<}{>}
它仍然很危险,可能会引起麻烦。所以我建议不要使用它。