1

Using the pdfpages package I can do something like this to merge some pages of a document.

\includepdf[page={1,1,1,2,2,10,10,10,10},nup=1x2]{mypdf.pdf}

In this case 3 times pages 1 and 2 times page 2 and 4 times page 10 are included in the specified arrangement.

Is there a better syntax for this instead of repeatedly typing in the page I want. I.e. something like {*{3}{1},*{2}{2},*{4}{10}}?

I tried to use the Repeat command from this anwer: https://tex.stackexchange.com/a/16192/4011 like this:

\documentclass[a4paper]{article}
\usepackage{pdfpages}


\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \Repeat \prg_replicate:nn
\ExplSyntaxOff
\makeatletter


\begin{document}

\includepdf[page={\Repeat{3}{1,}2},nup=1x2]{mypdf}

\end{document}

But it endet up with ERROR: Package pdfpages Error: Cannot find file1,1,1,2'`

I guess this is an expansion problem.

student
  • 29,003

1 Answers1

1

You can try

\makeatletter
\define@key{pdfpages}{pages}{\AM@CheckValue{pages}{#1}%
                             \edef\AM@pagestemp{#1}}%\edef instead of \def

But this can lead to problems if the value of pages contains things which don't like expansion.

Ulrike Fischer
  • 327,261