1

I am wondering if there is a way to have an image in a header overlap the horizontal line at the bottom of the header? I have my company's logo in the rhead, and some text in the lhead.

I essentially want to increase the size of the logo such that it overlaps the horizontal line, but doesn't move the horizontal line.

Thanks for any feedback/comments/answers!

This is kind of what I'm going for, with the red box being the logo:

enter image description here

As well, here is the preamble section for fancyhdr:

\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{52.6363pt}
\lhead{\textcolor{blue}{Company \\ Product}}
\rhead{\includegraphics[width=2cm]{img-src/logo}}
\lfoot{\textcolor{blue}{Company}}
\rfoot{\textcolor{blue}{\thepage}}
\renewcommand{\footrulewidth}{0.4pt}
3
  • I have just updated the question to show my preamble for fancyhdr. That's essentially all that applies to this situation I think. Jun 14, 2021 at 22:45
  • You can use \raisebox to adjust the baseline and overlap the edges. I don't know if fancyhdr draws the line or the header first. You may have to implement your own header with everypage or \AddToHook. Jun 15, 2021 at 3:56
  • @JohnKormylo I'm not 100% sure how to implement \raisebox here, could you provide an example? Will it work if the logo is in the header itself, or does the logo need to be outside of the header? Jun 15, 2021 at 15:41

1 Answer 1

1

Unfortunately, the line is drawn over the header:

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{52.6363pt}
\lhead{\textcolor{blue}{Company \\ Product}}
\rhead{\raisebox{\dimexpr \baselineskip-\headsep}[0pt][0pt]{\includegraphics[width=2cm]{example-image}}}
\lfoot{\textcolor{blue}{Company}}
\rfoot{\textcolor{blue}{\thepage}}
\renewcommand{\footrulewidth}{0.4pt}

\usepackage{lipsum}% random text

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

This version uses \AddToHook to draw the image separately.

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{52.6363pt}
\lhead{\textcolor{blue}{Company \\ Product}}
\lfoot{\textcolor{blue}{Company}}
\rfoot{\textcolor{blue}{\thepage}}
\renewcommand{\footrulewidth}{0.4pt}

\AddToHook{shipout/foreground}{\ifodd\value{page}\relax
  \put({\dimexpr 1in+\oddsidemargin+\textwidth},{\dimexpr -1in-\topmargin-\headheight+\baselineskip-\headsep})
    {\llap{\includegraphics[width=2cm]{example-image}}}
\else
  \put({\dimexpr 1in+\evensidemargin+\textwidth},{\dimexpr -1in-\topmargin-\headheight+\baselineskip-\headsep})
    {\llap{\includegraphics[width=2cm]{example-image}}}
\fi}
\usepackage{lipsum}% random text

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .