With pdflatex all my citation are pdf hyperlinks to the respective entry in the bibliography. This causes a problem when occasionally Latex decides to do a page break in the middle of a citation so that the citation starts on page n and and ends on page n+1. The problem then is that the footer of page n (containing page number) and the header of page n+1 (containing chapter name) are also included in the hyperlink.

This looks especially ugly in pdf viewers that highlight such links (like evince). So far I have solved this problem by rewriting the text until the page break no longer coincides with a citation but is there a better solution? I don't mind citations spanning pages, I just don't want the header and footer to be included in the hyperlink.

  • 9
    I'm afraid it's a known issue that, at the moment, has no real solution. :-(
    – egreg
    Apr 20, 2014 at 16:20
  • Thanks, will have to stick to my rewriting workaround then
    – themik81
    Apr 21, 2014 at 7:34

3 Answers 3


It is a difficult unsolved issue; pdfTeX uses a heuristics to find the right boxes that belongs to the link. It depends on the order of the boxes, the nesting level and the position. The following example modifies LaTeX's \@outputpage to move the header and footer boxes out of the way to fool pdfTeX's heuristics.


\begingroup           % the \endgroup is put in by \aftergroup
  \let \protect \noexpand
  \shipout \vbox{%
    \aftergroup \endgroup
    \aftergroup \set@typeset@protect
                                % correct? or just restore by ending
                                % the group?
    \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
    \else \let\@thehead\@evenhead
       \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
  \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
    \vskip \topmargin
    \moveright\@themargin \vbox {%
      \setbox\@tempboxa \vbox to\headheight{%
        }%                        %% 22 Feb 87
      \dp\@tempboxa \z@
%%% begin head
%     \box\@tempboxa
%%% replaced by:
%%% end head
      \vskip \headsep
      \baselineskip \footskip
%%% begin foot
%      \color@hbox
%        \normalcolor
%        \hb@xt@\textwidth{\@thefoot}%
%      \color@endbox
%%% foot replaced by
%%% end foot
  \global \@colht \textheight

  \href{http://www.dante.de/}{Hello\newpage\noindent World}

The link around the footer and header line are still present but outside the page area:

/MediaBox [0 0 612 792]                 % page 1 and 2
/Rect [147.716 656.239 478.476 665.15]  % page 1, "Hello"
/Rect [744.772 84.782 746.765 98.73]    % page 1, "FOOTER"
/Rect [744.772 691.108 746.765 705.056] % page 2, "HEADER"
/Rect [132.772 656.239 161.359 665.15]  % page 2, "World"

If figures and footnotes are added:

\footnote{A footnote}
\begin{figure}[b]\centering Figure bottom\caption{Figure A}\end{figure}
\href{http://www.dante.de/}{Hello\newpage\noindent World}
\begin{figure}[t]\centering Figure top\caption{Figure B}\end{figure}

then in this instance, the figures are not converted into links, but the footnote is a link. The latter could be caught by redefining \@makecol:

\gdef \@makecol {%
     \setbox\@outputbox \box\@cclv
     \setbox\@outputbox \vbox {%
       \boxmaxdepth \@maxdepth  
       \unvbox \@cclv
       \vskip \skip\footins
%%% original:
%         \unvbox\footins
%%% modified:
           \kern-\paperwidth\box \footins
   \global \let \@midlist \@empty
     \setbox\@outputbox \vbox to\@colht {%
       \dimen@ \dp\@outputbox
       \unvbox \@outputbox   
       \vskip -\dimen@
   \global \maxdepth \@maxdepth

However, putting free vertical material (\unvbox) into a fixed box is not side-effect free, if the \@cclv is again \unvboxed. Thus it fast becomes ugly. And patching base macros of LaTeX output routine raises compatibility issues with other packages that also deals with the output routine.

  • Clouldn't the hyperref package use some heuristic to split long links into separate tokens (which are not separated by whitespace) and then let the latex engine decide how to spread them over one or more pages?
    – lanoxx
    Oct 28, 2017 at 22:04
  • @lanoxx I do not see a more or less easy way. Package soul can detect break points in the text to split it to pieces, where hyphenation is allowed. Then, each piece needs a label and a second LaTeX run to detect, which pieces belong to the same page to merge them together (boxed link annotation). But, I doubt that \cite (there are lots of bibliography packages) is supported by soul. Oct 29, 2017 at 7:37

You could wrap the problematic citation like this \hbox{\cite{...}} to make it unbreakable. It worked nicely for me.


If some one will face this problem in the future and will be using DVI workflow the solution can be dvibreaklinks.sty. It will work only with luatex engine because link insertion is based on \localleftbox and \localrightbox. Links will be properly broken via pages (floats and headings will be ignored)




enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .