2

This question is building off the solution posted here.

For example, ONLY on the first pages of the contents pages (like contents, List of Figures, etc.), I wanted to remove the chapter name from the header so that the first page of the TOC, LOFs etc. will look like this:

enter image description here

but the following pages related to the TOC, LOFs etc. should have the chapter name in the header like this:

enter image description here

Here is the original solution code:

\documentclass[11pt,openany]{book}
\usepackage{calc}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{fourier}
\usepackage{etoolbox}
\usepackage{blindtext}
\usepackage[headheight=15pt]{geometry}
\patchcmd{\chapter}{\thispagestyle{plain}}{\pagestyle{fancy}}{}{}


\newif\ifchapterwidthstar
\newcommand\printchapternumber{\ifchapterwidthstar\else\thechapter\fi}
\makeatletter
\patchcmd\@chapter{\@afterheading}{\chapterwidthstarfalse\@afterheading}{}{}
\patchcmd\@schapter{\@afterheading}{\chapterwidthstartrue\@afterheading}{}{}
\makeatother
\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{line}{RGB}{70,160,216}

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

\newsavebox\headimageodd
\newsavebox\headimageeven
\newcommand*{\headimages}[3][]{%
  \savebox{\headimageeven}{%
    \includegraphics[height=120pt,#1]{#2}%
  }%
  \savebox{\headimageodd}{%
    \includegraphics[height=120pt,#1]{#3}%
  }%
}
\headimages{example-image-b}{example-image-a}

\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)$) {\printchapternumber};
      \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) {\usebox\headimageodd};
  \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) {\usebox\headimageeven};
  \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}
\pagestyle{empty}
\maketitle

\tableofcontents
\listoffigures

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

\section{Solution 1}
\lipsum
\lipsum

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

\blinddocument
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\blinddocument


\appendix
\chapter{Answer 1}
\lipsum[1]

\cleardoublepage
\chapter*{References}

\end{document}
  • Please make your example minimal and remove all unnecessary code (e.g. are the tikzpictures or the footlines really important?). – TeXnician Mar 8 '17 at 20:58
  • @TeXnician, I removed the code for the footer but left the header code as I think that it is needed for part of the solution. Thanks! – Joe Mar 8 '17 at 21:03
  • 1
    well if you can accept a manual solution you can do \newpage\markright{}\tableofcontents. – Ulrike Fischer Mar 10 '17 at 21:31
3
+50

Hard to believe this is what is intended, but it seems to be what you ask.

\documentclass[11pt,openany]{book}
\usepackage{calc}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{fourier}
\usepackage{etoolbox}
\usepackage{blindtext}
\usepackage[headheight=15pt]{geometry}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{semifancy}\pagestyle{fancy}}{}{}

\newif\ifchapterwidthstar
\newcommand\printchapternumber{\ifchapterwidthstar\else\thechapter\fi}
\makeatletter
\patchcmd\@chapter{\@afterheading}{\chapterwidthstarfalse\@afterheading}{}{}
\patchcmd\@schapter{\@afterheading}{\chapterwidthstartrue\@afterheading}{}{}
\makeatother
\definecolor{gmitblue}{RGB}{93,138,168}
\definecolor{line}{RGB}{70,160,216}

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

\newsavebox\headimageodd
\newsavebox\headimageeven
\newcommand*{\headimages}[3][]{%
  \savebox{\headimageeven}{%
    \includegraphics[height=120pt,#1]{#2}%
  }%
  \savebox{\headimageodd}{%
    \includegraphics[height=120pt,#1]{#3}%
  }%
}
\headimages{example-image-b}{example-image-a}

\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)$) {\printchapternumber};
    \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) {\usebox\headimageodd};
  \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) {\usebox\headimageeven};
  \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}%
}
\fancypagestyle{semifancy}{%
  \pagestyle{fancy}%
  \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=north west, inner xsep=5mm] at (current page.north west) {\usebox\headimageeven};
    \end{tikzpicture}%
  }%
  \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
      \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)$) {\printchapternumber};
      \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) {\usebox\headimageodd};
    \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}
\pagestyle{empty}
\maketitle

\tableofcontents
\listoffigures

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

\section{Solution 1}
\lipsum
\lipsum

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

\blinddocument
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\blinddocument

\appendix
\chapter{Answer 1}
\lipsum[1]

\cleardoublepage
\chapter*{References}

\end{document}

likely unwanted, but who knows?

Why is TOPIC TO BE DISCUSSED hard-coded in the definitions? And why does the content overlay the logo?

Aside from that, I find the layout extremely confusing as I can't tell where one chapter ends and the next begins at all easily. It looks like more and more of just the same.

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.