I would design the interface like this:
\defineauthor[john][name={John Doe}, email={[email protected]}, affiliation={....}]
\defineauthor[jill][name=..., email=..., affiliation=...]
\setupdocument
[title={....},
authors={john, jill}]
\startdocument
....
\stopdocument
Note that ConTeXt already defines a \setupdocument
and \startdocument
... \stopdocument
command that are meant to handle document metadata. \startdocument
calls \starttext
and \stopdocument
calls \stoptext
, so you do not need to explicitly add them (although adding them does no harm). In order for the above setup to work you need to define:
\startsetups document:start
\documentvariable{title} % Use this to get the document title
\documentvariable{author} % Use this to get the list of authors
\stopsetups
\startsetups document:stop
% If you want to place something at the end of a document
\stopsetups
So, all that is left is to define the \defineauthor
command. If you are using MkIV, you may simply use:
\definenamespace
[documentauthor] % name of internal varialbles
[type=module,
name=author,
command=yes, % Create \defineauthor
style=yes, % Create \useauthorstyleandcolor
setup=list, % Create \setupauthor
parent=documentauthor,
]
which will create the required command.
The above may appear like an overkill for adding authors, but it does provide you will the following features:
Inherit keys across authors. Suppose you have multiple authors at the same institute, and you don't want to pass on the affiliation each time. Then you can do:
\defineauthor[univ1][afficiation={TeX University}]
\defineauthor[john][univ1][name=..., email=...]
\defineauthor[jill][univ1][name=..., email=...]
and both john
and jill
will inherit the affiliation from univ1
.
Create an author database: You can create an author database in a separate file and use
\environment author-database
in all your files. This way, you only define the authors once and can use them in all your documents.
EDIT: Here is a complete example:
\definenamespace
[documentauthor] % name of internal varialbles
[type=module,
name=author,
command=yes, % Create \defineauthor
style=yes, % Create \useauthorstyleandcolor
setup=list, % Create \setupauthor
parent=documentauthor,
]
\define[1]\useauthor
{\edef\currentauthor{#1}%
{\useauthorstyleandcolor{style}{color}
\authorparameter{name}}%
\space
(\mono{\authorparameter{email}})}
\startsetups document:start
\startalignment[middle]
{\ssbfc\setupinterlinespace
\documentvariable{title}
\endgraf}
\blank[medium]
\processcommacommand[\documentvariable{author}]\useauthor
\blank[big]
\stopalignment
\stopsetups
\startsetups document:stop
% If you want to place something at the end of a document
\stopsetups
\setupauthor[style=sansbold]
\defineauthor[john][name={John Doe}, email={[email protected]}]
\defineauthor[jill][name={Jill Doe}, email={[email protected]}]
\setupdocument[title={Random title}, author={john,jill}]
\startdocument
\input knuth
\stopdocument