更改花式首页页脚的颜色

更改花式首页页脚的颜色

我正在使用它来更改花式页面样式中的章节页面的页眉和页脚的颜色,这是我从另一篇文章中得到的。

     \usepackage{etoolbox}

     \makeatletter
     \patchcmd{\@fancyhead}{\rlap}{\color{ared}\rlap}{}{} 
     \patchcmd{\headrule}{\hrule}{\color{ared}\hrule}{}{}
     \patchcmd{\@fancyfoot}{\rlap}{\color{ared}\rlap}{}{}
     \patchcmd{\footrule}{\hrule}{\color{ared}\hrule}{}{}
     \makeatother

但是,每章的第一页的页码仍然是黑色的。我尝试过修改,\fancypagestyle{plain}但目前还没有结果。

有人对如何成功更改第一章页脚颜色有什么建议吗?

我正在使用memoir文档类

答案1

不幸的是,问题中没有 MWE。memoir您应该使用此类的页眉和页脚命令:

 \documentclass{memoir}
\usepackage{blindtext}
\usepackage{xcolor}
\colorlet{ared}{red}

\pagestyle{ruled}
\makeevenhead{ruled}{\leftmark}{}{\rightmark}
\makeoddhead{ruled}{\rightmark}{}{\leftmark}
\makeevenfoot{ruled}{}{\thepage}{}
\makeoddfoot{ruled}{}{\thepage}{}

\makeheadfootruleprefix{ruled}{\color{ared}}{\color{ared}}
\makeheadfootstrut{ruled}{\strut\color{ared}}{\strut\color{ared}}
\makeheadfootstrut{plain}{\strut\color{ared}}{\strut\color{ared}}
\uppercaseheads

\begin{document}
\blinddocument
\blinddocument
\end{document}

在此处输入图片描述


标准班您可以使用fancyhdr,但您也必须定义plain为花哨的页面样式:

\documentclass{book}
\usepackage{blindtext}
\usepackage{xcolor}
\colorlet{ared}{red}
\usepackage{etoolbox}
\usepackage{fancyhdr}
\makeatletter
\patchcmd{\@fancyhead}{\rlap}{\color{ared}\rlap}{}{} 
\patchcmd{\headrule}{\hrule}{\color{ared}\hrule}{}{}
\patchcmd{\@fancyfoot}{\rlap}{\color{ared}\rlap}{}{}
\patchcmd{\footrule}{\hrule}{\color{ared}\hrule}{}{}
\makeatother

\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyfoot[C]{\thepage}
  \renewcommand\headrulewidth{0pt}
}

\pagestyle{fancy}
\begin{document}
\blinddocument
\end{document}

在此处输入图片描述


或者您可以使用包scrlayer-scrpage

\documentclass{memoir}
%\documentclass{book}
\usepackage{blindtext}
\usepackage{xcolor}
\colorlet{ared}{red}

\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\addtokomafont{pageheadfoot}{\color{ared}}
\ohead{\leftmark}
\ihead{\rightmark}
\cfoot*{\pagemark}


\begin{document}
\blinddocument
\blinddocument
\end{document}

相关内容