# Rectangle as background for header

I'm having a horrible problem with fancyhdr and tikz that I was hoping you'd be able to solve for me.

I've tried desperately to get a simple, colored rectangle to show up as background for my headers, much like in the attached picture.

However, for the life of me, no matter what I try, I can't seem to get something like this done. I've been able to draw rectangles, sure, but none of them have the following characteristics:

• Same width as the page's;
• Same height as the header text.

Can you please help me? I have no idea how to do this, and I have very little knowledge of how tikz and fancyhdr work.

• If it is as height as the text, it varies when text changes, right? – Symbol 1 Sep 24 '14 at 13:12
• Yes, but headers only have 1 line of height. – Lopson Sep 24 '14 at 13:32
• I mean the height of a line depends on its contents. A line like "xxxxxxx" is not as tall as "IIIIIII". Is this what you want? Or you want the rectangle is of height \baselineskip? – Symbol 1 Sep 24 '14 at 13:36
• I guess what I meant was \baselineskip! Sorry for the confusion. – Lopson Sep 24 '14 at 13:38

Here an attempt using default fancyhdr and tikzpagenodes. I didn't check if it's working with KOMA too. If you need additional help just add a comment.

Till now i didn't got it working for forced line-breaks (\\) in the header. Perhaps you find a solution of adding support for this on your own. I also did not have a closer look at the tikzpagenodes documentation. Should be worth a try.

\documentclass[11pt]{article}
\usepackage{tikzpagenodes}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{tikzpicture}[remember picture, overlay]
\fill [blue!50!white] (current page header area.north west) rectangle (current     page header area.south east);
\end{tikzpicture}