5

I have index.tex that I made a copy of it. renamed the copy to index_bad.tex, and added the line

\usepackage[pdfpagelabels]{hyperref}

to its preamble. So the 2 files are identical other than this one change.

Then compiled index.tex with pdflatex 3 time and looked at the index.pdf, and it is ok. (i.e. no blank page).

Compiled index_bad.tex with pdflatex 3 times. Now index_bad.pdf has an extra blank page inserted between first section and the second section.

This is the general layout of the document:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{fancyvrb}
\usepackage{graphicx}
\usepackage[left=.7in,right=.5in,top=.7in,bottom=.9in]{geometry}
\usepackage[pdfpagelabels]{hyperref}
\begin{document}
....
\section{....}
\subsection{...}
\begin{Verbatim}[frame=single,framesep=1mm,samepage=true,fontsize=\footnotesize]
.....
\begin{Verbatim}[frame=single,framesep=1mm,samepage=true,fontsize=\footnotesize]
....
\end{document}

When including hyperref a blank page shows up between first section, and the second section. No blank page shows up when this package is not included.

question is why does this happen? and how to fix it?

Since this document includes 2 images and large verbatim, I've zipped the whole folder so it is all self contained.

Unziping the zip file will create a folder. Inside the folder there is index.tex and index_bad.tex and the 2 images used. Running pdflatex on the files will show the problem above.

The zip file is http://12000.org/tmp/072113/latex_problem.zip

Using TL 2013 on Linux mint virtual machine hosted on windows.

enter image description here

Nasser
  • 20,220
  • 1
    It is obvious that the Verbatim frames are too large, since they visibly overflow into the page footer. That's what it causing the blank page, most likely. – Werner Jul 22 '13 at 04:25
  • 1
    @Werner, But the question is, why the blank page does not show up when hyperref not included? – Nasser Jul 22 '13 at 04:28

1 Answers1

8

As Werner has noticed, you have an overlarge page. TeX goes to the next page to set the oversized page, if the current page is not empty. That it, what happened here. The page is not empty, if package hyperref is loaded.

Package hyperref has to add anchors for the \section commands (otherwise the links would not have targets to jump to). It hooks into \refstepcounter for setting the anchor. Thus the example can be reduced to:

\documentclass[12pt]{article}

\usepackage{hyperref}

\showboxdepth=\maxdimen
\showboxbreadth=\maxdimen
\tracingonline=1

\begin{document}

Dummy page
\newpage  

\refstepcounter{section}% anchor setting with hyperref
\showlists
\rule{1pt}{1.1\textheight}

\end{document}

The \rule ensures that the page is overlarge:

Overfull \vbox (54.85335pt too high)

Without hyperref there are two pages and the page is empty after \refstepcounter{section}:

### vertical mode entered at line 0
prevdepth 2.33331, prevgraf 1 line

! OK.
l.15 \showlists

With hyperref the result is three pages and the page start after \refstpecounter is not empty and the anchor/link destination can be seen (driver pdftex):

### vertical mode entered at line 0
### current page:
\pdfdest name{section.1} xyz

prevdepth 2.33331, prevgraf 1 line

! OK.
l.15 \showlists

Thus the only unhappiness is that the page is broken between the destination and the section title. Fixing this would mean more digging/messing with internals, causing other incompatibilities.

BTW, you get the same behavior with other "whatits", e.g. index commands:

\documentclass[12pt]{article}

\usepackage{makeidx}
\makeindex

\showboxdepth=\maxdimen
\showboxbreadth=\maxdimen
\tracingonline=1

\begin{document}

Dummy page
\newpage

\index{foo}
\showlists
\rule{1pt}{1.1\textheight}

\end{document}

Result three pages with:

### vertical mode entered at line 0
### recent contributions:
\write3{\indexentry{foo}{\thepage }}
prevdepth 2.33331, prevgraf 1 line

! OK.
l.16 \showlists

Solution

The problem with the overfull \vbox needs to be resolved. A dirty way is:

\newpage
\enlargethispage{24.7852pt}
\section{Tikz solution}
Heiko Oberdiek
  • 271,626