1

I am trying to merge some pdf files in one document. My filenames are numbers and it occurs that \includepdfmerge has problems with numbers as filenames. Does anyone have a solution?

\documentclass{article}
\usepackage{pdfpages}
\begin{document}


\includepdfmerge[]{test.pdf, 1} %works
\includepdfmerge[]{133.pdf, 1} %does not work

\end{document} 
2
  • It works for me on TeXLive 2020. What's your TeX distribution and what doesn't work? Commented Dec 19, 2020 at 14:50
  • I have TeXlive 2017. I get the message ! Missing = inserted for \ifnum. <to be read again> . l.35 \includepdfmerge[nup=2x1]{{1365.pdf}} ?
    – user125198
    Commented Dec 19, 2020 at 15:03

1 Answer 1

2

This was a bug in older versions of pdfpages, in which it tried to parse the argument to check if it was a file name or a page number, and failed because the file name starts with a number. You should update your system to fix the issue. Meanwhile, here's a patch to fix the wrong detection of the page number (not sure how well that interacts with the rest of pdfpages, so you really should update instead):

\documentclass{article}
\usepackage{pdfpages}

% Fix pdfpages < 2019
\makeatletter
\@ifundefined{AM@checkinteger@}{%
\def\AM@checkinteger#1{%
  \expandafter\AM@checkinteger@\expandafter{#1}}
\def\AM@checkinteger@#1{%
  \begingroup
  \def\do##1{\uccode`##1=`\%}%
  \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  \makeatletter
  \catcode`\%=9
  \endlinechar\m@ne
  \uppercase{\scantokens{\def\AM@temp{#1}}}%
  \ifx\AM@temp\@empty
    \global\AM@integertrue
  \else
    \global\AM@integerfalse
  \fi
  \endgroup}%
}{}
\makeatother

\begin{document}

\includepdfmerge[]{testx.pdf, 1} %works
\includepdfmerge[]{133.pdf, 1} %also works

\end{document}
2
  • 1
    update solved the problem. Thanks
    – user125198
    Commented Dec 19, 2020 at 18:05
  • @Arno Good! No need for weird hacking :) Commented Dec 19, 2020 at 18:06

You must log in to answer this question.

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