# How do remove the two extra pages at the beginning of the pdf after using hyperref package?

I notice when I use the hyperref package, it creates two extra pages in the beginning of my pdf. I did find the info to remove the first page, but the second one is still there with just a '2' in the footer. I need to remove that page as well. Here's the code for the main book file. The packages, halfletter and moonfonts, are ones I wrote to help me with the required page size and typography. This book is unusual fiction and the typography is not conventional.

So what am I missing to clear those extra pages?

Here's the code for the main document:

\documentclass[12pt,openany]{book}
\usepackage{halfletter}
\usepackage{moonfonts}
\usepackage{hyperref}
\usepackage{atbegshi,multido,graphicx}
\hypersetup{

\author{Tom Baker}
\pagestyle{plain}
\begin{document}
\frontmatter
\thispagestyle{empty}
\include{title}
\pagenumbering{roman}
\include{legal}
\clearpage
\tableofcontents
\mainmatter
\pagenumbering{arabic}
\include{authorsnote}
\include{system}
\include{myhometown}
\include{dog}
\include{library}
\include{federalreserve}
\include{patrolcar}
\include{soitwasnt}
\include{tigers}
\include{thesetigers}
\include{parsecsinoblivion}
\include{prey}
\include{inalltheirstrange}
\include{somewherehefancied}
\include{toughworld}
\include{heiswithhismother}
\include{reddeath}
\include{thatstone}
\include{youdigthis}
\include{shesfucking}
\include{skymaiden}
\include{bubwasplugging}
\include{ratman}
\include{dogeats}
\include{theywalkedback}
\include{sherriffsmutz}
\include{itwas}
\include{shewas}
\include{filmbegins}
\include{communistprop}
\include{iwascertainly}
\include{irummaged}
\include{houseofsevensisters}
\include{itwassomesort}
\include{prisonlaundry}
\include{thisisdevil}
\include{nazimonkey}
\include{iamatchurch}
\include{imhungry}
\include{hehijacked}
\include{eclipse}
\include{onenight}
\include{andihave}
\include{ouryoungcouple}
\include{festival}
\include{runningdown}
\include{shereached}
\include{itwasnight}
\include{therewerepeople}
\include{happens}
\include{imsneaking}
\include{inmidst}
\include{somethingmightly}
\include{didherface}
\include{hotelroom}
\include{ourlittle}
\include{sherriffwas}
\include{theylookedlike}
\include{drivedown}
\include{ilookup}
\include{threedaysearlier}
\include{otherstuff}
\include{theyexplain}
\include{movie}
\include{somother}
\include{goingdown}
\include{shewent}
\include{butwhichdoors}
\include{sohereiam}
\include{severallargedogs}
\include{itwassummer}
\include{hesaw}
\include{stevemccloud}
\include{butthatcouldnt}
\include{timefordinner}
\include{whisperingonwind}
\include{hefelt}
\include{aftermuch}
\include{manseemed}
\include{screambrought}
\include{hereachedup}
\include{itisyoungwoman}
\include{sitting}
\include{guninhishand}
\include{lukegotout}
\include{theycorresponded}
\include{heknewclemwas}
\include{itisdark}
\include{helookedup}
\include{itsthatdamn}
\include{hesatatedge}
\include{hegrabbed}
\include{hereyeswork}
\include{shestoopslow}
\include{nullwashustled}
\include{nullisntsure}
\include{towakeup}
\include{backathouse}
\include{thiscousin}
\include{cloudsdarken}
\include{murdervictim}
\include{yeahisuppose}
\include{whitewalls}
\include{iknewhim}
\include{thisgirl}
\include{heturned}
\include{firsttime}
\include{okaysothisis}
\include{amidtallgrasses}
\include{nextiwas}
\include{largeempty}
\include{itslikedisneyland}
\include{exactlyhowmuch}
\include{twoyounggirls}
\include{poolwassituation}
\include{outofpool}
\include{hetookher}
\include{facecries}
\include{whenigotback}
\include{sceneshifts}
\include{butnow}
\include{turninghemoves}
\include{placeissmall}
\include{houseitself}
\include{hegotup}
\include{herolledover}
\include{theylie}
\include{okaysowegot}
\include{itwaslater}
\include{oneofthem}
\include{whentheyfound}
\include{heremembered}
\include{shewassomesort}
\include{nullwent}
\include{heavoided}
\include{theyweresitting}
\include{decapitationritual}
\include{hebrooded}
\include{later}
\include{wekeep}
\include{hesrollingaround}
\include{sotheystart}
\include{somewhere}

\end{document}

• Why do you include hyperref twice and set the toc options twice?
– cfr
Jan 16, 2014 at 0:11
• A minimal working example would help.
– A.G.
Jan 16, 2014 at 0:21
• I didn't catch including both hyperref and toc options twice. I have simplified now. Jan 16, 2014 at 16:17

Since I don't have the files you're using to create your document, the following 10-page minimal document should have to suffice:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\lipsum[1-50]
\end{document}


Here are two ways of removing the first two pages that are shipped out:

1. \usepackage[3-]{pagesel}% http://ctan.org/pkg/pagesel

2. \usepackage{atbegshi,afterpage}% http://ctan.org/pkg/{atbegshi,afterpage}
\AtBeginDocument{%
}


I am working with a template that has automatic filler cards and a cover page that I have to remove. Using the upper solutions, I had a blank page inserted when using the pagesel solution, and it only removed the first page. Using the atbegshi and afterpage approach, I could only get rid of the first page (no blank page inserted with this method). What has worked for me:

\usepackage{atbegshi}


Another take on the problem from here: Compiling only a page range or page selection

\documentclass{article}
\usepackage{lipsum,atbegshi,etoolbox}% http://ctan.org/pkg/{lipsum,atbegshi,etoolbox}
\makeatletter
\AtBeginShipout{% At shipout, decide whether to discard page/not
\renewcommand*{\do}[1]{% How to handle each page entry in csv list
\ifnum\value{page}=##1\relax%
\gdef\do####1{}% Do nothing further
\fi%
}%
}%
}
\newif\ifkeeppage
\newcommand{\keeppages}[1]{% \keeppages{<csv list>}
\xdef\keep@pages{#1}% Store pages to keep
\AtBeginShipout{% At shipout, decide whether to discard page/not
\keeppagefalse%
\renewcommand*{\do}[1]{% How to handle each page entry in csv list
\ifnum\value{page}=##1\relax%
\keeppagetrue% Page should be kept
\gdef\do####1{}% Do nothing further
\fi%
}%
\expandafter\docsvlist\expandafter{\keep@pages}% Process list of pages to keep