书籍类别的 fancypagestyle(s)

书籍类别的 fancypagestyle(s)

如何正确地重新定义标题以解决这个问题?

\documentclass[twoside, 12pt]{book}
\usepackage{mathtools,amssymb}
\usepackage{xcolor}
\usepackage[nobottomtitles,clearempty]{titlesec}
\assignpagestyle{\chapter}{empty}
\usepackage{lipsum}
\usepackage{fancyhdr}

%===============================
%frontmatter
\fancypagestyle{myplain}{%
 \renewcommand\chaptermark[1]{\markboth{ #1}{}}
\renewcommand\sectionmark[1]{\markright{ #1}}
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}%
\fancyhead[LE]{$\mathcolor{gray}{\blacksquare}$\space \thepage\space \hrulefill\space\itshape \leftmark}%
\fancyhead[RO]{\hrulefill \space \rightmark $\mathcolor{gray}{\blacksquare}$\space \thepage}}

%===============================
%maintmatter
\fancypagestyle{myfancy}{%
\renewcommand\chaptermark[1]{\markboth{#1}{}}
\renewcommand\sectionmark[1]{\markright{#1}}
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}%
\fancyhead[LE]{\itshape\chaptername\space\thechapter\hrulefill\itshape\leftmark\space $\mathcolor{gray}{\blacksquare}$\space \thepage}%
\fancyhead[RO]{$\mathcolor{gray}{\blacksquare}$\space \thepage\ \hrulefill\itshape \rightmark}}
%====================================
%backmatter
\fancypagestyle{back}{%
 \renewcommand\chaptermark[1]{\markboth{#1}{}}
\renewcommand\sectionmark[1]{\markright{#1}}
\fancyhf{}%
\renewcommand\chaptermark[1]{\markboth{#1}{}}
\renewcommand\sectionmark[1]{\markright{#1}}
\renewcommand{\headrulewidth}{0pt}%
\fancyhead[LE]{$\mathcolor{gray}{\blacksquare}$\space \thepage\space \hrulefill\space \leftmark}\fancyhead[RO]{\hrulefill \space \rightmark $\mathcolor{gray}{\blacksquare}$\space \thepage }}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\tableofcontents
\frontmatter
\pagestyle{myplain}
\chapter{unnumbered chapter}

\lipsum[1-15]

\mainmatter
\pagestyle{myfancy}
\chapter{numbered Chapter}

\section{Une section}

\lipsum[1-15]
\backmatter
\pagestyle{back}
Some content ...
\end{document}

日志文件的一部分:

! Illegal parameter number in definition of \ps@myplain.
<to be read again> 
1
l.19 ...hcolor{gray}{\blacksquare}$\space \thepage}}
                                                  
? 
! Illegal parameter number in definition of \ps@myplain.
<to be read again> 
1
l.19 ...hcolor{gray}{\blacksquare}$\space \thepage}}
                                                  
? 
! Illegal parameter number in definition of \ps@myfancy.
<to be read again> 
1
l.29 ...ce \thepage\ \hrulefill\itshape \rightmark}}
                                                  
? 
! Illegal parameter number in definition of \ps@myfancy.
<to be read again> 
1
l.29 ...ce \thepage\ \hrulefill\itshape \rightmark}}
                                                  
? 
! Illegal parameter number in definition of \ps@back.
<to be read again> 
1
l.38 ...color{gray}{\blacksquare}$\space \thepage }}
                                                  
? 
! Illegal parameter number in definition of \ps@back.
<to be read again> 
1
l.38 ...color{gray}{\blacksquare}$\space \thepage }}
                                                  
? 
! Illegal parameter number in definition of \ps@back.
<to be read again> 
1
l.38 ...color{gray}{\blacksquare}$\space \thepage }}
                                                  
? 
! Illegal parameter number in definition of \ps@back.
<to be read again> 
1
l.38 ...color{gray}{\blacksquare}$\space \thepage }}
                                                  
? 

相关内容