3

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

\documentclass[]{scrbook}
\usepackage{authblk}
\usepackage{pdfpages}
\newcommand{\insertpaper}[4]%
           { % Syntax: \insertmydocument{Toc level}{Title}{Subtitle}{File}
             % Requires: tocloft hyperref pdfpages
             \newpage
             \phantomsection
             \cftaddtitleline{toc}{#1}{#2}{\thepage}
             \cftchapterprecistoc{#3}
            \includepdf[pages=-, pagecommand={\pagestyle{plain}}]{#4}
           }
\begin{document}
\tableofcontents
\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}
\end{document}

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

\documentclass{scrartcl}
\usepackage{luatextra}
\usepackage{filecontents}

\begin{filecontents}{testdata.dat}
Title of the page
A.U. Thor1
A.U. Thor2
\end{filecontents}

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

      tex.print(line.."\\\\")
    end
  end
\end{luacode}

\begin{document}
  \directlua{readtxt()}
\end{document}

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
3

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}
\finishauthors

Now you can use the data:

\documentclass[]{scrbook}
\usepackage{authblk,tocloft}
\usepackage{pdfpages}
\usepackage{hyperref}
\newcommand{\insertpaper}[1]%
  {% #1 is the file name (without extension)
   \clearpage
   \renewcommand\papertitle{}% reinitialize
   \renewcommand\paperauthors{}% reinitialize
   \input{#1-titleauthors.dat}%
   \phantomsection
   \cftaddtitleline{toc}{chapter}{\papertitle\ --- \paperauthors}{\thepage}%
   \includepdf[pages=-, pagecommand={\pagestyle{plain}}]{#1}%
}
\newcommand\papertitle{}% initialize
\newcommand\paperauthors{}% initialize
\newcommand{\thispapertitle}[1]{\renewcommand\papertitle{#1}}
\makeatletter
\newcommand{\thispaperauthor}[2]{%
    \g@addto@macro\paperauthors{#1}%
  \ifx#2\finishauthors
    % no more authors
  \else
    \g@addto@macro\paperauthors{, }%
    \expandafter\thispaperauthor % reinsert the swallowed token
  \fi
}
\makeatother

\begin{document}
\tableofcontents
\insertpaper{paper1}
\end{document}

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.