3

I am trying to make a handout using a subset from a bigger set of pages. So far I succeeded in putting four pages on one page using

\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper,border shrink=2.5mm,landscape]

However, the problem is that I want only a part of the total pages on the handout, say pages 6 to 13. Unfortunately, for example, page 6 is now sharing one page with four other pages including page 5 which I do not want on my handout. So I cannot manually cut out the pages I need on my handouts.

Is it somehow possible to tell LaTeX to output only pages 6 to 13, using my pgfpages options, but keeping all other things equal?

2

You can use the components from Compiling only a page range or page selection:

enter image description here

\documentclass{article}
\usepackage{pgfpages}% http://ctan.org/pkg/pgf
\pgfpagesuselayout{4 on 1}[a4paper,border shrink=2.5mm,landscape]

% Taken from https://tex.stackexchange.com/q/96256/5764
\usepackage{multido,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
\keeppages{6,7,8,9,10,11,12,13}% Keep only these pages
\begin{document}
\multido{\iA=1+1}{20}{\scalebox{40}{\iA}\newpage}
\end{document}
  • This seems to work. However, with my particular presentation in LyX I get an error: ! You can't use `\spacefactor' in vertical mode. – Daniel Sep 18 '13 at 6:32
  • @Daniel: One would need to recreate the problem in order to assess how to fix it. You need to provide more detail; preferably in the form of a minimal working example (MWE). – Werner Sep 18 '13 at 6:34
1

I found a way to do it:

First, I compile my full text to full.pdf. And then do a run with the following code:

\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper,border shrink=-30mm,landscape]
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={6-12}]{full.pdf}
\end{document}

I had to adjust the border manually by shrinking them negatively (border shrink=-30mm). Nicely, this solution gives one the possibility to use page ranges (pages={6-12}).

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.