[NTG-context] Background for current page only

Wolfgang Schuster schuster.wolfgang at googlemail.com
Sat Apr 4 10:45:09 CEST 2009


Am 03.04.2009 um 22:54 schrieb Khaled Hosny:

> How to set a background for the current page only? \setupbackgrounds
> sets backgrounds for all pages, I don't seem to find a way to turn it
> on/off for certain pages (\setupbackgrounds[state=start/stop] has no
> effect).


Tricky thing, here is a (not so) quick and dirty solution.

\unprotect

\let\!!savedbackgroundcolor\empty

\def\onbackground
   {\globallet\@@mapagebackgroundcolor\!!savedbackgroundcolor}

\def\offbackground
   {\globallet\!!savedbackgroundcolor\@@mapagebackgroundcolor
    \globalletempty\@@mapagebackgroundcolor}

\def\nobackground
   {\globallet\@@mapagebackgroundcolor\!!savedbackgroundcolor
    \globalletempty\@@mapagebackgroundcolor
    \appendtoks\globallet\@@mapagebackgroundcolor\!! 
savedbackgroundcolor\to\afterpage}

\def\gobackground
   {\globallet\@@mapagebackgroundcolor\!!savedbackgroundcolor
    \appendtoks\globalletempty\@@mapagebackgroundcolor\to\afterpage}

\protect

\setupcolors[state=start]
\setupbackgrounds[page][background=color,backgroundcolor=lightgray] 
\offbackground

\starttext
\input tufte
\page
\gobackground
\input tufte
\page
\input tufte
\stoptext

Wolfgang



More information about the ntg-context mailing list