tikz-pgf – How to Prevent TikZ Rectangle from Hiding Text

marginstext manipulationtikz-pgf

Using this code to achieve an effect as in the question Page border coloured.

\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\pageframe}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[blue!25!] (current page.north east) rectangle (current page.south west);
\fill[white, rounded corners] ([xshift=-10mm,yshift=-17mm]current page.north east) rectangle ([xshift=10mm,yshift=17mm]current page.south west);
\end{tikzpicture}%
}

The code draws a whole-page coloured rectangle and a rounded white rectangle in between the page to create a white area for text.

But any text is not showing through (though it is selectable in PDF reader and appears as white text against white background rectangle)!

enter image description here

Best Answer

In the linked question the page frame is drawn in the footer. Moving the page frame into the header instead will change the order and should display the frame before, i.e. below, the text.

To give an explanation: As far I know the page is processed the following way: The main text is typeset and TeX collects a page worth of text. It then places the header on the page, followed by the already processed text and finally adds the footer. So material in the footer is placed above the text while material in the header is placed below it. It surprises me that the code in the linked question works as it is.