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}
Tomáš M.
  • 163
  • 5
  • 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}. –  Feb 28 '15 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 Feb 28 '15 at 11:03
  • @egreg Same on my side. It looks like there is some issue with ppxetex.def – karlkoeller Feb 28 '15 at 11:04
  • @egreg The error actually appears even when using "defined" ranges like 3-5 at my end. – Tomáš M. Feb 28 '15 at 11:11
  • @TomášM. Can you please add \listfiles to a minimal example such as touhami's and show the result you find in the terminal or in the log file after “File List”? – egreg Feb 28 '15 at 11:15
  • 1
    @TomášM. *Now* it's clear! The problem is of course \usepackage[czech]{babel}! But there's hope, don't worry. – egreg Feb 28 '15 at 11:16
  • @egreg The document would actually not compile otherwise, I assumed it was some overzealous l10n thing kicking in, what's the problem with babel? edit: You are right, though! That's strange. – Tomáš M. Feb 28 '15 at 11:17

2 Answers2

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.

egreg
  • 1,121,712
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}  
touhami
  • 19,520