In a text file titles.txt, I have the title, category and filenames of all the documents I wish to insert in TeX file.
I can properly insert the title and the category (used with \index) but unfortunately I can not use the filename since \includepdf added extra space that I can't remove.
The structure of the text file is the following:
title1
category1
filename1
tilte2
category2
filename2
etc..
Here is the code:
\newcounter{numexos}
\setcounter{numexos}{1}
\newread\myfile
\newcommand*\readfile{%
\immediate\openin\myfile=titles.txt\relax
\loop\unless\ifeof\myfile
\read\myfile to\mybtitle
\read\myfile to\mycategory
\read\myfile to\myfname
\ifeof\myfile\else
\index{\mycategory}
\includepdf[addtotoc={1, section, 1 , \mybtitle, \numexos },fitpaper=true,pagecommand={}]{\myfname.pdf}
\addtocounter{numexos}{1}
\fi
\repeat
\immediate\closein\myfile
}
Instead of using the filename stored in the TXT file I can use the counter if possible: I've tried but I failed for the same reasons : additionnal space in the filename:
01 .pdf