我正在考慮使用 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
}
我需要兩個標題相同,除了一個沒有這些框,而另一個有它們。