This problem relate with other my question here . I found a solution with pdfpages package thanks to TX.SX:

           { % Syntax: \insertmydocument{Toc level}{Title}{Subtitle}{File}
             % Requires: tocloft hyperref pdfpages
            \includepdf[pages=-, pagecommand={\pagestyle{plain}}]{#4}
\insertpaper{chapter}{Title o the 1st paper}{A.U. Thor11, A.U. Thor12}{paper1.pdf}
\insertpaper{chapter}{Title o the 2nd paper}{A.U. Thor21, A.U. Thor22}{paper2.pdf}

For production conference proceedings, I use pdfpages, as shown in example with LuaLaTeX. The macro \insertpaper adds a titles and authors of the papers in TOC. But for doing this, I manually write a desirable fields (e.g. title and authors) of the PDF. My papers (PDFs) also created by LuaLaTeX with scrartcl class and with authblk package for creating author and affiliations. Now my idea is not to manually fill corresponding fields, but read them from a file. That is, before paper.tex should write desirable fields into appropriate file.

It would be nice if the \insertpaper would have only one parameter filename and information about the required fields read from the appropriate information file.

Thus, I need some help for creation such procedures with Lua (desirable) or LaTeX3 or something else.

I found a some solution how to read the data


Title of the page
A.U. Thor1
A.U. Thor2

  function readtxt()
    file = io.open("testdata.dat", "r")
    for line in file:lines() do



but I have no idea how to substitude the data into desirable command, \insertpaper for example.

  • You shouldn't use tocloft with KOMA. – Johannes_B Jan 16 '15 at 16:50

If you follow the suggestion given in my answer to How to write authors of an article to the file?, when you compile paper1.tex you'll have a file called paper1-titleauthors.dat which will contain something like

\thispapertitle{Title of the article}
\thispaperauthor{First Author}
\thispaperauthor{Second Author}

Now you can use the data:

  {% #1 is the file name (without extension)
   \renewcommand\papertitle{}% reinitialize
   \renewcommand\paperauthors{}% reinitialize
   \cftaddtitleline{toc}{chapter}{\papertitle\ --- \paperauthors}{\thepage}%
   \includepdf[pages=-, pagecommand={\pagestyle{plain}}]{#1}%
\newcommand\papertitle{}% initialize
\newcommand\paperauthors{}% initialize
    % no more authors
    \g@addto@macro\paperauthors{, }%
    \expandafter\thispaperauthor % reinsert the swallowed token


This is the contents page you'd get; of course different formattings of the contents line can be defined.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.