# Section+Subsection in the header AND chapter in the footer using book (memoir)

I' writing my thesis in LyX with book (memoir) style. I would like to personalize the headers and footers but I cannot use the fancy package since I'm in the memoir style.

So (being a novice in LaTeX) I tried to use pre-existing code that I modified to create a new page style.

The headers work fine; I got the section and the subsections respectively on the even and odd pages. I also got the page number on the footer on both pages but I cannot add the chapter number on the footer.

How could I proceed to get the footer with the current chapter number on each page in addition to the pre-existing page number?

  \nouppercaseheads

\makepagestyle{mystyle}

%foot
\makeevenfoot {mystyle} {\small\thepage} {\small\leftmark} {}
\makeoddfoot {mystyle} {} {\small\leftmark} {\small\thepage}

\makeatletter

\makepsmarks{mystyle}{%
\createmark{section}{left}{shownumber}{}{\space}
\createmark{subsection}{right}{shownumber}{}{\space}
\createmark{chapter}{right}{shownumber}{\@chapapp\ }{\space }}

\makeatother

\pagestyle{mystyle}

-

As \chapter starts a new page, there is not really a need to use a marks register. A conventional macro is sufficient. The following example uses \mychapterfoot that holds the string with the chapter/appendix title for the footer. Class memoir defines \f@rhdr that holds the header version of the chapter title. Hook points are

• \memendofchapterhook for \chapter without star.
• \memchapstarinfo for \chapter* with star before \appendix.
• \memappchapstarinfo for \chapter after \appendix.

Also the marks register for \section and \subsection titles should be cleared to prevent leaking those titles from the previous chapter. Since the first page of a chapter has usually a different page style and a \subsection title is not likely to be needed in the headers on that page, calling \markboth{}{} clears the marks register.

Example:

\documentclass{memoir}

\makeatletter
\newcommand*{\mychapterfoot}{}
\protected@xdef\mychapterfoot{%
\@chapapp\ \thechapter\ \f@rhdr
}%
\markboth{}{}%
}
\let\org@memappchapstarinfo\memappchapstarinfo
\renewcommand{\memappchapstarinfo}[2]{%
\org@memappchapstarinfo{#1}{#2}%
\protected@xdef\mychapterfoot{\@chapapp\ \f@rhdr}%
\markboth{}{}%
}
\let\org@memchapstarinfo\memchapstarinfo
\renewcommand*{\memchapstarinfo}[2]{%
\org@memchapstarinfo{#1}{#2}%
\protected@xdef\mychapterfoot{\@chapapp\ \f@rhdr}%
\markboth{}{}%
}
\makeatother

\makepagestyle{mystyle}

%foot
\makeevenfoot {mystyle} {\small\thepage} {\small\mychapterfoot} {}
\makeoddfoot {mystyle} {} {\small\mychapterfoot} {\small\thepage}

\makeatletter

\makepsmarks{mystyle}{%
\createmark{section}{left}{shownumber}{}{\space}%
\createmark{subsection}{right}{shownumber}{}{\space}%
\renewcommand*{\chaptermark}[1]{}%
}

\makeatother

\pagestyle{mystyle}

\setcounter{secnumdepth}{3}

\begin{document}
\chapter{Introduction}
\section{Section A}
\subsection{Subsection B}
\newpage
\null
\newpage
\null
\chapter*{Nix}
\newpage
\null
\end{document}

-