6

The documentation says the following:

E.g.: pages=- will insert all pages of the document [...]

however, when I put \includepdf[pages=-]{foobar.pdf} in my LaTeX doc (compiled w/ xelatex), I get this error:

! Package pdfpages Error: Cannot find file `-'.

Similarly, just using a range like \includepdf[pages={1,3,5-last}]{foobar.pdf} results in:

 <use  "foobar.pdf" >
! Missing = inserted for \ifnum.
<to be read again> 
                   -
l.91 ...df[pages={1,3,5-last}]{foobar.pdf}

I'm using the latest pdfpages downloaded from CTAN.

Any idea where could the problem lie?

edit:
MWE:

\documentclass{article}
\usepackage{pdfpages}
\usepackage[czech]{babel}
\begin{document}

\includepdf[pages={1,3-5}]{foobar.pdf}
\end{document}
7
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Commented Feb 28, 2015 at 10:57
  • In my experiment, lines like \includepdf[pages=-]{foobar.pdf} and \includepdf[pages={1,3-5}]{foobar.pdf} succeed, but I get failure when I try pages={1,3-last}.
    – egreg
    Commented Feb 28, 2015 at 11:03
  • @egreg Same on my side. It looks like there is some issue with ppxetex.def Commented Feb 28, 2015 at 11:04
  • @egreg The error actually appears even when using "defined" ranges like 3-5 at my end.
    – Tomáš M.
    Commented Feb 28, 2015 at 11:11
  • 1
    @TomášM. Now it's clear! The problem is of course \usepackage[czech]{babel}! But there's hope, don't worry.
    – egreg
    Commented Feb 28, 2015 at 11:16

2 Answers 2

8

The problem is the same as in Slovak (and Czech) babel gives problems with cmidrule and cline: the czech option to babel makes the - character into a shorthand and this disrupts the working of the pages option.

Quick fix:

\shorthandoff{-}\includepdf[pages=1,3-5]{foobar.pdf}\shorthandon{-}

Better fix:

\documentclass{article}
\usepackage[czech]{babel}
\usepackage{pdfpages}

\usepackage{regexpatch}

\makeatletter
\xpatchparametertext{\AM@checkrange}{-}{\cA-}{}{}
\xpatchparametertext{\AM@checklast}{-}{\cA-}{}{}
\regexpatchcmd{\AM@readlisti}{-}{\cA-}{}{}
\makeatother

\begin{document}

\includepdf[pages={1,3-4}]{largefrac.pdf}

\end{document}

Note that, for some reasons, the last keyword doesn't work with XeLaTeX, but specifying 3- instead of 3-last is fine.

1
  • Today the command "\includepdf[pages={1,3-4}]{largefrac.pdf}" help me a lot. Thanks Commented Jun 10, 2016 at 19:01
0

I just copile this code and it work very good

\documentclass{report}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{31roegel.pdf}
\end{document}  

for the second problem use

\documentclass{report}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={1,5-}]{31roegel.pdf}
\end{document}  
10
  • 1
    Try to use pages={1,3-last} and compile with xelatex Commented Feb 28, 2015 at 11:06
  • that does not work but pages={1,3-} do the job
    – touhami
    Commented Feb 28, 2015 at 11:11
  • This does not answer the question, anyway. Commented Feb 28, 2015 at 11:12
  • Why? help me to see the problem
    – touhami
    Commented Feb 28, 2015 at 11:14
  • @touhami The same code doesn't work on my end.
    – Tomáš M.
    Commented Feb 28, 2015 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .