![使用 hyperref 包后,如何删除 pdf 开头的两页多余的页面?](https://linux22.com/image/282568/%E4%BD%BF%E7%94%A8%20hyperref%20%E5%8C%85%E5%90%8E%EF%BC%8C%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4%20pdf%20%E5%BC%80%E5%A4%B4%E7%9A%84%E4%B8%A4%E9%A1%B5%E5%A4%9A%E4%BD%99%E7%9A%84%E9%A1%B5%E9%9D%A2%EF%BC%9F.png)
我注意到当我使用 hyperref 包时,它会在我的 pdf 开头创建两个额外的页面。我确实找到了删除第一页的信息,但第二页仍然存在,页脚中只有一个“2”。我也需要删除该页面。这是主书文件的代码。halfletter 和 moonfonts 包是我编写的,用于帮助我获得所需的页面大小和排版。这本书是一部不同寻常的小说,排版也不是很常规。
那么我缺少什么来清除这些多余的页面呢?
以下是主文档的代码:
\documentclass[12pt,openany]{book}
\usepackage{halfletter}
\usepackage{moonfonts}
\usepackage{hyperref}
\usepackage{atbegshi,multido,graphicx}
\AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}
\usepackage[linktoc=all,pagebackref=true]{hyperref}
\hypersetup{
colorlinks=false,
linktoc=all}
\title{Nazi, Monkey, Séance}
\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{goatheadalbino}
\include{itwas}
\include{shewas}
\include{filmbegins}
\include{communistprop}
\include{graveyardmadonna}
\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{shadow}
\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{ihadnopart}
\include{thisgirl}
\include{heturned}
\include{firsttime}
\include{yesterdaytheyinvaded}
\include{okaysothisis}
\include{amidtallgrasses}
\include{reallybadidea}
\include{nextiwas}
\include{earliertheyhadbeen}
\include{largeempty}
\include{itslikedisneyland}
\include{exactlyhowmuch}
\include{twoyounggirls}
\include{poolwassituation}
\include{outofpool}
\include{hetookher}
\include{facecries}
\include{theyhadcollected}
\include{whenigotback}
\include{sceneshifts}
\include{butnow}
\include{turninghemoves}
\include{placeissmall}
\include{houseitself}
\include{hegotup}
\include{herolledover}
\include{theylie}
\include{theyhadbeenwaiting}
\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{latertheymade}
\include{hesrollingaround}
\include{sotheystart}
\include{somewhere}
\end{document}
答案1
由于我没有您用来创建文档的文件,因此以下 10 页的最小文档应该足够了:
\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\lipsum[1-50]
\end{document}
以下是删除发运出去的前两页的两种方法:
-
\usepackage[3-]{pagesel}% http://ctan.org/pkg/pagesel
-
\usepackage{atbegshi,afterpage}% http://ctan.org/pkg/{atbegshi,afterpage} \AtBeginDocument{% \AtBeginShipoutNext{\AtBeginShipoutDiscard}% Remove page 1 \afterpage{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}% Remove page 2 }
答案2
我正在使用一个模板,该模板具有自动填充卡和封面页,我必须将其删除。使用上面的解决方案,我在使用 pagesel 解决方案时插入了一个空白页,它只删除了第一页。使用 atbegshi 和 afterpage 方法,我只能删除第一页(使用此方法不会插入空白页)。对我有用的方法:
\usepackage{atbegshi}
\AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}
\AtBeginShipoutNext{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}
从这里可以看到这个问题的另一种看法: 仅编译页面范围或页面选择
\documentclass{article}
\usepackage{lipsum,atbegshi,etoolbox}% http://ctan.org/pkg/{lipsum,atbegshi,etoolbox}
\makeatletter
\newcommand{\discardpages}[1]{% \discardpages{<csv list>}
\xdef\discard@pages{#1}% Store pages to discard
\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%
\AtBeginShipoutDiscard% Discard page/not
\gdef\do####1{}% Do nothing further
\fi%
}%
\expandafter\docsvlist\expandafter{\discard@pages}% Process list of pages to discard
}%
}
\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
\ifkeeppage\else\AtBeginShipoutDiscard\fi% Discard page/not
}%
}
\makeatother
\discardpages{1,3,5,7,9,29,35,40}% Discard these pages.
%\keeppages{2,4,6}% Keep these pages.
\begin{document}
\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]\lipsum[1-50]
\end{document}