我希望有一个由 3 种或更多不同颜色组成的头部规则,如下图所示:
到目前为止,我已经成功创建了一个单色的头部规则,如下图所示,但我想要一个多色的。
以下是我的 MWE:
\documentclass[11pt,openany,twoside]{book}
\raggedbottom
\let\cleardoublepage=\clearpage
\usepackage[left=2.5cm, right=2.5cm, top=3cm, bottom=3cm,a4paper]{geometry}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\newcommand\HRule{\noindent\rule{\linewidth}{1.5pt}}
\usepackage[dotinlabels]{titletoc}
\usepackage{background}
\backgroundsetup{contents={}}
\usepackage{fancyhdr}
\usepackage{hhline}
\pagestyle{fancy}
\renewcommand\headrule
{{ \color{red}%
\hrule height 2.5pt
width\headwidth
}}
\renewcommand{\footrulewidth}{2pt}
\usepackage{blindtext}
\usepackage[noindentafter,calcwidth]{titlesec}
\usepackage[courier]{quotchap}
\usepackage{helvet}
\renewcommand\sectfont{\bfseries}
\usepackage{calc}
\newcommand*\myheaderfooterfont{\normalfont\bfseries}
\usepackage[nottoc]{tocbibind}
\usepackage[ragged]{sidecap}
\usepackage[marginal]{footmisc}
\renewcommand\footnoterule{\vspace*{-3pt}%
\hrule width 2in height 1.4pt \vspace*{2.6pt}}
\setlength\footnotemargin{10pt}
\begin{document}
\Blinddocument
\end{document}
答案1
具有三种颜色等长的规则段:
\documentclass[11pt,openany,twoside]{book}
\usepackage[hmargin=2.5cm, vmargin=3cm,a4paper]{geometry}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\headrule
{{ \color{blue}\rule{0.33\headwidth}{2.5pt}% <---
\color{red}\rule{0.34\headwidth}{2.5pt}% <---
\color{orange}\rule{0.33\headwidth}{2.5pt}% <---
}}
\usepackage{helvet}
\newcommand*\myheaderfooterfont{\normalfont\bfseries}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}