1

I would like to design the header (and footer) of my documents/letters in a rather fancy way. What I'm trying to achive is a colored background with some sort of shading pattern which is a little bit more elaborated than a simple gradient fill or something similar. I want this "bar" to span the complete paperwidth and to be placed right at the very top of the page.

I tried using the fancyhdr package to accomplish this, since I thought it might come handy later on if I use this in documents, but if I could place the background at the top with an option to write on it that would be sufficient for the moment.

So far, I've failed quite miserably in achieving any of the above mentioned points... to give you some kind of hint, what I dreamt might work is the following:

\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{mindmap, backgrounds}
\usepackage{fancyhdr}
\pagestyle{fancy}

\lhead{ %
\begin{tikzpicture}
\begin{pgfonlayer}{background}
\clip (-1.5,-5) rectangle ++(20,1);
%The shadings
\end{pgfonlayer}
 \end{tikzpicture}
  This is my colored header}

\begin{document}
...
\end{document}

And this is what the end product should look like:

Example header

1
3

You can use some rectangles with shading bilinear interpolation:

\documentclass{article}

\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{fit,shadings}

\begin{document}
\begin{tikzpicture}[overlay,remember picture]
  \node[inner sep=0,fit=(current page)] (cp){};
  \shade[upper left=white,lower left=gray,upper right=white,lower right=cyan]
  (cp.north west) rectangle +(4cm,-3cm);
  \shade[upper left=white,lower left=cyan,upper right=yellow,lower right=white]
  ([xshift=4cm]cp.north west) rectangle +(4cm,-3cm);
  \shade[upper left=yellow,lower left=white,upper right=gray,lower right=red!50!white]
  ([xshift=2*4cm]cp.north west) rectangle +(4cm,-3cm);
  \shade[upper left=gray,lower left=red!50!white,upper right=white,lower right=cyan]
  ([xshift=3*4cm]cp.north west) rectangle +(4cm,-3cm);
  \shade[upper left=white,lower left=cyan,upper right=white,lower right=gray]
  ([xshift=4*4cm]cp.north west) rectangle ([yshift=-3cm]cp.north east);

  \node[font=\Huge\bfseries] at ([yshift=-1.5cm]cp.north) {Hello World!};
\end{tikzpicture}
\end{document}

enter image description here

1
  • The result is amazing; I wonder why this answer hasn't gotten more attention. – user9424 Mar 18 '18 at 16:53
1

You can start with something like this. You can use more advanced shading or pattern or even include a picture, the idea will remain the same.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{mindmap,backgrounds}
\usepackage{fancyhdr}
\pagestyle{fancy}

\lhead{%
\begin{tikzpicture}[overlay,remember picture]
\path[inner color=blue,outer color=red] (current page.north west) rectangle ([yshift=-2cm]current page.north east);
\node at ([yshift=-1cm]current page.north) {\large\sffamily\bfseries\color{white}This is my colored header};
\end{tikzpicture}
}

\begin{document}
...\newpage...\newpage...\newpage...
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.