1

In the WE below, I was attempting to get the same footer on each page of the document (except the first page of the chapter), however, I get the footer appearing only on the odd pages. Can you help me get the same footer on both the odd and even pages?

Here is my code:

\documentclass{book}
\usepackage{lmodern}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}

\pagestyle{plain}

% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}

% the list of colors to be used (add more if needed)
\newcommand\BoxColor{%
  \ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}


% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

%======================================================================================
%   PAGE HEADERS
%======================================================================================

\usepackage{etoolbox,fancyhdr} % Required for header and footer configuration

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} % Section text font settings
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Font setting for the page number in the header
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north east]
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}} % Print the nearest section name on the left side of odd pages
\fancyhead[RE]{\leftmark%
  \begin{tikzpicture}[overlay,remember picture]
  \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
    text height=4cm,align=center,anchor=north west]
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
  {\rotatebox{90}{\parbox{4cm}{%
    \centering\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}} % Print the current chapter name on the right side of even pages
\renewcommand{\headrulewidth}{.5pt} % Width of the rule under the header
\addtolength{\headheight}{2.5pt} % Increase the spacing around the header slightly
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{.5pt}
\fancyfoot[LE,RO]{%
\cfoot[\fancyplain{}{}] {\fancyplain{}{\footnotesize\bfseries{Center Foot}}} \lfoot[\fancyplain{}{}]
{\fancyplain{}{\footnotesize\bfseries\itshape{Left Foot}}}
\rfoot[\fancyplain{}{}]
{\fancyplain{}{\footnotesize\bfseries\itshape{Right Foot}}}
}
\fancyfoot[RE,LO]{%
\cfoot[\fancyplain{}{}] {\fancyplain{}{\footnotesize\bfseries{Center Foot}}} \lfoot[\fancyplain{}{}]
{\fancyplain{}{\footnotesize\bfseries\itshape{Left Foot}}}
\rfoot[\fancyplain{}{}]
{\fancyplain{}{\footnotesize\bfseries\itshape{Right Foot}}}
}

\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} % Style for when a plain pagestyle is specified

% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
  {\vskip 40\p@}
  {\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother

\begin{document}
\fancypagestyle{plain}{%
\renewcommand{\headrulewidth}{0pt} % Width of the rule under the header
\renewcommand{\footrulewidth}{0pt}
\cfoot[\fancyplain{}{}] {\fancyplain{}{}} \lfoot[\fancyplain{}{}]
{\fancyplain{}{}}
\rfoot[\fancyplain{}{}]
{\fancyplain{}{}}
{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} % Style for when a plain pagestyle is specified
}

\part{Part One}
\mainmatter
\chapter[Intro]{Introduction}
\lipsum[1-7]
\section{This is how we do it}
\lipsum[1-7]

\chapter{Results}
\lipsum[1-7]

\chapter{Some Sample Code}
\lipsum[1-7]

\part{Part Two}
\appendix
\renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries \appendixname~\thechapter}{}}
\chapter{This is Appendix A}
\lipsum[1-7]

\chapter{This is Appendix B}
\lipsum[1-7]

\end{document}
  • The use of \fancyplain is deprecated. A quick look at the .sty file suggests that it did not work properly and caused problems. It is included only for compatibility reasons (i.e. compiling old documents). – cfr Aug 25 '15 at 16:48
2

You need to clean up your fancyhdr definitions.

For redefining the plain page style to only have a page number in the top-right, use

\fancypagestyle{plain}{%
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% Width of rule under header
  \renewcommand{\footrulewidth}{0pt}% Width of rule above footer
  \fancyhead[R]{\thepage}}

For defining the fancy page style footer you might be interested in

\renewcommand{\footrulewidth}{.5pt}
\fancyfoot[LE,RO]{\footnotesize\bfseries\itshape Left foot}
\fancyfoot[C]{\footnotesize\bfseries Center foot}
\fancyfoot[RE,LO]{\footnotesize\bfseries\itshape Right foot}

Here is your example code:

enter image description here

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}

% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}

% the list of colors to be used (add more if needed)
\newcommand\BoxColor{%
  \ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}


% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

%======================================================================================
%   PAGE HEADERS
%======================================================================================

\usepackage{etoolbox,fancyhdr} % Required for header and footer configuration

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} % Section text font settings
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Font setting for the page number in the header
\fancyhead[LO]{\rightmark%
  \begin{tikzpicture}[overlay,remember picture]
    \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
      text height=4cm,align=center,anchor=north east]
    at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
    {\rotatebox{90}{\parbox{4cm}{%
      \centering\textcolor{black}{\scshape\leftmark}}}};
    \end{tikzpicture}} % Print the nearest section name on the left side of odd pages
  \fancyhead[RE]{\leftmark%
    \begin{tikzpicture}[overlay,remember picture]
    \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
      text height=4cm,align=center,anchor=north west]
    at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
    {\rotatebox{90}{\parbox{4cm}{%
      \centering\textcolor{black}{\scshape\leftmark}}}};
    \end{tikzpicture}} % Print the current chapter name on the right side of even pages

\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\headrulewidth}{.5pt} % Width of the rule under the header
\addtolength{\headheight}{2.5pt} % Increase the spacing around the header slightly
\renewcommand{\footrulewidth}{.5pt}
\fancyfoot[LE,RO]{\footnotesize\bfseries\itshape Left foot}
\fancyfoot[C]{\footnotesize\bfseries Center foot}
\fancyfoot[RE,LO]{\footnotesize\bfseries\itshape Right foot}

% Removes the header from odd empty pages at the end of chapters
\renewcommand{\cleardoublepage}{%
  \clearpage
  \ifodd\value{page}\else
    \mbox{}\thispagestyle{empty}
    \newpage
  \fi}

\makeatletter
\patchcmd{\@makechapterhead}
  {\vskip 40\p@}
  {\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother

\fancypagestyle{plain}{%
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% Width of rule under header
  \renewcommand{\footrulewidth}{0pt}% Width of rule above footer
  \fancyhead[R]{\thepage}}


\begin{document}

\part{Part One}
\mainmatter
\chapter[Intro]{Introduction}
\lipsum[1-7]
\section{This is how we do it}
\lipsum[1-7]

\chapter{Results}
\lipsum[1-7]

\chapter{Some Sample Code}
\lipsum[1-7]

\part{Part Two}
\appendix
\renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries \appendixname~\thechapter}{}}
\chapter{This is Appendix A}
\lipsum[1-7]

\chapter{This is Appendix B}
\lipsum[1-7]

\end{document}

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.