5

I want to replicate this document layout. I tried to reach the author, but did not get any positive response.

enter image description here

Main Matter Header

What I got so far is the header. But mine is statical and I want a dynamic header (adjusted to the section margins).

Here is the code

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

\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{midnightgreen}{rgb}{0.0, 0.29, 0.33}

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

\pagestyle{fancy}
\fancyhf{}
\fancyhead[CO]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north west)+(0.25in,-0.35in)$) rectangle ($(current page.north west)+(0.65in,-0.75in)$);
    \fill[midnightgreen] ($(current page.north west)+(2.5in,-0.35in)$) rectangle ($(current page.north east)+(-0.6in,-0.75in)$);
\node[anchor=north west, text=white, font=\large\bfseries, minimum size=1in, inner xsep=5mm] at ($(current page.north west)+(-0.1in,-0.05in)$){\thepage};
\node[anchor=north west, text=white, font=\large\bfseries, minimum size=1in] at ($(current page.north west)+(2.6in,-0.075in)$) {\rightmark};
\end{tikzpicture}
}
\fancyhead[CE]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north west)+(0.6in,-0.35in)$) rectangle ($(current page.north east)+(-2.25in,-0.75in)$);
\fill[midnightgreen] ($(current page.north east)+(-0.65in,-0.35in)$) rectangle ($(current page.north east)+(-0.25in,-0.75in)$);
\node[anchor=north west, text=white, font=\large\bfseries, minimum size=1in, inner xsep=5mm] at ($(current page.north east)+(-1in,-0.05in)$){\thepage};
\node[anchor=north west, text=white, font=\large\bfseries, minimum size=1in] at ($(current page.north west)+(0.65in,-0.075in)$) {\leftmark};
\end{tikzpicture}
}
\setlength{\headheight}{12pt}

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

\begin{document}
\maketitle
\chapter[Hola Mundo]{Hola Mundo}
\lipsum[1-9]
\section{La prueba na' ma'}

\chapter[Hola de Nuevo]{Hola Mundo... de Nuevo}
\lipsum[10-19]
\end{document}
2

Based on the code of @marmot, I added some missing parts. Please see the MWE later.

To recreate the shown structure of a document you need to add some code to your given MWE:

  1. Add \usepackage{multicol} in your preamble and then add the following code to get a TOC in two columns:

    \begin{multicols}{2} % <================================================
    \tableofcontents % <====================================================
    \end{multicols} % <===================================================== 
    
  2. I added \maketitle to your code to get the title of the document.
  3. To be able to add easily an complete dummy document I changed \usepackage{lipsum} to

    \usepackage{blindtext} % <========================== \Blinddocument
    

    Remember to change \lipsum... to \blindtext ...

  4. To get your wanted header on chapter pages etc., too, you have to define

    \fancypagestyle{plain}{% <==============================================
    

    (see the full code in the following MWE).

  5. Please see that I added at the end of your text \Blinddocument to get a better filled TOC for showing the two column TOC.
  6. Have you noticed the warnings you got because you are using a KOMA-Script class with fancyhdr and titlesec? KOMA-Script has an own way to build headers with package scrlayer-scrpage (please see documentation with texdoc KOMA-Script on your terminal/console). You should consider to change to that package but that was not the question here (If you can not do it by your own, ask a new question and show what you have tried so far ...).

The complete corrected MWE:

\documentclass[twoside,letterpaper]{scrbook}

\usepackage[letterpaper, left=1.5cm, right=1.5cm, bindingoffset=1.5cm]{geometry}
\usepackage[utf8]{inputenc}

\usepackage{fancyhdr} % <=========================== better use scrlayer-scrpage
\usepackage{titlesec} % <=========================== see warnings in log file
\usepackage{multicol} % <===============================================
%\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{blindtext} % <========================== \Blinddocument

\usepackage{etoolbox}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}

\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{midnightgreen}{rgb}{0.0, 0.29, 0.33}

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

\pagestyle{fancy}
\fancyhf{}
\fancyhead[CO]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north west)+(0.25in,-0.35in)$) rectangle ($(current page.north west)+(0.65in,-0.75in)$)
node[midway,text=white, font=\large\bfseries] {\thepage};
\fill[midnightgreen] ([yshift=-0.35in]current page.north-|current page text area.west)
coordinate (TL)
rectangle ([yshift=-0.75in]current page.north-|current page text area.east);
\node[anchor=north west, text=white, font=\large\bfseries,text
height=0.2in,inner xsep=1em] at (TL) {\rightmark}; 
\end{tikzpicture}%
}
\fancyhead[CE]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north east)+(-0.65in,-0.35in)$) rectangle ($(current page.north east)+(-0.25in,-0.75in)$)
node[midway,text=white, font=\large\bfseries] {\thepage};
\fill[midnightgreen] ([yshift=-0.35in]current page.north-|current page text area.west)
coordinate (TL)
rectangle ([yshift=-0.75in]current page.north-|current page text area.east);
\node[anchor=north west, text=white, font=\large\bfseries,text height=0.2in,inner xsep=1em] 
at (TL) {\leftmark};
\end{tikzpicture}%
}

\fancypagestyle{plain}{% <==============================================
\fancyhf{}
\fancyhead[CO]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north west)+(0.25in,-0.35in)$) rectangle ($(current page.north west)+(0.65in,-0.75in)$)
node[midway,text=white, font=\large\bfseries] {\thepage};
\fill[midnightgreen] ([yshift=-0.35in]current page.north-|current page text area.west)
coordinate (TL)
rectangle ([yshift=-0.75in]current page.north-|current page text area.east);
\node[anchor=north west, text=white, font=\large\bfseries,text
height=0.2in,inner xsep=1em] at (TL) {\rightmark}; 
\end{tikzpicture}%
}
\fancyhead[CE]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north east)+(-0.65in,-0.35in)$) rectangle ($(current page.north east)+(-0.25in,-0.75in)$)
node[midway,text=white, font=\large\bfseries] {\thepage};
\fill[midnightgreen] ([yshift=-0.35in]current page.north-|current page text area.west)
coordinate (TL)
rectangle ([yshift=-0.75in]current page.north-|current page text area.east);
\node[anchor=north west, text=white, font=\large\bfseries,text height=0.2in,inner xsep=1em] 
at (TL) {\leftmark};
\end{tikzpicture}%
}}
\setlength{\headheight}{14pt}

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


\begin{document}

\maketitle % <==========================================================
\begin{multicols}{2} % <================================================
\tableofcontents % <====================================================
\end{multicols} % <=====================================================
\chapter[Hola Mundo]{Hola Mundo}
\blindtext
\section{La prueba na' ma'}

\chapter[Hola de Nuevo]{Hola Mundo... de Nuevo}
\blindtext

\Blinddocument % <======================================================
\end{document}

and its result:

toc

and an usual chapter page:

usual chapter page

7
+350

With tikzpagenodes you can adjust things to the width of the actual page. It has the node current page text area, which is a rectangle that covers the text area.

\documentclass[twoside]{scrbook}
\usepackage[letterpaper, left=1.5cm, right=1.5cm, bindingoffset=1.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\usepackage{etoolbox}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}

\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{midnightgreen}{rgb}{0.0, 0.29, 0.33}

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

\pagestyle{fancy}
\fancyhf{}
\fancyhead[CO]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north west)+(0.25in,-0.35in)$) rectangle ($(current page.north west)+(0.65in,-0.75in)$)
node[midway,text=white, font=\large\bfseries] {\thepage};
\fill[midnightgreen] ([yshift=-0.35in]current page.north-|current page text area.west)
coordinate (TL)
rectangle ([yshift=-0.75in]current page.north-|current page text area.east);
\node[anchor=north west, text=white, font=\large\bfseries,text
height=0.2in,inner xsep=1em] at (TL) {\rightmark}; 
\end{tikzpicture}%
}
\fancyhead[CE]{%
\begin{tikzpicture}[overlay, remember picture]%
\fill[midnightgreen] ($(current page.north east)+(-0.65in,-0.35in)$) rectangle ($(current page.north east)+(-0.25in,-0.75in)$)
node[midway,text=white, font=\large\bfseries] {\thepage};
\fill[midnightgreen] ([yshift=-0.35in]current page.north-|current page text area.west)
coordinate (TL)
rectangle ([yshift=-0.75in]current page.north-|current page text area.east);
\node[anchor=north west, text=white, font=\large\bfseries,text height=0.2in,inner xsep=1em] 
at (TL) {\leftmark};
\end{tikzpicture}%
}
\setlength{\headheight}{12pt}

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

\begin{document}
\maketitle
\chapter[Hola Mundo]{Hola Mundo}
\lipsum[1-9]
\section{La prueba na' ma'}

\chapter[Hola de Nuevo]{Hola Mundo\dots\space de Nuevo}
\lipsum[10-29]
\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.