4

I have a boolean in my LaTeX paper that I use to create a custom author version (including a copyright box and clickable links and references). For the author version, I include the \hyperref package (in the other case, I use \nohyperref, following my earlier question https://tex.stackexchange.com/a/53316/2090).

However, I noticed that, when including hyperref, my layout changes slightly (I blame it on line spacing, but not 100% sure) with the end result that the last lines of my paper get pushed to a new page.

Is there any way to NOT have hyperref influence the layout (line spacing)? Or counteract upon it in an easy way?

The hyperref options I am currently using are below. But even disabling these gives the same result.

\hypersetup{
    pdfborder={0 0 0},
    colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue,
    pdfpagemode=UseNone}
  • I suspect this may be because hyperref does not like having breaks in the middle of links. This would change the position of line breaks and hence the layout. You could try using breakurl, but I find that this does not always work. – CPLB Aug 28 '13 at 13:02
  • @CPLB: I initially though this to be the reason as well. However, already on the 2nd page of my paper a shift of 2 lines to the 3rd page occur; and I don't have any URLs (http://... or similar) at that point in the paper. – Rabarberski Aug 29 '13 at 8:01
  • I just found your question by searching to solve a similar problem. On my side, there are discrepancies between a run with the pdftex package option (with pdflatex) and the ps2pdf package option (compiled with latex->dvips->ps2pdf). Did you find a solution ? – Adam B. Sep 17 '13 at 14:39
  • 1
    I ran across another question that may help you toward a solution here. Essentially, hyperref necessarily changes the formatting in order to add anchors. In some situations, you can avoid this, but it always seems to be a pain. – wyer33 Mar 7 '14 at 1:22
  • @Adam: I worked around it by using inserting \linespread{0.99} for my custom author version – Rabarberski Mar 7 '14 at 8:09
1

Just reporting the workaround I eventually used.
I inserted the command \linespread{0.99} where applicable.

\ifthenelse{\boolean{AuthorVersion}}{
    \linespread{0.99}       % apparently hyperref changes layout for this paper, so adjust slightly
    \usepackage{hyperref}   % for hyper references of citations, sections, etc.
    ...
 }{
    \linespread{0.99}       % do here also, to have same layout in camready and author version
    \usepackage{nohyperref} % to disable links (EDAS doesn't want them)
    \usepackage{url}        % hyperref includes \url but nohyperref doesn't 
}
1

The draft options of hyperref or package nohyperref also removes the specials for the hyper features as links and destinations. These specials can have influence on paragraph and page breaking.

The following example disables most hyper features, when driver pdftex is used. Links and destinations removed by redefining the primitives of pdfTeX relying on the way, they are called in hyperref. The replacement definition will add a whatsit, a write whatsit to the log file, to keep the influence on the paragraph and page breaking.

\documentclass{article}
\usepackage{makeidx}
\makeindex

% Disable information and catalog entries
\makeatletter
\AtBeginDocument{%
  \let\PDF@SetupDoc\relax
}
\makeatother

% Disable links, hyperref usually ends \pdfstartlinks arguments with \relax
\protected\def\pdfstartlink#1\relax{%
  \immediate\write-1{- \string\pdfstartlink#1}%
}
\protected\def\pdfendlink{%
  \immediate\write-1{- \string\pdfendlink}%
}

% Disable destinations, \pdfdest usually ended by \relax in hyperref
\protected\def\pdfdest#1\relax{%
  \immediate\write-1{- \string\pdfdest#1}%
}

\usepackage[
  % disable features independent from typesetting
  bookmarks=false,
  pdfpagelabels=false,
]{hyperref}

\begin{document}
\tableofcontents
\section{Hello World}
\index{Einstein}
\begin{equation}
  \label{eq:einstein}
  E=mc^2
\end{equation}
See equation (\ref{eq:einstein}) on page \pageref{eq:einstein}.

\section{TeX user groups}
\begin{itemize}
\item[\href{http://www.tug.org/}{TUG}:] \url{http://www.tug.org/}
\item[\href{http://www.dante.de/}{DANTE}:] \url{http://www.dante.de/}
\end{itemize}

\printindex
\end{document}

The list of disabled features is not complete, e.g., forms and option ocgcolorlinks still leave traces.

The log file contains:

- \pdfdestname{Doc-Start}XYZ
- \pdfdestname{section*.1}XYZ
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[1 0 0]}goto name{section.1}
- \pdfendlink
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[1 0 0]}goto name{section.2}
- \pdfendlink
- \pdfdestname{section.1}XYZ
- \pdfdestname{equation.1.1}XYZ
- \pdfdestname{equation.1.1}XYZ
- \pdfdestname{equation.1.1}XYZ
- \pdfdestname{equation.1.1}XYZ
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[1 0 0]}goto name{equation.1.1}
- \pdfendlink
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[1 0 0]}goto name{equation.1.1}
- \pdfendlink
- \pdfdestname{section.2}XYZ
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[0 1 1]}user{/Subtype/Link/A<</Type/Act
- \pdfendlink
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[0 1 1]}user{/Subtype/Link/A<</Type/Act
- \pdfendlink
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[0 1 1]}user{/Subtype/Link/A<</Type/Act
- \pdfendlink
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[0 1 1]}user{/Subtype/Link/A<</Type/Act
- \pdfendlink
- \pdfdestname{page.1}XYZ
- \pdfdestname{section*.2}XYZ
- \pdfstartlinkattr{/Border[0 0 1]/H/I/C[1 0 0]}goto name{page.1}
- \pdfendlink
- \pdfdestname{page.2}XYZ

Does this help with your document?

-1

I had a similar problem which was not caused by a change in line spacing. The hyperref package was changing the paper size from A4 format to US letter format, thus leading to a page 18mm less high and shifting some text to the next page. I fixed the problem by declaring the page size in the document class:

\documentclass[a4paper]{letter}

Another solution is to declare the paper height to the desired value (for example A4 -> 297mm):

\setlength{\paperheight}{some value}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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