1

I use a header (blue rule and image) and a footer (blue rule).

I have 2 issues that I'm trying to solve:

1. I want my footer rule to touch the very bottom of the page (there is some bottom-margin of sorts currently). How can I achieve that? (see image below)

enter image description here

2. I don't know how to remove that random black line appearing on the header. It seems to appear when I include "\pagestyle{fancy}" or "\thispagestyle{fancy}" - but without them, my header won't show at all. Any ideas on how to remove that black line? And why does it appear in the first place? (see image below)

enter image description here

This is my code:

\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}

Img file: enter image description here

  • 1
    This code is not compilable: highlight_colour is not defined, the '(x)color` package is not loaded, and most importantly, we don't even know the dimensions of the image in the header. – Bernard May 31 at 18:39
  • You can replace the 'highlight_colour' with any other pre-existing color name e.g. 'red' - that does not affect the issues I'm having in any way. But here's how i defined it \definecolor{highlight_colour}{HTML}{067dac}. I haven't set in Latex the dimensions of the image - i just called the image file as is. – Constantina May 31 at 19:09
  • Yes, but we don't have this image, so my answer uses the [demo] option for \includegraphics. Always post compilable codes so we can test instantly and see what happens. – Bernard May 31 at 19:12
  • Well noted, thank you. I've edited my post to include the img file and custom blue color code. Your answer below has worked, thank you. – Constantina May 31 at 19:32
  • You're welcome. Note, that using eso-pic, it will simpler to add the page number, to, say, the footer. – Bernard May 31 at 19:35
3

The rule is removed by setting \headrulewidth to 0pt. As to the rules at the top and bottom of the paper sheet, it is simpler to do that with 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} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.