![无法更改标题行的颜色(fancyhdr)](https://linux22.com/image/330573/%E6%97%A0%E6%B3%95%E6%9B%B4%E6%94%B9%E6%A0%87%E9%A2%98%E8%A1%8C%E7%9A%84%E9%A2%9C%E8%89%B2%EF%BC%88fancyhdr%EF%BC%89.png)
我正在尝试将标题中的线条颜色更改为灰色,但我不知道如何正确地进行操作。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel} % Включаем пакет для поддержки русского
\usepackage[a4paper, portrait, margin=1in, hmargin=1.3cm, top=4cm, bottom=4cm, headheight=3cm, footskip=2.5cm]{geometry}
%\usepackage[tiny]{titlesec}
\usepackage{fancyhdr}
\usepackage{tabu}
\usepackage{xcolor}
% not sure is it a right command
% \newcommand\setheadrule[1]{%
% \def\makeheadrule{{\color{ grey}\rule[-.3\baselineskip]%{\linewidth}{#1}}}%
% }
\fancypagestyle{prefirstpage}
{
\rhead{
\hline
\begin{tabu} to \textwidth { |X[0.15,l,p]|X[0.25,l,p]|X[0.25,l,p]|X[0.4,l,p]|}
\taburulecolor{gray}
& \multicolumn{2}{l|}{Adress} & \\ [10ex] \hline
& \textbf{№ УКД:} & \textbf{ Версия:} & \textbf{Страниц:} \\ \hline
\end{tabu}
%not sure is it right command
% \setheadrule{}
}
}
\begin{document}
\pagestyle{prefirstpage}
\end{document}
答案1
该fancyhdr
软件包已经提供了对带有\headrule
和的头规则的支持\headrulewidth
。颜色有点棘手,但也可以通过将旧代码存储在命令中\oldheadrule
并使用{\color{\headrulecolour}\oldheadrule}}
(注意分组{}
)来使用
有明确的警告说头部高度太小,这就是我增加它的原因。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel} % Включаем пакет для поддержки русского
\usepackage[a4paper, portrait, margin=1in, hmargin=1.3cm, top=5.5cm, bottom=4cm, headheight=125pt, footskip=2.5cm]{geometry}
\usepackage{fancyhdr}
\usepackage{tabu}
\usepackage[svgnames,x11names,dvipsnames]{xcolor}
\providecommand{\copyid}{4711}
\providecommand{\varVersion}{3.14159}
\newcommand{\headrulecolour}{white!70!black}
\renewcommand{\headrulewidth}{.1\baselineskip}
\let\oldheadrule\headrule
\fancypagestyle{prefirstpage}
{
\rhead{%
\begin{tabu} to \textwidth { |X[0.15,l,p]|X[0.25,l,p]|X[0.25,l,p]|X[0.4,l,p]|}
\hline
\taburulecolor{gray}
& \multicolumn{2}{l|}{Adress} & \\ [10ex] \hline
& \textbf{№ УКД:} \copyid{} & \textbf{ Версия:} \varVersion{} & \textbf{Страниц:} \\ \hline
\end{tabu}
}
\renewcommand{\headrule}{{\color{\headrulecolour}\oldheadrule}}%
}
\begin{document}
\pagestyle{prefirstpage}
.
\end{document}