Coloured background on part of a page

backgroundscoloreso-pictikz-pgf

I am trying to colour the background of the top fifth of a page. I thought that I should use eso-pic and tikz for this, and came up with the following:

\documentclass{scrbook}

\usepackage{eso-pic}
\usepackage{tikz}

\usepackage{lipsum}

\begin{document}

\AddToShipoutPictureBG{%
\begin{tikzpicture}
\node[rectangle, fill = blue, minimum width = \paperwidth, minimum height = \paperheight * 0.2] {};
\end{tikzpicture}}

\lipsum

\end{document}

This adds the background to the bottom of the page. How can I put it at the top?

I would also be happy to hear suggestions about how to do this whole thing better.

Best Answer

Wrap the tikz picture inside the AtPageUpperLeft command and set the the node anchor to north west

\documentclass{scrbook}

\usepackage{eso-pic}
\usepackage{tikz}

\usepackage{lipsum}

\begin{document}
%
\AddToShipoutPictureBG{%
\AtPageUpperLeft{\begin{tikzpicture}[overlay]
\node[rectangle, fill = blue, minimum width = \paperwidth,outer sep=0pt, minimum height = 0.2\paperheight, anchor =north west]{};
\end{tikzpicture}}
}

\lipsum

\end{document}

enter image description here