I could put the following Tikz code on a single page:

``````\tikz[remember picture,overlay]
(current page.north west) rectangle (current page.south east);
``````

However, it fails if I try to use it as a background for all pages.

I was also unsure whether to use overlays or layers -- tried both (see below)

``````\usemodule[t-tikz]

\defineoverlay[sombra][
\tikz[remember picture,overlay]
(current page.north west) rectangle (current page.south east);
]

%\setupbackgrounds[page][background=sombra]

\setlayer[mybg] % name of the layer
%[hoffset=1cm, voffset=1cm]  % placement (from upper left corner of the layer)
{\tikz[remember picture,overlay]
(current page.north west) rectangle (current page.south east);
}  % the actual contents of the layer

\setupbackgrounds[page][background=mybg,
state=repeat % repeat each page
]

\starttext

asdf asdf

\stoptext
``````

## Edit

I was able to get it working with this -- though I've got to fix this white part with some offset I couldn't figure out so far.

``````\setuppagenumbering
[alternative=doublesided]

\setupcolors
[state=start]

\definelayer
[fundo]
[repeat=yes,
width=\paperwidth,
height=\paperheight]

\usemodule[t-tikz]

\setlayer
[fundo]
[preset=middle]
{\tikz[remember picture,overlay]
\shade[top color=green!30, bottom color=blue!30](current page.north west) rectangle (current page.south east);}

\setupbackgrounds
[page]
[background=fundo]

\starttext
asdf
\page
asdf
\stoptext
``````
• You should report it as a bug to Henri Menke (it works with LuaTeX, but not LuaMetaTeX). If you consider another alternative, you could do the same using MetaPost. Jan 26 at 11:59
• @JairoA.delRio, Thanks. I guess it could be fairly simple with Metapost, but adapting the examples from the manual was beyond my capabilities at the moment. Besides, should it work `layer` or `overlay`?
– user9424
Jan 26 at 12:03
• Oh, you only put the TikZ code in the page you need it (no overlays nor layers), the same as LaTeX. If it doesn't compile for you, use `context --luatex <filename>`. If it's helpful, I'll post a solution using MetaPost Jan 26 at 12:06
• Yes, that was another possibility. I guess it worked fairly well now, with one caveat (see edit).
– user9424
Jan 26 at 12:14

While some TikZ wizard comes to explain the way, let me propose the ConTeXt way, explained in the Colors manual:

``````\setuppapersize[A6]
%You could directly apply this with any fill operation
%but it's better to keep it separated for reuse
withshadevector (dir 180) %play with angles to see what happens
%MetaPost understands colors differently
%Hence the white
;
StartPage;
StopPage;
\stopuseMPgraphic
\starttext
\dorecurse{3}%
{
\samplefile{quevedo-es}
\samplefile{knuth}
}
\stoptext
``````

And we have a nice background with no TikZ involved. `:D`

• When you apply a background to the page you can use a overlay without the need for layer, i.e. you can remove the `\definelayer` and `\setlayer` settings and replace them with `\defineoverlay[shade][\useMPgraphic{shade}]`. Jan 26 at 22:26
• @WolfgangSchuster But, unlike layers, overlays don't repeat themselves across pages, right? Or did I miss a key? Jan 26 at 22:27
• Overlays are applied to each page but it works in your example only when I remove `defineshade` and apply the settings to the filled box itself. Jan 30 at 20:08