An elaborate 'fancy' header (book design)

1,453

Here is something to start with:

\documentclass[12pt]{book}
\usepackage{tikz}
\usepackage[a4paper, margin=4cm, headheight=23pt]{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newcommand{\X}{\phantom{X}} % Filler to define baseline of empty circles
\fancyhf{}
\DeclareRobustCommand{\bul}{\begin{tikzpicture}[baseline={(current bounding box.south)}]
\fill [blue!40,anchor=base,baseline] circle (1mm);
\end{tikzpicture}}
\renewcommand{\chaptermark}[1]{\markboth{Chapter \thechapter~%
\bul~#1}{}}
\renewcommand{\sectionmark}[1]{\markright{Section \thesection~%
\bul~#1}{}}
\renewcommand\headrulewidth{0pt}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}
\fancyhead[RO]
{\begin{tikzpicture}[baseline, every node/.style={minimum size=8mm, anchor=base}]
\path node at (0,0) [shape=circle, fill=blue!20] (0,0) {\X} 
node at (1,0) [shape=circle, fill=blue!40] (0,0) {\X} 
node at (2,0) [shape=circle, fill=blue!60] (0,0) {\thepage}; 
\end{tikzpicture}}
\fancyhead[LE]
{\begin{tikzpicture}[baseline, every node/.style={minimum size=8mm, anchor=base}]
\path node at (0,0) [shape=circle, fill=blue!60] (0,0) {\thepage} 
node at (1,0) [shape=circle, fill=blue!40] (0,0) {\X} 
node at (2,0) [shape=circle, fill=blue!20] (0,0) {\X};
\end{tikzpicture}}

\begin{document}
\chapter{Test Chapter}
\lipsum[1]
\section{Test Section}    
\lipsum[1-15]
\newpage    
\section{Test Section 2}    
\lipsum[1-15]
\end{document}
Share:
1,453
wrb98
Author by

wrb98

Updated on November 30, 2020

Comments

  • wrb98
    wrb98 almost 3 years

    I wish to design a book with the following style of header enter image description here

    The pages are to be set on A4paper with a margin of about 1 inch. I am currently using the code

         \usepackage[margin=1in]{geometry}
    

    for margins, but I'm unsure as to whether there is a more effective option available. To achive the bullet between 'Chapter 1' and 'A chapter' I am planning on using the code

         \tikzcircle[fill=...]{3pt}
    

    (the dots to represent the light blue colour shown in the mock-up picture). The document class will obviously be book with 12pt font, which I have chosen to be mathptmx. However, as someone who is only a beginner on Latex, I was wondering if anyone could provide a code which produces headers as shown in the mock-up. Fancyhdr seems to be the way forward and is the most versatile tool, but the fading circles seem to be the most difficult to replicate (I've had no success at recreating these so far). If anyone could help recreate the image I'd be very grateful.

    • Pieter van Oostrum
      Pieter van Oostrum almost 7 years
      I think A4 paper with 1 inch margin probably makes the text too wide. Such wide lines generally make reading uncomfortable.
    • wrb98
      wrb98 almost 7 years
      Ah ok. What sort of margin do you think will look better?
    • Pieter van Oostrum
      Pieter van Oostrum almost 7 years
      Usually the text width should be on average something like 60-70 characters. I woul like to advise you to read the documentation of the memoir documentclass. Especially section 2 has some excellent information about page design.
    • Pieter van Oostrum
      Pieter van Oostrum almost 7 years
      \usepackage[a4paper, margin=4cm, headheight=23pt]{geometry} looks better to me. I have now put that in my code.
  • wrb98
    wrb98 almost 7 years
    That seems to work OK, however it seems that the Chapter 1 Test Chapter and the number in the blue circle are not aligned properly. Could you suggest a fix?
  • Pieter van Oostrum
    Pieter van Oostrum almost 7 years
    We have to specify ` anchor=base` for the circles. But then the empty circles must have some contents that defines the baseline. I have updated the code.