Using the fancyhdr package, the code below does exactly what I want for my headers and footers. I use the empty pagestyle, redefine the plain pagestyle, and define a fancy pagestyle.
There is something about the way you define the fancy pagestyle that bothers me (no brackets indicating the beginning and end of the definition). So, as an experiment, I used \fancypagestyle to define a MyFancy pagestyle that is identical to the fancy pagestyle. From this answer, I thought I was on the right track.
However, in the \frontmatter section below, if you comment out \pagestyle{fancy} and uncomment \pagestyle{MyFancy}, the results are different. In the \mainmatter, you no longer get the chapter information where it was expected to be in the footer (i.e., it was expected to be on all non-empty pages that were not the first page of a chapter). No doubt I am missing something obvious, but I am stumped.
Question: What changed are needed to my code so I can use the MyFancy pagestyle as a replacement for the fancy pagestyle?
\documentclass[11pt]{book}
\raggedbottom
\usepackage{lipsum}
\title{Some Book Name}
\author{Henry A. Smith}
\usepackage{emptypage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.2pt}
\fancyfoot[RO, LE] {Page \thepage}
\makeatletter\fancyfoot[CE,CO]{\if@mainmatter \leftmark\fi}\makeatother
\fancypagestyle{plain}{
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.2pt}
\fancyfoot[RO, LE] {Page \thepage}}
\fancypagestyle{MyFancy}{%
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.2pt}%
\fancyfoot[RO, LE] {Page \thepage}%
\makeatletter\fancyfoot[CE,CO]{\if@mainmatter \leftmark\fi}\makeatother}
\begin{document}
\frontmatter
\pagestyle{empty}
\maketitle
\cleardoublepage
Copyright 2018, Henry A. Smith
\chapter{Acknowledgments}
\pagestyle{fancy} % COMMENT THIS OUT
%\pagestyle{MyFancy} % UNCOMMENT THIS
\lipsum[1-5]
\chapter{Preface}
\lipsum[1-5]
\mainmatter
\chapter{The First Chapter}
\lipsum[1-10]
\chapter{The Second Chapter}
\lipsum[1-20]
\backmatter
\chapter{BackMatter Chapter}
\lipsum[1-10]
\end{document}
\makeatletter\fancyfoot[CE,CO]{\if@mainmatter \leftmark\fi}\makeatother}
can not work, move the\make...
out of the argument and just have one\makeatletter
and one\makeatother
around all the definitions that need@
in your preamble