
在撰寫論文時,我使用了hyperref
和appendix
包,如下面的小範例所示。
測試文件
\documentclass{book}
\usepackage{hyperref}
\usepackage[titletoc]{appendix}
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{Chapter section}
\chapter{Second chapter}
\begin{appendices}
\input{extra}
\end{appendices}
\end{document}
額外文字
\chapter{First appendix}
\section{Appendix section}
該範例不會產生任何錯誤。最終結果是一個內容表,其中包含所有章節(包括附錄中的章節)的可點擊鏈接,並按照我想要的方式進行格式化。
編譯(pdfLaTeX)時會產生以下檔案:
檢驗出
\BOOKMARK [0][-]{chapter.1}{First chapter}{}% 1
\BOOKMARK [1][-]{section.1.1}{Chapter section}{chapter.1}% 2
\BOOKMARK [0][-]{chapter.2}{Second chapter}{}% 3
\BOOKMARK [0][-]{Appendix.1.A}{Appendix First appendix}{}% 4
\BOOKMARK [1][-]{section.1.A.1}{Appendix section}{Appendix.1.A}% 5
當然,我的論文要大得多(更多的章節和更多的附錄)。儘管結構相似,但編譯我的論文會導致許多神秘錯誤(意味著我不理解它們)。我在下面列出了一些。對包進行註釋hyperref
可以讓我進行編譯,但也會停用 PDF 文件中的連結和書籤。
! Missing \endcsname inserted.
<to be read again>
\penalty
l.46 ...@skip {}lage.1.D}{B\377lage Afkortingen}{}
% 46
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing number, treated as zero.
<to be read again>
{
l.46 ...@skip {}lage.1.D}{B\377lage Afkortingen}{}
% 46
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.)
! Extra \endcsname.
\check@bm@number ...0\else \csname B_#1\endcsname
\fi
l.46 ...@skip {}lage.1.D}{B\377lage Afkortingen}{}
% 46
I'm ignoring this, since I wasn't doing a \csname.
)
! Missing $ inserted.
<inserted text>
$
l.154 \begin{document}
在您看到附錄書籤之前,我論文的 .out 文件看起來不錯。
...
\BOOKMARK [1][-]{section.5.4}{Optimalisatie}{chapter.5}% 32
\BOOKMARK [0][-]{chapter.6}{Conclusie}{}% 33
\BOOKMARK [0][-]{chapter*.28}{Bibliografie}{}% 34
\BOOKMARK [0][-]{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M \hskip \z@skip {}lage.1.A}{B\377lage Stopwoordlijsten}{}% 35
\BOOKMARK [1][-]{section.1.A.1}{Nederlandse stopwoorden}{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M \hskip \z@skip {}lage.1.A}% 36
\BOOKMARK [1][-]{section.1.A.2}{Engelse stopwoorden}{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M \hskip \z@skip {}lage.1.A}% 37
...
我相信這個帖子與我的問題有關,但我無法弄清楚它(我對 LaTeX 還比較陌生)。誰能幫我啟用論文中的連結和書籤?
問候,
桑德爾
編輯
將套件新增babel
至範例會重現該問題。
\usepackage[dutch]{babel}
答案1
錯誤報告
這是包附錄中的一個錯誤。如果babel
載入了語言選項,則會觸發該錯誤dutch
。從我給包維護者的錯誤回報:
以下文檔在第二次運行時中斷:
\documentclass{book}
\usepackage[dutch]{babel}
\usepackage{hyperref}
\usepackage[titletoc]{appendix}
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{Chapter section}
\chapter{Second chapter}
\begin{appendices}
\chapter{First appendix}
\section{Appendix section}
\end{appendices}
\end{document}
.out 檔案包含:
\BOOKMARK [0][-]{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M
\hskip \z@skip {}lage.1.A}{B\377lage First appendix}{}% 4
由於語言相關字串:用於目標名稱的計數器名稱已損壞B"ylage
。原因是:
\newcommand{\@resets@pp}{\par
\@ppsavesec
\stepcounter{@pps}
\setcounter{section}{0}%
\if@chapter@pp
\setcounter{chapter}{0}%
\renewcommand\@chapapp{\appendixname}%
\renewcommand\thechapter{\@Alph\c@chapter}%
\else
\setcounter{subsection}{0}%
\renewcommand\thesection{\@Alph\c@section}%
\fi
\if@pphyper
\if@chapter@pp
\renewcommand{\theHchapter}{\theH@pps.\Alph{chapter}}%
\else
\renewcommand{\theHsection}{\theH@pps.\Alph{section}}%
\fi
\def\Hy@chapapp{\appendixname}%
\fi
\restoreapp
}
\Hy@chapapp
被重新定義為\appendixname
,這是依賴語言的,由於簡寫擴展,在荷蘭語的情況下會中斷。但\Hy@chapapp
在目的地名稱中使用,通常是“章節”(來自計數器章節),只有在\appendix
名稱chapter
更改為 後appendix
才能獲得更好的唯一目的地名稱。沒有必要使這種語言依賴。只需使用:
\def\Hy@chapapp{appendix}
或者
\def\Hy@chapapp{\Hy@appendixstring}
\@resets@ppsub
還需要修復其他發生的情況。
解決方法/解決方案
還有一個獨立於包中的錯誤修復的解決方法appendix
。只需bookmark
在之後加載包即可hyperref
。它有一個更強大的書籤演算法,並透過使用 編碼( )來處理文件B"ylage
中的損壞。書籤也較早更新。.aux
hex
base16
\documentclass{book}
\usepackage[dutch]{babel}
\usepackage{hyperref}
\usepackage{bookmark}
\usepackage[titletoc]{appendix}
v6.83b也會hyperref
停用目標名稱中的簡寫(\hypercurrent 和 \contentsline 中的目標名稱)。
書籤中的“IJ”和“ij”
這些字元(大寫/小寫 i 和 j 的連字)在 PDFDocEncoding 中不可用。但它們可以透過 Unicode 書籤訪問,這意味著
hyperref
選項pdfencoding=auto
或unicode
。
hyperref
的編碼中用“ÿ”替換PD1
是一個錯誤,將在 v6.83b 中修復。
順便說一句,書籤巨集的重新定義可以透過將它們放入以下位置來限制為書籤(pdf 字串)\pdfstringdefDisableCommands
:
\pdfstringdefDisableCommands{%
\renewcommand*{\appendixname}{Bookmark-Appendix}%
}
答案2
根據所有評論編譯的完整解決方案。
\documentclass{book}
\usepackage[dutch]{babel}
\usepackage[titletoc]{appendix}
\usepackage{hyperref}
\usepackage{bookmark} % handles the encoding in the .out file
\addto\captionsdutch{\renewcommand{\appendixname}{Bijlage}} % changes 'Bÿlage' to 'Bijlage' for the bookmarks
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{Chapter section}
\chapter{Second chapter}
\begin{appendices}
\input{extra}
\end{appendices}
\end{document}
問候,
桑德爾