#StackBounty: #compiling #page Why isn't range input supported in keeppages?

Bounty: 50

It seems a little odd that keeppages{x-y} is not supported? Perhaps I’m not using the proper syntax.

This code should be adapted to satisfy the case that the first several pages of the document are labelled as i, ii, iii, iv, etc.

makeatletter
newcommand{discardpages}[1]{% discardpages{<csv list>}
  xdefdiscard@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
      ifnumvalue{page}=##1relax%
        AtBeginShipoutDiscard% Discard page/not
        gdefdo####1{}% Do nothing further
      fi%
    }%
    expandafterdocsvlistexpandafter{discard@pages}% Process list of pages to discard
  }%
}
newififkeeppage
newcommand{keeppages}[1]{% keeppages{<csv list>}
  xdefkeep@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
      ifnumvalue{page}=##1relax%
        keeppagetrue% Page should be kept
        gdefdo####1{}% Do nothing further
      fi%
    }%
    expandafterdocsvlistexpandafter{keep@pages}% Process list of pages to keep
    ifkeeppageelseAtBeginShipoutDiscardfi% Discard page/not
  }%
}
makeatother


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.