
在我的論文中,我同時使用了appendix
包和hyperref
包。當我到達附錄時,我使用以下命令:
\appendix
\noappendicestocpagenum
\addappheadtotoc
\appendixpage
在目錄中,hyperref
使用 選項僅提供頁碼上的連結linktocpage=true
。由於該指令,目錄中沒有顯示「附錄」頁的頁碼\noappendicestocpagenum
;然而,hyperref
無論如何都會產生一個小的空紅色框。有沒有辦法阻止這個盒子的形成?
這是一個最小的工作範例。
\documentclass{report}
\usepackage{appendix}
\usepackage[pdftex,linktocpage=true]{hyperref}
\begin{document}
\tableofcontents
\chapter{Chapter Name}
Here is my document.
\clearpage
\appendix
\noappendicestocpagenum
\addappheadtotoc
\appendixpage
\chapter{Appendix Name}
Here is my appendix.
\end{document}
答案1
在你的例子中,我只是重新定義它的\addappheadtotoc
作用(因為你知道你將要使用的結構):
\makeatletter
\renewcommand{\addappheadtotoc}{%
\phantomsection
\addtocontents{toc}%
{\protect\contentsline{chapter}{\appendixtocname}{}{}}%
}
\makeatother
當然,appendix
旨在管理各種環境中的工作,但了解您所處的框架,這是一個簡單且易於管理的變更。
這是一個完整的最小範例:
\documentclass{report}
\usepackage{appendix}% http://ctan.org/pkg/appendix
\usepackage[pdftex,linktocpage=true]{hyperref}% http://ctan.org/pkg/hyperref
\makeatletter
\renewcommand{\addappheadtotoc}{%
\phantomsection
\addtocontents{toc}%
{\protect\contentsline{chapter}{\appendixtocname}{}{}}%
}
\makeatother
\begin{document}
\tableofcontents
\chapter{Chapter Name}
Here is my document.
\clearpage
\appendix
\noappendicestocpagenum
\addappheadtotoc
\appendixpage
\chapter{Appendix Name}
Here is my appendix.
\end{document}