Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In my thesis, I am using both the appendix package and the hyperref package. When I get to the appendix, I use the following commands:

\appendix
\noappendicestocpagenum
\addappheadtotoc
\appendixpage

In the table of contents, hyperref is providing links on just the page numbers, using the linktocpage=true option. There is no page number for the "Appendices" page displayed on the table of contents thanks to the \noappendicestocpagenum command; however, hyperref generates a small empty red box regardless. Is there a way to stop this box from forming?

Here is a minimal working example.

\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}
share|improve this question
    
Would adding the option colorlinks=true to hyperref be an option for you? –  Gonzalo Medina Aug 22 '12 at 1:50
    
Heh, that's a nice solution, but I don't think my thesis committee would appreciate the colors (even in grayscale) turning up in the print copy. I could do separate print and pdf versions, but I'd prefer not to. –  Jolyon Aug 22 '12 at 1:54
    
Then perhaps use \usepackage[hidelinks]{hyperref}. –  Gonzalo Medina Aug 22 '12 at 1:55
    
That is one way of doing it, but I like those links being visible in the pdf copy! Note that the link to the appendix page still exists in this case however; it's just hidden. –  Jolyon Aug 22 '12 at 1:58
    
Thanks for the use case. Package hyperref 6.83d will remove the link if the page number is empty. –  Heiko Oberdiek Aug 22 '12 at 5:44
add comment

1 Answer 1

up vote 4 down vote accepted

In your instance, I would just redefine what \addappheadtotoc does (since you know the structure you will be working with):

\makeatletter
\renewcommand{\addappheadtotoc}{%
  \phantomsection
  \addtocontents{toc}%
    {\protect\contentsline{chapter}{\appendixtocname}{}{}}%
 }
\makeatother

Of course, appendix is written to manage working in a variety of settings, but knowing the framework you find yourself in, it is an easy and manageable change.

Here's a complete minimal example:

enter image description here

\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}
share|improve this answer
    
That looks great. Many thanks! –  Jolyon Aug 22 '12 at 3:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.