![我如何将当前的标题样式分成两个可以在其间进行更改的相似的标题样式?](https://linux22.com/image/358096/%E6%88%91%E5%A6%82%E4%BD%95%E5%B0%86%E5%BD%93%E5%89%8D%E7%9A%84%E6%A0%87%E9%A2%98%E6%A0%B7%E5%BC%8F%E5%88%86%E6%88%90%E4%B8%A4%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%9C%A8%E5%85%B6%E9%97%B4%E8%BF%9B%E8%A1%8C%E6%9B%B4%E6%94%B9%E7%9A%84%E7%9B%B8%E4%BC%BC%E7%9A%84%E6%A0%87%E9%A2%98%E6%A0%B7%E5%BC%8F%EF%BC%9F.png)
我正在考虑使用 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
}
我需要两个标题完全相同,除了一个标题没有那些框而另一个标题有那些框之外。