Changes

Jump to navigation Jump to search
2,109 bytes added ,  12:05, 21 March 2008
New solution for document title.
\starttext
\startalignment[center]
\blank[force,2*big]
{\tfd How to do this in Context}
\blank[3*medium]
\def\maketitle{%
\startalignment[center]
\blank[force,2*big]
{\tfd \@title}
\blank[3*medium]
The typeset result is, of course, identical to the previous version. Now, the <code>t-title.tex</code> macros can be shared between any number of documents,
and changes will affect all of the documents that use this file.
 
== In ConTeXt: A more advanced solution ==
 
The next solution use a interface inspired by the ones from the core commands and tries to go away from hard coded values.
 
The values for the title are set with the <code>\setuptitle</code> command, it provides two arguments where the second argument is optional and could be used to change the layout for the three text blocks. The title block itself is placed with the <code>\placetitle</code> command.
 
<texcode>
\unprotect
 
\definesystemvariable {dt} % DocumentTitle
 
\def\setuptitle
{\dodoubleempty\dosetuptitle}
 
\def\dosetuptitle[#1][#2]%
{\ifsecondargument
\dodosetuptitle[#1][#2]%
\else
\dodosetuptitle[\v!content][#1]%
\fi}
 
\def\dodosetuptitle[#1][#2]%
{\def\dododosetuptitle##1%
{\getparameters[\??dt##1][#2]}%
\processcommalist[#1]\dododosetuptitle}
 
\def\placetitle
{\startalignment[\v!middle]
\blank[\v!force,2*\v!big]
\doattributes{\??dt\c!title}\c!style\c!color\@@dtcontenttitle
\blank[3*\v!medium]
\doattributes{\??dt\c!author}\c!style\c!color\@@dtcontentauthor
\blank[2*\v!medium]
\doattributes{\??dt\c!date}\c!style\c!color\@@dtcontentdate
\blank[3*\v!medium]
\stopalignment}
 
\setuptitle
[\c!title]
[\c!style=\tfd,
\c!color=]
 
\setuptitle
[\c!author,\c!date]
[\c!style=\tfa,
\c!color=]
 
\setuptitle
[\c!title=,
\c!author=,
\c!date=\currentdate]
 
\protect
</texcode>
 
To reuse the definition above you could save the code in module like <code>t-title.tex</code> and load it in your document with <code>\usemodule[title]</code>.
 
<texcode>
\setuptitle
[title={How to do this in Context},
author={The author},
date={July 26, 2005}]
 
\starttext
 
\placetitle
 
Then, the actual text of the document starts here. We'll put in enough text to
fill out the line and start to make a paragraph.
 
\stoptext
</texcode>
 
The definition for the macro <code>\placetitle</code> could be extended without problems to change the values for the space before and after the title block or the distance between all elements with the <code>\setuptitle</code> command.
== Adding markings to headers and footers ==
gardener
110

edits

Navigation menu