0

I am writing a document in LaTex however I have an issue with the header. I need to insert two images in the header of the file along with some lines of text. So far my code :

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{graphicx}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\includegraphics{departamentulCalc.png}
}
\fancyhead[RE,LO]{\includegraphics{SIglaUTCN.png} 
}
\setlength\headheight{61pt} 

\fancyfoot[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

\begin{document}

\section{First Section}

Hello,  here  is  some  text  without  a  meaning.   This  
text  should  show  what  a printed text will look like at 
this place.  If you read this text, you will get no information.  
Really?  Is there no information?  Is there a difference between 
this ...

\end{document}

Does insert the images but the text in the chapter jumps over the images and over the footer. enter image description here

Any idea on what to do to fix this ? Thank you !

  • Please provide a compilable example. – Fractal is at topanswers.xyz Dec 20 '19 at 13:28
  • The example I have provided above compiles on overleaf.com and the png images are saved in the project. All of it is at: overleaf.com/project/5dfcb1bd86279000014049a2 ( not sure that the project is accessible to others) – Diana G Dec 20 '19 at 13:32
  • Please do not provide external links. Many of us don't use Overleaf – Fractal is at topanswers.xyz Dec 20 '19 at 13:33
  • No, your example does not compile well. Of course it does give an output, but you have some errors. \chapter is not defined in article class, for example. Do you see the little [x] above the PDF viewer? – Fractal is at topanswers.xyz Dec 20 '19 at 13:36
  • Welcome to TeX.SE! Yes, it's very helpful when you provide code that we can compile using any TeX engine. Have you considered just resizing the image, or increasing the height of your header to accommodate the image? – dgoodmaniii Dec 20 '19 at 13:37
1

Your code (at the time of this answer) is not compilable. I think it should be something like this

\documentclass[twoside]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{graphicx}

\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{26pt} 
\fancyhead[LE,RO]{
\includegraphics{departamentulCalc.png}
}
\fancyhead[RE,LO]{
\includegraphics{SIglaUTCN.png} 
}
\fancyfoot[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

\begin{document}

\section{First Section}

Hello,  here  is  some  text  without  a  meaning.   This  
text  should  show  what  a printed text will look like at 
this place.  If you read this text, you will get no information.  
Really?  Is there no information?  Is there a difference between 
this ...

\end{document}

When you compile it, you will receive some warnings like this:

Package Fancyhdr Warning: \headheight is too small (26.0pt): 
Make it at least 60.70523pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.

Do precisely what it tells you to do: \setlength\headheight{61pt}. It will solve the problem.

\documentclass[twoside]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{graphicx}
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{61pt} 
\fancyhead[LE,RO]{
\includegraphics[scale=.5]{example-image-duck}
}
\fancyhead[RE,LO]{
\includegraphics[scale=.5]{example-image-duck} 
}
\fancyfoot[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\begin{document}

\section{First Section}

Hello,  here  is  some  text  without  a  meaning.   This  
text  should  show  what  a printed text will look like at 
this place.  If you read this text, you will get no information.  
Really?  Is there no information?  Is there a difference between 
this ...

\end{document}

enter image description here

|improve this answer|||||
  • Why should I set the length twice ? I have a \setlength\headheight{26pt} above the first header image – Diana G Dec 20 '19 at 13:36
  • @DianaG 26pt is too small. Make the number larger. – Fractal is at topanswers.xyz Dec 20 '19 at 13:37
  • @DianaG 26pt is just as high as two letters stacked. I doubt if your pictures are that small. – Fractal is at topanswers.xyz Dec 20 '19 at 13:39
  • Setting the headheight to 61 does not change the output: imgur.com/a/xWCh3oD – Diana G Dec 20 '19 at 13:40
  • @DianaG Sure, 61pt is still too small, it is just sufficient for my example images, which are not yours. See the warning message. It will tell you the right number. – Fractal is at topanswers.xyz Dec 20 '19 at 13:42

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.