Command/startdocument

From Wiki
Jump to navigation Jump to search


\startdocument ... \stopdocument

Summary

The environment \startdocument ... \stopdocument adds option processing to \starttext.

Settings

\startdocument[...=...,...] ... \stopdocument
...=...,...inherits from \setupdocument

Description

Sometimes it makes sense to have options available at the time of \starttext, for example to typeset a title page. \startdocument allows you to do this either directly by passing arbitrary keys and values to the command itself, or via \setupdocument.

\startdocument by default makes use of two setups: document:start and document:stop.

You can use document:start to construct a title page. You can fetch the passed values by using the \documentvariable command.

Examples

Example 1

% \starttext \stoptext %% needed to fool the wiki
\setuppapersize[A8][A7,landscape]
\setuparranging[2SIDE]
\showframe

\startsetups document:start
   \startalignment[middle]
      \bold{\documentvariable{title}}
   \stopalignment
   \page
\stopsetups

\startdocument[title={Be this the Verse}]

    Start of the document ...

\stopdocument

Elaborate example


\definenamespace
   [documentauthor] % name of internal variables
   [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}})%
     \doifsomething{\authorparameter{affiliation}}{%
         \space\authorparameter{affiliation}}
     \endgraf
    }

\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=bold]
\defineauthor[john][name={John Doe}, email={john.doe@gmail.com}, affiliation={TUG}]
\defineauthor[jill][name={Jill Hough}, email={this@that.com}, color=red]

\setupdocument
     [title={Be this the Verse},
      author={john,jill}]

\startdocument
    Start of the document ...
\stopdocument

This example is based on Abstracting an author list on Stack Exchange.

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: