0

I have a pdf generated as below. Now I would like to create the index which should be a page listing all the names of papers included, i.e. the names of sections, one row should be dedicated for each paper from the entire pdf. How could I achieve this ? Preferably in XeTeX.

\documentclass[landscape,a4paper]{article}
\usepackage{pdfpages}
\usepackage{pgfmath}
%\usepackage[margin=1cm,showframe]{geometry}% MWE only

\pgfmathsetmacro{\scale}{(\paperheight-2cm)/(\paperwidth-3cm)}% 1cm margin \pgfmathsetlengthmacro{\delta}{\paperwidth-2cm-2\scale(\paperheight-3cm)-4mm}% 4mm fudge factor

\usepackage[footwidth=paper]{scrlayer-scrpage} \pagestyle{plain}

\usepackage{polyglossia} \usepackage{fontspec} \setotherlanguage{hebrew} \newfontfamily\hebrewfont{Arial}

\robustify{\thepage} \renewcommand{\thepage}{\arabic{page} \ \roman{page}\ \texthebrew{\hebrewnumeral{\value{page}}}}

\newcommand\gettitle[1]{% \directlua{% local filename = kpse.find_file("#1", 'graphic/figure') doc = pdfe.open(filename) info = pdfe.getinfo(doc) title = info['Title'] tex.print(title) }}

\begin{document}

% \includepdf[scale=1.02, nup=2x1,pages=1-8,trim=2.5cm 2.5cm 5.5cm 7.0cmB]{sh1.pdf}

%pagecommand={\thispagestyle{plain}}

\includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order trim=2.5cm 2.5cm 5.5cm 7.0cm,picturecommand={\put(.15\paperwidth,3.3cm){\thepage}}]{example-image-a4-numbered.pdf}

\includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order trim=2.5cm 2.5cm 5.5cm 7.0cm,picturecommand={\put(.15\paperwidth,3.3cm){\thepage}}]{example-image-a4-numbered.pdf}

\includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order trim=2.5cm 2.5cm 5.5cm 7.0cm,picturecommand={\put(.15\paperwidth,3.3cm){\thepage}}]{example-image-a4-numbered.pdf} \end{document}

user2925716
  • 1,940
  • 1
    So you want to have something like a list of documents much alike the list of tables ? – alchemist Feb 27 '23 at 13:20
  • @alchemist You're right. Just the name of each paper together with the page on which it begins. Shall I be more precise with this ? Please tell me or provide a MWE . I mean just a separate A4 page with the heading of R0.pdf example-image-a4-numbered.pdf and the rest of chapters included via includepdf. – user2925716 Feb 27 '23 at 13:26

1 Answers1

0

Consider the additions to your code example. This produces a list of documents on a separate page like the list of tables.

\documentclass[landscape,a4paper]{article}
\usepackage{pdfpages}
\usepackage{pgfmath}
%\usepackage[margin=1cm,showframe]{geometry}% MWE only

\pgfmathsetmacro{\scale}{(\paperheight-2cm)/(\paperwidth-3cm)}% 1cm margin \pgfmathsetlengthmacro{\delta}{\paperwidth-2cm-2\scale(\paperheight-3cm)-4mm}% 4mm fudge factor

\usepackage[footwidth=paper]{scrlayer-scrpage} \pagestyle{plain}

\usepackage{polyglossia} \usepackage{fontspec} \setotherlanguage{hebrew} \newfontfamily\hebrewfont{Arial}

\robustify{\thepage} \renewcommand{\thepage}{\arabic{page} \ \roman{page}\ \texthebrew{\hebrewnumeral{\value{page}}}}

% ====== added to the mwe code \usepackage{xpatch} \usepackage[titles]{tocloft}

\newlistof[section]{pdfdoc}{lop}{List of documents}

\newcommand{\pdfdoc}[1]{% \refstepcounter{pdfdoc} \addcontentsline{lop}{pdfdoc}{\protect\numberline{\thepdfdoc} \addvspace{1pt}\sffamily\small \textcolor{blue}{#1}}\par}

\xpatchcmd{\listofpdfdoc}{\chapter}{\section}{}{} \cftsetindents{pdfdoc}{15mm}{10mm}

% ===== end of addition

\newcommand\gettitle[1]{% \directlua{% local filename = kpse.find_file("#1", 'graphic/figure') doc = pdfe.open(filename) info = pdfe.getinfo(doc) title = info['Title'] tex.print(title) }}

\begin{document}

%  \includepdf[scale=1.02, nup=2x1,pages=1-8,trim=2.5cm 2.5cm 5.5cm 7.0cmB]{sh1.pdf}

%pagecommand={\thispagestyle{plain}}

% ===== added to print list of documents \listofpdfdoc \addcontentsline{toc}{section}{List of documents} % =====

\includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
trim=2.5cm 2.5cm 5.5cm 7.0cm,picturecommand={\put(.15\paperwidth,3.3cm){\thepage}}]{example-image-a4-numbered.pdf}
\addcontentsline{lop}{pdfdoc}{example-image-a4-numbered - 1} % <- puts document name into list of documents


\includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
trim=2.5cm 2.5cm 5.5cm 7.0cm,picturecommand={\put(.15\paperwidth,3.3cm){\thepage}}]{example-image-a4-numbered.pdf}
\addcontentsline{lop}{pdfdoc}{example-image-a4-numbered - 2}

\includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
trim=2.5cm 2.5cm 5.5cm 7.0cm,picturecommand={\put(.15\paperwidth,3.3cm){\thepage}}]{example-image-a4-numbered.pdf}
\addcontentsline{lop}{pdfdoc}{example-image-a4-numbered - 3} \phantom{end} % <- needed to add the last entry to the list of documents

\end{document}

Note the addition of \phantom{end} to the last entry. Somehow that is needed to get the last entry into the list in your code. In my own document using the code to get a list of included documents that was not needed.

pdf_lop_list

alchemist
  • 1,761
  • Your answer is good but not exactly what I wanted. Instead of \addcontentsline{lop}{pdfdoc}{example-image-a4-numbered - 2 I wanted that XeTeX itself automatically extracted the title from the file {example-image-a4-numbered.pdf} instead of my coding it by hand. Please is that possible ? – user2925716 Feb 27 '23 at 16:41
  • And please note that everything is and should be in XeLaTeX . – user2925716 Feb 27 '23 at 16:48
  • I used LuaLaTeX compiling the example, so it should be compatible with XeLaTeX. As for that automatically part of your question ... that is beyond my knowledge of TeX and programming. A piece of coding in Lua might be possible, si I hope someone else can help you with that part. – alchemist Feb 27 '23 at 17:10
  • I'm posting a new question here. Anyway I do not think that XeLaTeX would compile Lua. I've tried but it does not. – user2925716 Feb 27 '23 at 17:15
  • No, XeTeX won't compile Lua, but you can switch to a LuaLaTeX compiler easily when using XeTeX. Just try compiling your document using LuaLaTeX and see if there are issues emerging. – alchemist Feb 27 '23 at 17:30
  • This issue has appeared: ! I can't write on file mergeSR.pdf'. Please type another file name for output: ! I can't write on filemergeSR.pdf'. – user2925716 Feb 27 '23 at 17:34
  • That sounds like another program is blocking access to that file. It occurs for example when you have an older version of the file open in an external PDF reader and want to recompile the same file again in a TeX engine. It doesn;t look like a LuaLaTeX related issue. – alchemist Feb 27 '23 at 19:52