Changes

Jump to navigation Jump to search
106 bytes added ,  04:06, 27 April 2006
m
<texcode>
It starts, surprisingly enough, with a line saying
<pretexcode>
\startmodule[bgcolor]
</pretexcode>
Since we need to use some internal parameters, we have to "unprotect" the
contents of the module:
<pretexcode>
\unprotect
</pretexcode>
The next step is to set up the module with default parameters:
<pretexcode>
\setupmodule[color=red]
</pretexcode>
Our strategy will be to define a variable <tt>\BColor</tt> for the background color which
So we define a macro <tt>\BColor</tt> and define it:
<pretexcode>
\processaction[\currentmoduleparameter{color}]
[blue=> \def\BColor{blue},
\v!unknown=> \def\BColor{white},
\v!default=> \def\BColor{red}]
</pretexcode>
We then use this variable to define the background of our document:
<pretexcode>
\setupbackgrounds[page][background=color,backgroundcolor=\BColor]
</pretexcode>
And that's it! We now just have to finish the module with these lines:
<pretexcode>
\protect
\stopmodule
\endinput
</pretexcode>
A simple test document will look like this:
<pretexcode>
\setupcolors[state=start]
\usemodule[bgcolor][color=blue]
\stoptext
</pretexcode>
This is just meant as a first example; of course, there are many more possibilities to use this mechanism. If you want to use the parameters directly in your code, you can use the form <tt>\getmoduleparameter{color}</tt>.
-- [[User:Thomas|Thomas]] 18:28, 26 April 2006 (CEST) --
 
[[Category:Modules]]
[[Category:Inside ConTeXt]]

Navigation menu