4

I would like to create header and footers for all the page in my latex PDF, they should look:

Header

1) one inch thick; background color: Blue; left hand-side: DOCUMENT Title; right hand-side: Logo (logo.jpg; file placed in DOCUMENT folder);

Footers

1) half inch think; background color: Blue; left hand-side: page number; center: Chapter Title; right hand-side: Date; Only even pages.

2) half inch think; background color: Blue; left hand-side: Date; center: Chapter Title; right hand-side: page number; Only odd pages.

\documentclass[twoside,a4paper]{report}
\usepackage{fancyhdr, graphicx}
\usepackage{makeidx}
\usepackage{ifthen}
\usepackage{framed}
\usepackage[usenames, dvipsnames]{color}
\usepackage{environ}
\usepackage{xcolor}
\usepackage[tikz]{bclogo}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{DejaVuSansCondensed}
\makeindex
\begin{document}

\maketitle
\newpage
%-- header here
%-- even footer here

\newpage
%-- header here
%-- odd footer here

\end{document}
6

This is easily done with TikZ which you're already loading. I didn't set any margins, but if you're using twoside, maybe you want proper margins for the binding. If so, let me know and I'll fix the example.

Output

enter image description here

enter image description here

Code

\documentclass[twoside]{report}
\usepackage[a4paper, left=1.5cm, right=1.5cm, bindingoffset=1.5cm]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{etoolbox}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}

\definecolor{gmitblue}{RGB}{93,138,168}

\usetikzlibrary{calc}
\renewcommand{\headrulewidth}{0pt}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (current page.north west) rectangle ($(current page.north east)+(0,-1in)$);
    \node[anchor=north west, text=white, font=\Large\scshape, minimum size=1in, inner xsep=5mm] at (current page.north west) {A reasonably long title};
    \node[anchor=north east, minimum size=1in, inner xsep=5mm] at (current page.north east) {\includegraphics[scale=.2]{example-image-a}};
      %node[minimum width=\x2-\x1, minimum height=2cm, draw, rectangle, fill=blue!20, anchor=north west, align=left, text width=\x2-\x1] at ($(current page.north west)$) {\Large\bfseries \quad #1};
\end{tikzpicture}
}
\fancyfoot[CE]{
    \begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (current page.south west) rectangle ($(current page.south east)+(0,.5in)$);
    \node[anchor=south west, text=white, font=\Large, minimum size=.5in] at (current page.south west) {\thepage};
    \node[anchor=south, text=white, font=\large, minimum size=.5in] at (current page.south) {\leftmark};
    \node[anchor=south east, text=white, font=\large, minimum size=.5in, inner xsep=5mm] at (current page.south east) {\today};
\end{tikzpicture}
}
\fancyfoot[CO]{
    \begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (current page.south west) rectangle ($(current page.south east)+(0,.5in)$);
    \node[anchor=south west, text=white, font=\large, minimum size=.5in, inner xsep=5mm] at (current page.south west) {\today};
    \node[anchor=south, text=white, font=\large, minimum size=.5in] at (current page.south) {\leftmark};
    \node[anchor=south east, text=white, font=\Large, minimum size=.5in] at (current page.south east) {\thepage};
\end{tikzpicture}
}
\setlength{\headheight}{12pt}

\title{A reasonably long title}
\date{\today}
\author{The author}

\begin{document}
\maketitle
\chapter{first chapter}
\lipsum[1-9]

\chapter{second chapter}
\lipsum[10-19]
\end{document}
  • Wonderful, thanks! This is exaclty what I need! Three things: 1) how do I set the thikness of the footer and heades? 2) How do I set the logo image? 3) I have defined a color \definecolor{gmitblue}{rgb}{0.36, 0.54, 0.66}, it was working prior to the insert of the header and footer, yet not anymore; those this affects the coloset? – mattobob Feb 29 '16 at 10:35
  • @mattobob You mean the colored bars? When it says ($...+(0,.5in)$); change that .5in into whatever thickness you want. Remember to change also the minimum size of the nodes in the same "place" though. 2 place the logo in the same folder as your .tex file, then replace \includegraphics[scale=.2]{example-image-a} with \includegraphics[scale=.2]{<your file name>} without extension. Fix the scaling if necessary. 3 place the color command at the top (after the packages) but before the fancy definitions. Then replace my "blue" with your "gmitblue". It should work. – Alenanno Feb 29 '16 at 10:42
  • Thanks, really thanks man, you made my day, I'm fighting with this document since this morning, now it is wonderful, thanks! Only one thing, everything is working, i set the color definition after package includes, it recognize the color and use it, also on the colored bars, but the compiler still throws the error: ! Package xcolor Error: Undefined color `GMITBLUE'. have you an idea why? – mattobob Feb 29 '16 at 11:10
  • @mattobob Did you write it all caps? It's case sensitive I think. :D – Alenanno Feb 29 '16 at 11:16
  • If i write it evrywere uppercase it does not recognize the color, in lowercase it work correctly but it throws me the error – mattobob Feb 29 '16 at 11:27

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.