这种布局可能出现在汇编、期刊、杂志或书籍的首页中,每个作者都有单独的条目或文章。
我正在尝试生成一个目录,其中作者、页码、标题的顺序位于一行上(如果标题很长,则需要多行)。目录看起来应该像这样(没有破折号):
作者 ----- 页码 ------ 文章标题
Jane doe --- 11 --------- 来自行星 x 的光谱波长落叶
(作者可能将名字和姓氏作为单独的字段)
我根据一个解决方案拼凑了一个无法正常工作的样本,该解决方案在左侧显示页码,其后是文章标题,标题下方显示作者(作者:F.Mittelbach)。从该解决方案开始,我无法生成布局(作者、页面、标题)。此外,我无法访问作者或机构名称(即,如果我想的话,无法在文本中使用它)。
我尝试了许多“基本代码”的变体,但仍然没有成功。我希望有人能指出我遗漏或不理解的内容——这将非常有帮助。其中包括一个 mwe。
\documentclass{book}
\usepackage{titletoc}
\newcommand\tocauthor[1]{\\\textmd{#1}}
\newcommand\tocinstitution[1]{}
\newcommand\newpaper[3]{%
\clearpage
\chapter*{#1}%
\addcontentsline{toc}{chapter}{#1\tocauthor{#2}\tocinstitution{#3}}
\textbf{#2}\\
\textit{#3}\par
\vspace{5mm}%
}
% FM's code works: page#,title\\ author -- but not quite what I want
%\titlecontents{chapter}[3pc] % type, left indent
% {\addvspace{1.4pc}\bfseries}% above code
% {} % numbered entry format
% {{\hspace*{-3pc}\makebox[3pc] % numberless entry format
% {\thecontentspage. \hfil}}}
% {} % page format
% [\addvspace{.2pc}] % below code
% one of the many variations tried, compiles, but incorrect display
\titlecontents{chapter}[0pt]% type,left indent
{\addvspace{1.4pc}\bfseries} % above code
{\contentslabel[\tocauthor]{\Huge\thecontentspage\quad}}% numbered entry format
{} % numberless entry format
{} % page format
% [ ]% below code
\setcounter{tocdepth}{0}
\begin{document}
\tableofcontents
\newpaper{Title of the first paper}{Jane Doe}{Institution}
The author is \tocauthor from nsf.
\newpaper{The second paper}{Fred Smith}{Round Yonder}
Ever been to \tocinstitution by the bay?
\end{document}
答案1
\tableofauthors
下面我从头创建了一个类似 ToC 的版本,没有任何包:
\documentclass{book}
\makeatletter
\newcommand{\l@author}[2]{%
\begin{tabular}[t]{@{}
p{.25\linewidth}
p{3em}
p{\dimexpr.75\linewidth-3em-4\tabcolsep}@{}}
\expandafter\@secondofthree#1 & % Author
\makebox[3em]{#2} & % Page
\expandafter\@firstofthree#1 % Title
\end{tabular}\par}
\newcommand{\tableofauthors}{% Very similar to \tableofcontents
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{List of papers
\@mkboth{%
\MakeUppercase{List of papers}}{\MakeUppercase{List of papers}}}%
{\setlength{\parindent}{0pt}\@starttoc{aut}}%
\if@restonecol\twocolumn\fi
}
\newcommand{\@firstofthree}[3]{#1}
\newcommand{\@secondofthree}[3]{#2}
\makeatother
\providecommand{\tocauthor}{}
\providecommand{\authorinstitution}{}
\newcommand{\printtocauthor}{\textmd}
\newcommand{\printinstitution}{\textit}
\newcommand{\newpaper}[3]{% \newpaper{<title>}{<name>}{<institution>}
\clearpage
\chapter*{#1}%
\addcontentsline{aut}{author}{{#1}{#2}{#3}}
\renewcommand{\tocauthor}{#2}\printtocauthor{#2} \par
\renewcommand{\authorinstitution}{#3}\printinstitution{#3}\par
\vspace{5mm}%
}
\AtBeginDocument{%
\addtocontents{aut}{%
\protect\makebox[.25\linewidth][l]{\textbf{Author}}\hfill%
\protect\makebox[3em]{\textbf{Page}}\hfill%
\protect\makebox[\dimexpr.75\linewidth-3em-4\tabcolsep][l]{\textbf{Title}}%
\par\medskip}}
\begin{document}
\tableofauthors
\newpaper{Title of the first paper}{Jane Doe}{Institution}
The author is \tocauthor{} from somewhere.
\newpaper{The second paper}{Fred Smith}{Round Yonder}
Ever been to \authorinstitution{} by the bay?
\newpaper{This is a very long paper title so it must be extremely interesting}{Who Cares}{Randomville}
This is another \tocauthor{} release from \authorinstitution.
\end{document}
如果需要,可以扩展它以适应作者的名字/姓氏规定。