
我在編譯文檔時遇到一個奇怪的錯誤。我現在已經在這個文件上工作了一段時間,並在透過 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
或將文檔類別變更為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*{<}{>}
這仍然是危險的,可能會帶來麻煩。所以我建議不要使用它。