TransWikia.com

includepdfmerge does not work with numbers in filenames

TeX - LaTeX Asked on June 23, 2021

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} 

One Answer

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@}{%
defAM@checkinteger#1{%
  expandafterAM@checkinteger@expandafter{#1}}
defAM@checkinteger@#1{%
  begingroup
  defdo##1{uccode`##1=`%}%
  dodo1do2do3do4do5do6do7do8do9%
  makeatletter
  catcode`%=9
  endlinecharm@ne
  uppercase{scantokens{defAM@temp{#1}}}%
  ifxAM@temp@empty
    globalAM@integertrue
  else
    globalAM@integerfalse
  fi
  endgroup}%
}{}
makeatother

begin{document}

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

end{document}

Correct answer by Phelype Oleinik on June 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP