1

with this code:

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{fancyhdr}
\title{fancy}
\author{xxx}
\date{March 2024}
\fancyhead[C]{\includegraphics[width=200mm,height=39mm]{banner_corto_completo_blu.jpg}}  
 \fancyhead[L]{\includegraphics[width=20mm,height=39mm]{wepik-export-20240319220855HA4H.jpeg}}
 \fancyhead[R]{\includegraphics[width=40mm,height=39mm]{wepik-export-20240319220855HA4H.jpeg}}
 
 \par
      \vspace*{+4ex}


    \pagestyle{fancy}
\begin{document}

\maketitle

\section{Introduction}

\end{document}

I would have 1 image that spread all the page (\fancyhead [C]...]) in background and the other two (\fancyhead [L]...and \fancyhead[R]) over the background image. I made many change but I obtain that just the Left image go over the backgroud, but never the right one. what is wrong?

Thank you

Renato

2 Answers 2

2

The order in which the header parts are put in the output file is L - C - R. So I would expect the left part to be covered by the background and the right part to be on top of the background. Your description is the reverse, which I don't understand.

This is how fancyhdr works, and that cannot be changed. However you could put the background image together with the left image (in that order) overlapping each other in the L header, and leave the C header empty.

 \fancyhead[C]{}
 \fancyhead[L]{%
   \rlap{\includegraphics[width=200mm,height=39mm]{banner_corto_completo_blu.jpg}}%
   \includegraphics[width=20mm,height=39mm]{wepik-export-20240319220855HA4H.jpeg}}
 \fancyhead[R]{\includegraphics[width=40mm,height=39mm]{wepik-export-20240319220855HA4H.jpeg}}

I think this should solve it. I can't try it with your images, but I tested it with other images.

And in order to horizontally center the background image, you can put it inside a \makebox, like this:

\rlap{\makebox[\headwidth]{\includegraphics...}}

So this code, with the background image a 200mm x 39 mm yellow rectangle, generated the header below. The textwidth goes from the left side of image A to the right side of image B, and is indicated by the horizontal line below the image.

 \fancyhead[C]{}
 \fancyhead[L]{%
   \rlap{\makebox[\headwidth]{\includegraphics[width=200mm,height=39mm]{background}}}%
   \includegraphics[width=20mm,height=39mm]{example-image-a}}
 \fancyhead[R]{\includegraphics[width=40mm,height=39mm]{example-image-b}}

enter image description here

5
  • I'm not able to use it. it looks like I have one image on background left aligned,the other two, not at left and right of the image. Can you write an example with the code I wrote, the I can change the name of image file, or if you prefer I can also send you the image, but I don't know how can I do that
    – RenatoP
    Commented Mar 21 at 19:01
  • See my addition about \makebox. Commented Mar 21 at 19:15
  • sorry, I still don't undestand how \makebox could be useful. I've read that \rlap already create 1 pixel box
    – RenatoP
    Commented Mar 21 at 20:28
  • No, it doesn’t. My solution is `\rlap{\makebox[\headwidth]{…}} Commented Mar 21 at 20:32
  • Can you add a picture of what it should look like? Commented Mar 21 at 20:37
0

ok, I've solved it and I want to share my solution.a friend of mine gave me this solution:

\documentclass{article} \usepackage{graphicx} % Required for inserting images \usepackage{geometry} \geometry{paperwidth=270mm,textwidth=200mm}

\usepackage{fancyhdr} \fancyhead{} \headheight=45mm \renewcommand{\headrulewidth}{0pt}

\fancyhead[C]{% \makebox[0pt][c]{\includegraphics[width=200mm,height=39mm]{banner_corto_completo_blu..jpg}}% \llap{\raisebox{15mm}{\includegraphics[width=60mm,height=39mm,keepaspectratio]{blu.png}\hspace*{40mm}}}% \rlap{\raisebox{15mm}{\hspace*{40mm}\includegraphics[width=60mm,height=39mm,keepaspectratio]{blu.png}}}% }% \pagestyle{fancy}

\begin{document}

\section{Introduzione}

\end{document}

You must log in to answer this question.

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