我如何将当前的标题样式分成两个可以在其间进行更改的相似的标题样式?

我如何将当前的标题样式分成两个可以在其间进行更改的相似的标题样式?

我正在考虑使用 fancyhdr 包来完成这项任务,根据这个问题,但我还不具备完成它所需的知识。

我正在使用以下代码:

\documentclass[a4paper,12pt,twoside,openright]{memoir}

\usepackage[utf8]{inputenc} % If utf8 encoding
\usepackage{librecaslon}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[final]{microtype}
\usepackage{fetamont}
\usepackage{graphicx} % Include figures
\usepackage{lmodern}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{alphalph,etoolbox}
\usepackage{fancyhdr}

%%% PAGE LAYOUT 
%%%------------------------------------------------------------------------------

\setlrmarginsandblock{0.15\paperwidth}{*}{1} % Left and right margin
\setulmarginsandblock{0.2\paperwidth}{*}{1}  % Upper and lower margin
\checkandfixthelayout

%%% HEADER AND FOOTER 
%%%------------------------------------------------------------------------------

\makepagestyle{standard} % Make standard pagestyle

\makeatletter                 % Define standard pagestyle
\makeevenfoot{standard}{}{}{} %
\makeoddfoot{standard}{}{}{}  %
\makeevenhead{standard}{\bfseries\thepage\normalfont\qquad\small\leftmark}{}{}
%\makeoddhead{standard}{}{}{\small\rightmark\qquad\bfseries\thepage}
\makeoddhead{standard}{}{}{%
    {\color{gray}\rule{1em}{1em}\hspace{0.2em}}%
    {\color{yellow}\rule{1em}{1em}\hspace{0.2em}}%
    {\color{blue}\rule{1em}{1em}\hspace{0.2em}}%
    {\color{brown}\rule{1em}{1em}\hspace{0.2em}}%
    {\color{black}\rule{1em}{1em}\hspace{0.2em}}%
    {\color{pink}\rule{1em}{1em}\hspace{0.2em}}%
    \hfill\small\rightmark\qquad\bfseries\thepage}
\makeheadrule{standard}{\textwidth}{\normalrulethickness}
\makeatother                  %

\makeatletter
\makepsmarks{standard}{
    \createmark{chapter}{both}{shownumber}{\@chapapp\ }{ \quad }
    \createmark{section}{right}{shownumber}{}{ \quad }
    \createplainmark{toc}{both}{\contentsname}
    \createplainmark{lof}{both}{\listfigurename}
    \createplainmark{lot}{both}{\listtablename}
    \createplainmark{bib}{both}{\bibname}
    \createplainmark{index}{both}{\indexname}
    \createplainmark{glossary}{both}{\glossaryname}
}
\makeatother                               %

\makepagestyle{chap} % Make new chapter pagestyle

\makeatletter
\makeevenfoot{chap}{}{\small\bfseries\thepage}{} % Define new chapter pagestyle
\makeoddfoot{chap}{}{\small\bfseries\thepage}{}  %
\makeevenhead{chap}{}{}{}   %
\makeoddhead{chap}{}{}{}    %
% \makeheadrule{chap}{\textwidth}{\normalrulethickness}
\makeatother

\nouppercaseheads
\pagestyle{standard}               % Choosing pagestyle and chapter pagestyle
\aliaspagestyle{chapter}{chap} %

%%% THE DOCUMENT
%%%------------------------------------------------------------------------------

\usepackage{lipsum} % Just to put in some text

\begin{document}

    \frontmatter

    \mainmatter

%   \pagestyle{style1}
    \chapter{How to build a time machine}

    \lipsum[1-12]

%   \pagestyle{style2}
    \chapter{How to destroy a time machine}

    \lipsum[1-12]

%   \pagestyle{style1}
    \chapter{How to build a time machine}

    \lipsum[1-12]

    \backmatter

\end{document}

我需要改变的是位于之间的代码页眉和页脚文件

代码当前在每个奇数页的页眉内创建彩色框,并且每个页面都这样做。我的目标是创建一个没有这些框的页眉样式,同时在第二个页眉样式中保留当前样式,我正在考虑实现以下代码以完成此操作:

\fancypagestyle{style1}{ % without colored boxes

}

\fancypagestyle{style2}{ % with colored boxes

}

我需要两个标题完全相同,除了一个标题没有那些框而另一个标题有那些框之外。

相关内容