我使用页眉(蓝色规则和图像)和页脚(蓝色规则)。
我有两个问题需要解决:
1.我希望页脚规则触及页面的最底部(目前有一些底部边距)。我该如何实现?(见下图)
2.我不知道如何去除页眉上出现的随机黑线。当我添加“\pagestyle{fancy}”或“\thispagestyle{fancy}”时,似乎会出现黑线 - 但如果不使用它们,我的页眉根本就不会显示。有没有关于如何去除黑线的想法?为什么会出现黑线?(见下图)
这是我的代码:
\documentclass[9pt, legalpaper]{article}
\usepackage[legalpaper,margin=0.5in]{geometry}
\usepackage{lipsum}
\usepackage{xcolor}
\definecolor{highlight_colour}{HTML}{067dac} % bright blue
% ==============================================
% HEADER AND FOOTER (.sty file)
% ==============================================
\usepackage{fancyhdr} % uses a stylised header and footer
\usepackage{graphicx} % to manage images
\pagestyle{fancy} % to display it on pages
\thispagestyle{fancy} % to display it on the first page too
\fancyhf{} % remove everything
\setlength{\headheight}{14pt}
\chead{
\makebox[\linewidth]{\color{highlight_colour}\rule{\paperwidth}{3pt}}
\makebox[\linewidth]{\includegraphics{header_design02.PNG}}
}
\cfoot{
\makebox[\linewidth]{\color{highlight_colour}\rule{\paperwidth}{3pt}}
}
% ==============================================
% BODY OF THE DOCUMENT (.tex file)
% ==============================================
\begin{document}
{\large Title}
\lipsum[1]
\end{document}
答案1
通过设置为 0pt 来删除规则\headrulewidth
。至于纸张顶部和底部的规则,这样做更简单eso-pic
:
\documentclass[9pt, legalpaper]{article}
\usepackage[legalpaper,margin=0.5in]{geometry}
\usepackage{lipsum}
\usepackage[svgnames]{xcolor}
\colorlet{highlight_colour}{SteelBlue}
% ==============================================
% HEADER AND FOOTER (.sty file)
% ==============================================
\usepackage{fancyhdr} % uses a stylised header and footer
\usepackage[demo]{graphicx} % to manage images
\pagestyle{fancy} % to display it on pages
\renewcommand{\headrulewidth}{0pt}
\thispagestyle{fancy} % to display it on the first page too
\fancyhf{} % remove everything
\setlength{\headheight}{14pt}
\chead{\makebox[\linewidth]{\includegraphics{header_design02.PNG}}
}
\cfoot{}
\usepackage{eso-pic}
\AddToShipoutPictureBG{\AtPageLowerLeft{{\color{highlight_colour}\rule{\paperwidth}{3pt}}}\AtPageUpperLeft{{\color{highlight_colour}\rule[-3pt]{\paperwidth}{3pt}}}}
% ==============================================
% BODY OF THE DOCUMENT (.tex file)
% ==============================================
\begin{document}
{\large Title}
\lipsum[1-20]
\end{document}