1

I would to get some help in getting my headers to show up like this on the odd pages:

enter image description here

and like below in the even pages:

enter image description here

Here is my minimal code:

\documentclass{book}
\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{mybluei}{RGB}{199,234,253}
\definecolor{gmitblue}{RGB}{93,138,168}

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

\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[mybluei] (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)+(0,-.35in)$) 
    {Configuration Issues, System Design\hspace{.5cm} {\Huge\textbf{\textcolor{white}{\thechapter}}} \thepage};
\end{tikzpicture}
}
\fancyhead[LO]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[mybluei] (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 west, minimum size=1in, inner xsep=5mm] at ($(current page.north west)+(0,-.35in)$)
    {\thepage {\Huge\textbf{\textcolor{white}{\thechapter}}} \hspace{.5cm} Configuration Issues, System Design};
\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
\lipsum

\chapter{second chapter}
\lipsum[10-19]
\end{document} 
  • 1
    Rather than posting a screenshot please post the actual latex code as a minimal working example. The screen short is close to useless because it does not show what class, and what packages, you are using and people have to try and recreate what you are doing from scratch. People are much more likely to help you if you give them some code that they can start from. – Andrew Sep 7 '16 at 4:41
  • What does the C in the header represent? – Werner Sep 7 '16 at 4:44
  • Sorry, I forgot to put my minimal code in. Its there now. Thanks. – Joe Sep 7 '16 at 4:44
  • 2
    Please see my solution to this question: Fancy header and footers – Alenanno Sep 7 '16 at 9:10
  • 1
    Let us know if you manage to use it or if you encounter difficulties. If you do, tell us what you tried and what wasn't working. – Alenanno Sep 7 '16 at 9:34
2

I am not sure if you wanted the footers as well, since your OP showed only the headers. In any case, here's a solution for the headers. Your try was not bad, but for example you didn't take into account the distances from the side of the page to the page number, chapter letter/number, and title. They should be the same on both sides, so here's a small example that shows that.

Note that the header and footer are not present when the chapter starts. That's a feature, but you could change this.

Output (various pages)

Chapter
enter image description here

Appendix, even page
enter image description here

Appendix, odd page
enter image description here

Code

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{geometry}
\usepackage{etoolbox,fancyhdr}

\usetikzlibrary{calc}

\definecolor{ultramarine}{RGB}{0,45,97}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{line}{RGB}{70,160,216}
\definecolor{fillh}{RGB}{225,233,251}

\renewcommand{\headrulewidth}{0pt}
\newcommand\hdheight{1in}

% uncomment this to see the distances are the same for evena nd odd pages.
%\tikzset{
%   every node/.style={draw}
%}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhf{}
\fancyhead[E]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[fillh] (current page.north west) rectangle ($(current page.north east)+(0,-\hdheight)$);
    \draw[line] ([yshift=-\hdheight]current page.north west) -- ([yshift=-\hdheight]current page.north east);
    \node[anchor=south west, font=\sffamily, text width=1cm] (evenpagenum) at ($(current page.north west)+(.5\hdheight,-\hdheight)$) {\thepage};
    \node[anchor=south west, text width=1.5cm, text=white, font=\fontsize{2cm}{5.5cm}\selectfont] (chapter) at (evenpagenum.south east) {\thechapter};
    \node[anchor=south west] at (chapter.south east) {\leftmark};
\end{tikzpicture}
}%
\fancyhead[O]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[fillh] (current page.north west) rectangle ($(current page.north east)+(0,-\hdheight)$);
    \draw[line] ([yshift=-\hdheight]current page.north west) -- ([yshift=-\hdheight]current page.north east);
    \node[align=right, anchor=south east, font=\sffamily, text width=1cm] (evenpagenum) at ($(current page.north east)+(-.5\hdheight,-\hdheight)$) {\thepage};
    \node[align=right, anchor=south east, text width=1.5cm, text=white, font=\fontsize{2cm}{5.5cm}\selectfont] (chapter) at (evenpagenum.south west) {\thechapter};
    \node[align=right, anchor=south east] at (chapter.south west) {\leftmark};
\end{tikzpicture}
}
\fancyfoot[CE]{}
\fancyfoot[CO]{}
\setlength{\headheight}{12pt}

\begin{document}
\chapter{Problems}
\section{Problem 1}
\subsection{Problem 1}
\lipsum[1]
\subsection{Solution 1}
\lipsum[1-7]
\cleardoublepage

\appendix
\chapter{Appendix \thechapter}
\lipsum[1-20]

\end{document} 

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.