# TOC pagestyle not working for first page (in memoir using fancyhdr)

I am using memoir class for my thesis. Among many decoration (by fancyhdr) are the color vertical bars for even and odd pages as similarly guided in this link: coloured rule margin, which I want to keep through the whole thesis.

The problem is that I could not apply these bars for the first page of any parts within frontmatter, including Abstract, TOC, LOT, LOF, despite it seems working for the following pages. I have tried advises in this question, but got no success.

\documentclass[twoside,12pt,a5paper]{memoir}
\usepackage{tikz,fancyhdr,lipsum}
\usetikzlibrary{calc}
\pagestyle{fancy}\fancyhf{}
\begin{tikzpicture}[overlay,remember picture]
\fill [color=blue] (current page.north west) rectangle
($(current page.south west) + (1cm,0cm)$);
\end{tikzpicture}
}
\begin{tikzpicture}[overlay,remember picture]
\fill [color=orange] (current page.north east) rectangle
($(current page.south east) + (-1cm,0cm)$);
\end{tikzpicture}
}

\begin{document}
\tableofcontents* \clearpage
\listoffigures \clearpage
\fancypagestyle{chapter}{}

\chapter{My first Chapter: Problems}
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]

\chapter{My Second Chapter: Problems}
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\end{document}
• Welcome to TeX.SE. Why are using fancyhdr together with memoir which has its own header/footer mechanism? The reason why it does not work is that the first page of a ToC etc. uses plain or empty pagestyle in most cases
– user31729
Feb 18, 2018 at 14:31
• I have to attach myself with fancyhdr and memoir, since I have done some decoration using these packages and now everything is just fine except for the above issue. Please kindly advise any possible solution to "patch" into the fancy or plain pagestyle provided by fancyhdr. Many thanks. Feb 18, 2018 at 14:35

The easiest way is to call fancy inside the plain style and removing the headrule:

\fancypagestyle{plain}{%
\pagestyle{fancy}%
}

I don't recommend using memoir and fancyhdr, however.

\documentclass[twoside,12pt,a5paper]{memoir}
\usepackage{tikz,fancyhdr,lipsum}
\usetikzlibrary{calc}
\pagestyle{fancy}\fancyhf{}
\begin{tikzpicture}[overlay,remember picture]
\fill [color=blue] (current page.north west) rectangle
($(current page.south west) + (1cm,0cm)$);
\end{tikzpicture}
}
\begin{tikzpicture}[overlay,remember picture]
\fill [color=orange] (current page.north east) rectangle
($(current page.south east) + (-1cm,0cm)$);
\end{tikzpicture}
}
\fancypagestyle{plain}{%
\pagestyle{fancy}%
}

\begin{document}
\tableofcontents* \clearpage
\listoffigures \clearpage
\fancypagestyle{chapter}{}

\chapter{My first Chapter: Problems}
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]

\chapter{My Second Chapter: Problems}
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\section{A}\subsection{B}\lipsum[1]\subsection{CS1}\lipsum[1] \subsection{C}\lipsum[1]
\end{document}
• Please kindly receive my appreciation. Your advise is working perfect for my minimal sample and it is truly useful. The fact that it is not working for my actual problem has the meaning that the issue is lying somewhere else beyond my above expectation. I am now working on it with the hope to clarify the problem then could come back here and seek for your brilliant advise. Many thanks. Feb 18, 2018 at 15:19
• @RomalpaAkzo: Yes, but my answer is meant for the use - case you posted, not for extra issues. Please accept my answer and post a new question in case your issue couldn't be solved
– user31729
Feb 18, 2018 at 19:08