2

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.

Please kindly advise me. Here is my minimal code:

\documentclass[twoside,12pt,a5paper]{memoir}
\usepackage{tikz,fancyhdr,lipsum}               
\usetikzlibrary{calc}
\pagestyle{fancy}\fancyhf{}
\fancyhead[LO]{%
  \begin{tikzpicture}[overlay,remember picture]
      \fill [color=blue] (current page.north west) rectangle
       ($ (current page.south west) + (1cm,0cm) $);
   \end{tikzpicture}
}
\fancyhead[RE]{%
  \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 '18 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. – Romalpa Akzo Feb 18 '18 at 14:35
2

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

 \renewcommand{\headrulewidth}{0pt}
   \fancypagestyle{plain}{%
    \pagestyle{fancy}%
 }

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

enter image description here

\documentclass[twoside,12pt,a5paper]{memoir}
\usepackage{tikz,fancyhdr,lipsum}               
\usetikzlibrary{calc}
\pagestyle{fancy}\fancyhf{}
\fancyhead[LO]{%
  \begin{tikzpicture}[overlay,remember picture]
      \fill [color=blue] (current page.north west) rectangle
       ($ (current page.south west) + (1cm,0cm) $);
   \end{tikzpicture}
}
\fancyhead[RE]{%
  \begin{tikzpicture}[overlay,remember picture]
     \fill [color=orange] (current page.north east) rectangle
      ($ (current page.south east) + (-1cm,0cm) $);
  \end{tikzpicture}
}
\renewcommand{\headrulewidth}{0pt}
\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. – Romalpa Akzo Feb 18 '18 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 '18 at 19:08

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.