3

I need to process about 100 tex files for a conference. Each file contains an abstract of a presentation and has one author. Let us assume that the relevant parts of each file are arguments of the following TeX or LaTeX macros (commands or environments):

TITLE % the title of the paper

AUTHOR % the author (given as: LastName, FirstName)

AFFILIATION % the author's affiliation (including e-mail address)

ABSTRACT % the abstract of the presentation

REFERENCES % short list of references introduced with \bibitem

I would like to obtain a document that contains the abstracts of the presentations sorted after the LastName of the author, together with a table of contents and a sorted list of the participants that would include their affiliation.

I thought of first stripping the tex files that the authors submitted and leave only the relevant information (mentioned above), but I don't know how I should proceed next, in an "algorithmic" way (without any manual sorting or other "manual" methods).

I looked over a similar question here, but I couldn't find a solution to the sorting problem.

digital-Ink
  • 3,083
  • I think if you edit your question to provide three sample source files that display all the complexities you expect to encounter it will be easier for someone here to help. – Ethan Bolker Jun 09 '16 at 01:05
  • In the mean time, I have partially solved the problem, except for the sorting part. I did an "external" sort and pasted the result directly in the tex file. I thought of using the 'datatool' bundle, but the sorting just took me a few seconds using a simple text sorting outside TeX. I will post the details later. – digital-Ink Jun 11 '16 at 20:20

1 Answers1

2

In the meantime, I have partially solved the problem, except for the sorting part and thought of sharing it with you, expecting your valueable comments and suggestions.

I chose to make an "external" sort and pasted the result directly in the main tex file, since it seems the easiest of the options. I thought of using the datatool bundle, but the sorting just took me a few seconds using a simple text sorting outside TeX.

The data is collected from authors using a simple text file with the following structure:

\AUTHOR{}{} %% <--- {LastName}{FirstName}
\EMAIL{}
\AFFILIATION{}
\TITLE{}
\ABSTRACT{}

The main file reads these files and produces the contents of the Abstract Book, as in the following minimal example (where we read three files), where the macros are defined in the external abstractbook.sty file:

\documentclass[a4paper,12pt]{article}
\usepackage{abstractsbook}

\begin{document}

%% ++++++++++ Process submitted files ++++++++++++++++++

\begin{processfiles}
    %% ---------------------------------------
    \processfile{FirstAuthor}
    \processfile{SecondAuthor}
    \processfile{ThirdAuthor}
    %% First sorted alphabetically outside TeX
\end{processfiles}

\parindent 0pt
%% +++++++++++++++++++ List of Talks  ++++++++++++++++++

\listoftalks

%% +++++++++++++++++++ Abstracts ++++++++++++++++++++++

\abstracts

%% +++++++++++++++++++ Index of participants +++++++++++

\listofparticipants

%% +++++++++++++++++++++++++++++++++++++++++++++++++++++
\end{document}

The abstractbook.sty file defines all the above macros. When processing files, \processfile{NameOfFile} reads the contents of NameOfFile.tex from the same folder with the main tex file. Each \processfile{...} increases a local counter (counting the number of read files) and defines the following macros:

\author-<x>-LastName

\author-<x>-FirstName

\affiliation-<x>

\email-<x>

\title-<x>

\abstract-<x>

where <x> is the current value of the counter.

When typesetting the document, we just cycle through all the values of the counter and display the required info.

See a minimal example below for the abstractbook.sty. I hope it is (not so hard) readable:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{abstractsbook}
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++
\RequirePackage{ifthen}
%% ----- some shortcuts ------
\let\ea=\expandafter
\let\cs=\csname
\let\ecs=\endcsname
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++

\newenvironment{processfiles}
    {\newcount\numabs % <--- TeX local counter that counts
                      %      the number of abstracts
     \numabs=0\relax
     \newcounter{numabs} % <--- LaTeX global counter
    }
    {\setcounter{numabs}{\the\numabs}
      % < --- saving the final (local) value of \numabs
    } %       for global later use

\long\def\processfile #1{%
                         \advance\numabs by 1\relax
                         \input{#1.tex}
                        }%

