TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to have links to lines in the table of contents, as suggested in, e.g., this question. It seems like the standard answer is to include lines like


in the appropriate part of the document. This works great except that the table of contents doesn't seem willing to have page breaks between subsections that have this line between them, which leads to awkward spacing. I've posted an example below.





\subsection{Pagebreak should go below here}
% but it doesn't if this is uncommented



Why is this, and how can I specify that page breaks are OK?

share|improve this question

The answer to your question Why does adding hypertarget to TOC change pagination? is that by adding \addtocontents{toc}{\protect\hypertarget{moo}{}} will add a new line in the .aux file with \@writefile{toc}{\hypertarget {moo}{}}. On the next compilation, an additional empty line with invisible hyper-target will appear in the PDF, which seems to us that the pagination changed.

To overcome this situation, we need to tweak \section, \subsection and what ever section commands which require navigation as given in the below example:


   \def\rightmark{\hyperlink{moo.\thesection}{\thesection.\quad #1}}%
   \def\rightmark{\hyperlink{moo.\thesubsection}{\thesubsection.\quad #1}}%
   \def\rightmark{\thesection.\quad #1}%
   \def\rightmark{\thesubsection.\quad #1}%







\nolinksubsection{Pagebreak should go below here}
% but it doesn't if this is un-commented





Defined a new pagestyle (header and footer) named myheading to put the navigation in headers which lead back to the ToC entry. Also, the commands \section, \subsection, etc changed to \linksection, \linksubsection respectively for those sections which required the navigation using hyper-linking. And those \section, \subsection which does not require navigation are defined as \nolinksection, \nolinksubsection respectively. These macros will define respective entries for \hypertarget in the ToC and \hyperlink in the headers.

Hope this helps.

share|improve this answer
Yes, it adds another line to the toc. The question is: why does that change the pagination? The visible text is identical; why does the linebreak become "non-pagebreaking" or whatever the term is? – Eric Price Jul 31 '13 at 4:40
Please open and see the filename.toc file. You will find a new entry in the toc file. This will cause one empty line (invisible line) in the table of contents and these empty lines changes the pagination. – Jagath Jul 31 '13 at 4:54

Your Answer


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.