
会議のために約 100 個の tex ファイルを処理する必要があります。各ファイルにはプレゼンテーションの要約が含まれており、著者は 1 人です。各ファイルの関連部分が次の TeX または LaTeX マクロ (コマンドまたは環境) の引数であると仮定します。
TITLE
% 論文のタイトル
AUTHOR
% 著者 (LastName、FirstName の形式で指定)
AFFILIATION
% 著者の所属(メールアドレスを含む)
ABSTRACT
% プレゼンテーションの要約
REFERENCES
% 紹介された参考文献の短いリスト\bibitem
著者の姓順に並べられたプレゼンテーションの要旨、目次、および所属を含む参加者の並び替えられたリストを含む文書を入手したいと思います。
まず、著者が提出した tex ファイルを削除して、関連する情報 (上記) のみを残すことを考えましたが、次に「アルゴリズム」方式 (手動による並べ替えやその他の「手動」の方法なし) でどのように進めればよいかわかりません。
同様の質問を見ましたここしかし、ソート問題の解決策を見つけることができませんでした。
答え1
その間に、並べ替えの部分を除いて、問題を部分的に解決したので、皆さんの貴重なコメントや提案を期待しながら、それを皆さんと共有しようと思いました。
私は「外部」ソートを選択し、その結果をメインの tex ファイルに直接貼り付けました。これが最も簡単なオプションのようです。バンドルの使用も考えましたdatatool
が、TeX 外部の単純なテキスト ソートを使用した場合、ソートには数秒しかかかりませんでした。
データは、次の構造を持つ単純なテキスト ファイルを使用して著者から収集されます。
\AUTHOR{}{} %% <--- {LastName}{FirstName}
\EMAIL{}
\AFFILIATION{}
\TITLE{}
\ABSTRACT{}
メイン ファイルはこれらのファイルを読み取り、次の最小限の例 (3 つのファイルを読み取ります) のように、Abstract Book の内容を生成します。ここで、マクロは外部ファイルで定義されていますabstractbook.sty
。
\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}
このabstractbook.sty
ファイルは上記のすべてのマクロを定義します。ファイルを処理するときに、メインの tex ファイルと同じフォルダーから\processfile{NameOfFile}
内容を読み取ります。それぞれがローカル カウンター (読み取ったファイルの数をカウント) を増加させ、次のマクロを定義します。NameOfFile.tex
\processfile{...}
\author-<x>-LastName
\author-<x>-FirstName
\affiliation-<x>
\email-<x>
\title-<x>
\abstract-<x>
ここで<x>
、カウンターの現在の値です。
ドキュメントをタイプセットするときに、カウンターのすべての値を循環して必要な情報を表示するだけです。
の最小限の例を次に示しますabstractbook.sty
。(それほど難しくなく) 読みやすいと思います。
\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
}%
}
以下の要約ファイルの最小限の例も検討してください。
FirstAuthor.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AUTHOR{First}{Author}% <--- {LastName}{FirstName}
%%
\EMAIL{[email protected]}
%%
\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{[email protected]}
%%
\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{[email protected]}
%%
\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.
\]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
この最小限の例の結果は次のファイルになります。