\long\def\AUTHOR #1#2{%
                     \ea\long\ea\gdef\cs author-\the\numabs-LastName\ecs{#1}%
                     \ea\long\ea\gdef\cs author-\the\numabs-FirstName\ecs{#2}%
                     }

\long\def\AFFILIATION #1{%
                        \ea\long\ea\gdef\cs affiliation-\the\numabs\ecs{#1}
                       }

\long\def\EMAIL #1{%
                  \ea\long\ea\gdef\cs email-\the\numabs\ecs{#1}
                 }
%%
\long\def\TITLE #1{%
                  \ea\long\ea\gdef\cs title-\the\numabs\ecs{#1}
                 }
%%
\long\def\ABSTRACT #1{%
                     \ea\long\ea\gdef\cs abstract-\the\numabs\ecs{#1}
                    }

% ++++++++++++++  List of Talks ++++++++++++++++++++++++++++++++++++++++++++++

\def\heading #1{\cleardoublepage{\LARGE\scshape #1}\par\hrulefill\vskip 6ex}

\long\def\listoftalks
    {
     \heading{List of Talks}
     \newcount\@i
     \@i=1\relax
     \whiledo{\the\@i<\numexpr \thenumabs+1\relax}
        {\begin{minipage}{\textwidth}
             \vskip 1.5ex
             \leftskip 0em
             \textsc{\cs author-\the\@i-FirstName\ecs}~\MakeUppercase{\cs author-\the\@i-LastName\ecs}
             \par\leftskip 2.5em
             \textit{\cs title-\the\@i\ecs}\dotfill\pageref{marker-\the\@i}
        \end{minipage}
        \advance \@i by 1\relax
        }%
     }

% ++++++++++++++  List of Participants  +++++++++++++++++++++++++++++++++++++

\long\def\listofparticipants
    {\heading{List of Participants}
     \newcount\@i
     \@i=1\relax
     \whiledo{\the\@i<\numexpr \thenumabs+1\relax}
        {\begin{minipage}{\textwidth}
                \textbf{\MakeUppercase{\cs author-\the\@i-LastName\ecs}},~\textbf{\cs author-\the\@i-FirstName\ecs}
                \vskip 1ex
                \textit{\cs affiliation-\the\@i\ecs}
                \vskip 0.25ex
                \texttt{\cs email-\the\@i\ecs}
         \end{minipage}
         \vskip 4ex
         \advance \@i by 1\relax
        }%
    }

% +++++++++++++++  Abstracts of Talks +++++++++++++++++++++++++++++++++++++++++

\long\def\abstracts
    {\heading{Abstracts of Talks}
     \newcount\@i
     \@i=1\relax
     \whiledo{\the\@i<\numexpr \thenumabs+1\relax}
        {%
         \begin{minipage}{\textwidth}
            \label{marker-\the\@i} % <--- used for later referencing of the page
            \begin{center}
                \textsc{\Large \cs title-\the\@i\ecs}
                \vskip 1.5ex
                \textbf{\Large \cs author-\the\@i-FirstName\ecs~\cs author-\the\@i-LastName\ecs}
                \vskip 1ex
                \normalsize{\cs affiliation-\the\@i\ecs}
            \end{center}
            \vskip 2.5ex
            \cs abstract-\the\@i\ecs
            \end{minipage}
            \vskip 8ex
            \vfill
            \advance \@i by 1\relax
        }%
     }

Consider also the minimal examples of the abstract files below:

FirstAuthor.tex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AUTHOR{First}{Author}% <--- {LastName}{FirstName}
%%
\EMAIL{first.author@firstuniv.edu}
%%
\AFFILIATION{First University}
%%
\TITLE{The first title}
%%
\ABSTRACT{This is the abstract of the first talk.

And some math: $1+1=2$.

}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

SecondAuthor.tex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AUTHOR{Second}{Author}% <--- {LastName}{FirstName}
%%
\EMAIL{second.author@seconduniv.edu}
%%
\AFFILIATION{Second University}
%%
\TITLE{The second title}
%%
\ABSTRACT{This is the abstract of the second talk.

And some math:

\[
E=m\mathrm{c}^2.
\]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

ThirdAuthor.tex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AUTHOR{Third}{Author}% <--- {LastName}{FirstName}
%%
\EMAIL{third.author@thirduniv.edu}
%%
\AFFILIATION{Third University}
%%
\TITLE{The third title}
%%
\ABSTRACT{This is the abstract of the second talk.

And some math:

\[
\mathrm{e}^{i\pi}+1=0.
\]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The result of this minimal example is the following file:

First Page

Second Page

Third Page

digital-Ink
  • 3,083
  • If OP's tex files are full documents with \documentclass{article} and \end{document}, this won't work. Those commands will still activate. – Teepeemm Mar 13 '18 at 13:57
  • how to add references of each abstract in its same page? and can I categorize abstract in subfolders ?
    I have 4 categories for example folder1..4 etc
    – Don Freecs Oct 15 '22 at 23:04