0

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.

2 Answers 2

1

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

3
  • Could you explain why I need remember picture and overlay? And an outer sep of 0pt? It seems that I get the result that I want with only overlay.
    – twsh
    Oct 2, 2021 at 12:40
  • 1
    @twsh for the outer sep option try for example outer sep=1cm to see the effect. For the overlay option I don't know why it is required bu without it this will not work. For the remember picture option we don't need it at all and I will remove it . Oct 2, 2021 at 12:59
  • @twsh an edit has been made. The correct command to use to have the picture on every page and not only on the current one is \AddToShipoutPictureBG without the "*" Oct 2, 2021 at 13:30
5

You don't need to use a hammersledge like tikz for that: a simple coloured rule will do:

\documentclass{scrbook}
\usepackage[svgnames]{xcolor}
\usepackage{eso-pic}

\usepackage{lipsum}

\begin{document}
%
\AddToShipoutPictureBG*{%
\AtPageUpperLeft{\color{CornflowerBlue!40}\rule[-0.2\paperheight]{\paperwidth}{0.2\paperheight}}
}%

\lipsum

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .