2

in the MWE code below:

  1. How do I go about removing the section number just from the \rightmark in the headers,

  2. Remove "CHAPTER X" from the footers, and

  3. Shift the main body text down so that it does not overlap with the header images.

  4. Remove the "0" from the un-numbered chapters (like the List of Figures, Contents, etc.).

Here is the code that was modified as per solution given here:

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

\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{line}{RGB}{70,160,216}

\usetikzlibrary{calc}
\renewcommand{\headrulewidth}{0pt}
\newcommand\hdheight{1in}
\newcommand\ftheight{.5in}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[O]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (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, text width=1cm, text=white, font=\fontsize{2cm}{1.5cm}\selectfont] (oddpagenum) at ($(current page.north west)+(.5\hdheight,-\hdheight)$) {\textbf{\thechapter}};
    \node[anchor=south west, text width=11.5cm, text=white, font=\fontsize{.5cm}{1.5cm}\selectfont] (chapter) at (oddpagenum.south east) {\quad\textbf{TOPIC TO BE DISCUSSED}};
    \node[anchor=north east, minimum size=1in, inner xsep=5mm] at (current page.north east) {\includegraphics[scale=.4]{example-image-a}};
%    \node[anchor=south west] at (chapter.south east) {\leftmark};
\end{tikzpicture}
}
\fancyhead[E]{%
\begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (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, text width=7cm, text=white, font=\fontsize{.7cm}{1.5cm}\selectfont] (evenpagenum) at ($(current page.north east)+(-.5\hdheight,-\hdheight)$) {\textbf{\rightmark}};
%    \node[align=right, anchor=south east, text width=1.5cm, text=white, font=\fontsize{.5cm}{5.5cm}\selectfont] (leftmark) at (evenpagenum.south west) {\rightmark};
    \node[anchor=north west, minimum size=1in, inner xsep=5mm] at (current page.north west) {\includegraphics[scale=.4]{example-image-b}};
%    \node[align=right, anchor=south east] at (chapter.south west) {\leftmark};
\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) {\textbf{\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) {\textbf{\thepage}};
\end{tikzpicture}
}
\setlength{\headheight}{12pt}

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

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{}{0pt}{\Huge}
\titlespacing*{\chapter} {0pt}{20pt}{40pt}

\begin{document}
\maketitle

\tableofcontents

\listoffigures

\chapter{Problem 1}
\section{Problem 1}
\lipsum[1]
\section{Solution 1}
\lipsum
\lipsum


\chapter{Problem 2}
\section{Problem 2}
\lipsum[1]
\section{Solution 2}
\lipsum[1-5]

\appendix
\chapter{Appendix A}
\lipsum[1-5]
\end{document} 
Joe
  • 9,080
  • Please note that the site works best when you ask one question per ... well, per question, really. – cfr Sep 12 '16 at 22:50

2 Answers2

4

This answer

  • eliminates all the very many bad boxes caused by your code which you did not mention in the question;

  • avoids mucking up geometry by defining things it doesn't know about behind its back;

  • avoids content overlapping the header;

  • removes chapter numbers equal to zero and repeats the \rightmark in these cases instead;

  • introduces one new bad box which is not a result of the page style, but just, I think, a function of the current dummy content and so not really worth the trouble to eliminate at this point.

It does not answer your sundry other questions. The site works best when you ask one question per question and, for me, this was too much for one question. I may come back to it if I have time later, but the other questions aren't really related to what I did here and would be best answered by somebody familiar with titleps who can show you how to use it to replace the use of fancyhdr. In the meantime, I would recommend looking to that kind of solution. I don't like titleps because I am allergic to titlesec. So I pretty much always use fancyhdr. But if you are using titlesec already, you are presumably not similarly allergic and would be best advised to use page styling which is designed to cooperate with it.

Note that the problem is that you are not using information from LaTeX's marks consistently. Rather you are saying \thechapter explicitly which obviously does not work well when chapters do not have numbers. One way to deal with this would be to use different page styles for the front matter, main matter and back matter. (You are not using these commands - I don't know whether this is because you don't want traditional pagination or for some other reason.)

Anyway, here's a solution to the pagestyle-dependent bad boxes, zero chapters and overlapping content.

\documentclass[11pt,a4paper]{book}
\usepackage{calc}
\usepackage[left=1.5cm, right=1.5cm, bindingoffset=1.5cm, headheight=120pt, top={120pt+10mm}]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{fourier}
\usepackage{etoolbox}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}

\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{line}{RGB}{70,160,216}

\usetikzlibrary{calc}
\renewcommand{\headrulewidth}{0pt}
\newcommand\hdheight{1in}
\newcommand\ftheight{.5in}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[O]{%
  \begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (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);
    \ifnum\value{chapter}=0
      \node[anchor=south west, text width=11.5cm, text=white, font=\fontsize{.7cm}{1.5cm}\selectfont\bfseries]  at ($(current page.north west)+(.5\hdheight,-\hdheight)$) {\raggedleft\rightmark};
    \else
      \node[anchor=south west, text width=2cm, text=white, font=\fontsize{2cm}{1.5cm}\selectfont\bfseries] (oddpagenum) at ($(current page.north west)+(.5\hdheight,-\hdheight)$) {\thechapter};
      \node[anchor=south west, text width=11.5cm, text=white, font=\fontsize{.5cm}{1.5cm}\selectfont\bfseries] (chapter) at (oddpagenum.south east) {\quad TOPIC TO BE DISCUSSED};
    \fi
    \node[anchor=north east, inner xsep=5mm] at (current page.north east) {\includegraphics[height=120pt]{example-image-a}};
  \end{tikzpicture}%
}
\fancyhead[E]{%
  \begin{tikzpicture}[overlay, remember picture]%
    \fill[gmitblue] (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 east, text width=7cm, text=white, font=\fontsize{.7cm}{1.5cm}\selectfont\bfseries] (evenpagenum) at ($(current page.north east)+(-.5\hdheight,-\hdheight)$) {\raggedleft\rightmark};
    \node[anchor=north west, inner xsep=5mm] at (current page.north west) {\includegraphics[height=120pt]{example-image-b}};
  \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\bfseries, 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\bfseries, minimum size=.5in] at (current page.south east) {\thepage};
  \end{tikzpicture}%
}

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

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{}{0pt}{\Huge}
\titlespacing*{\chapter} {0pt}{20pt}{40pt}

\begin{document}
\maketitle
\tableofcontents
\listoffigures

\chapter{Problem 1}
\section{Problem 1}
\lipsum[1]

\section{Solution 1}
\lipsum
\lipsum

\chapter{Problem 2}

\section{Problem 2}
\lipsum[1]

\section{Solution 2}
\lipsum[1-5]

\appendix

\chapter{Appendix A}
\lipsum[1-5]

\end{document}

overview of better boxes and roomier headers

cfr
  • 198,882
1

Here is another solution:

Problem 1 and 2:

You have to define the commands that fill the marks. Normally the chapter and section numbers are used in the marks. So you have to redefine the code not to use these. This is described in the fancyhdr manual. Put

\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

after \pagestyle{fancy}

Problem 3:

You have to make more room between the header and the text. This is defined by headsep. Use this 'geometry' line:

\usepackage[a4paper, left=1.5cm, right=1.5cm, bindingoffset=1.5cm, 
includehead, headheight=14pt, headsep=10mm]{geometry}

And remove the \setlength{\headheight}{12pt} (which was too small anyway). Let geometry do the work.

Adapt the 10mm to your taste.

Problem 4:

Here is my solution.

Replace \thechapter in \fancyhead[O] with \mychapter.

In the preamble (before \begin{document}):

\newcommand{\mychapter}{}

Before the first chapter:

\newpage
\renewcommand{\mychapter}{\thechapter}