# Horizontal line under header background

I made a function that displays a header background. However, there supposed to be a horizontal line right under the background image, that goes from very left to very right with no margins.

This is my current code:

\documentclass{article}

\usepackage{lipsum}
\usepackage{wallpaper}

\AtPageLowerLeft{%
\parbox[b][\paperheight]{#1\paperwidth}{%
\includegraphics[width=#1\paperwidth,height=#1\paperheight,%
keepaspectratio,trim={#2},clip]{#3}%
\vfill%
}
}
}
}

\begin{document}
\lipsum[1-3]
\end{document}


And this is how it looks:

I've tried putting following under \vfill, but no results:

\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}%


What I'm doing wrong? How to get that line under the image?

• \vfill puts it at the bottom of the page, doesn't it? If you colour it red, you can just see it on the edge of the page. – cfr Jul 13 '15 at 21:13
• But also you have made the image twice \paperheight high. So the rule is going to be 2\paperheight down from the top of the page. – cfr Jul 13 '15 at 21:16
• Maybe you want something like \newcommand{\BackgroundHeader}[3]{% \AddToShipoutPicture{% \AtPageLowerLeft{% \parbox[b][\paperheight]{#1\paperwidth}{% \includegraphics[width=#1\paperwidth,trim={#2},clip]{#3}% \par% \vfill \noindent\makebox[\paperwidth]{\color{red}\rule{\linewidth}{0.4pt}}% \bigskip \par }% }% }% }? – cfr Jul 13 '15 at 21:23
• @cfr I think you should turn your comments into an answer :-) – Gonzalo Medina Jul 13 '15 at 22:52
• @GonzaloMedina The trouble is, I'm not sure what it is meant to look like. How big should the background image really be and where should the line really go? – cfr Jul 13 '15 at 23:28

If the line should be under the header image you have to put it before \vfill:

Code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{wallpaper}

\AtPageLowerLeft{%
\parbox[b][\paperheight]{#1\paperwidth}{%
\includegraphics[width=\linewidth,height=7\baselineskip
]{#3}% <- necessary to avoid spurious spaces
\vspace*{-\baselineskip}
\textcolor{red}{\rule[-2pt]{\paperwidth}{2pt}}%
\vfill%
}
}
}
}

\begin{document}

Note that I have changed the options for \includegraphics because I do not have your picture.
If the image should be part of the page style you could also use package scrlayer, see Fancy header and footer including images with tikz