Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I get one image as a header that is not just the header but extends to the top of the page limits and also left and right? I have see this Minipage in Header? but is not to have the image to the top of the page limits, and this How do I put the top of an image at the top of a page but I do not understand what to do

I have tried this but the result is not the expected. When Ι replace width=\textwidth with width=\pagewidth does not work.

\documentclass{article}

\usepackage{kantlipsum}
\usepackage{fancyhdr}
\usepackage[demo]{graphicx}

\usepackage[right=2.5cm,left=2.5cm,top=2.5cm,bottom=2.0cm,total={165mm,243mm},showframe,includeheadfoot]{geometry}

\pagestyle{fancy}

\fancyhead[L]{%
% \centering
% \vspace{-7cm}
  \includegraphics[width=\textwidth,height=2.5cm]{logo.png}
}

% \fancyfoot[L]{\thepage}


\begin{document}
\kant
\end{document}

enter image description here

Update-1 What I want is probably very close to this approach http://www.texample.net/tikz/examples/fancy-chapter-headings/ but not be connected to the chapter but with one image

share|improve this question
1  
This question reminds me on How to include a picture over two pages, left part on left side, right on right (for books)?. Parts of its solution could be used here as well. –  Martin Scharrer Feb 6 '13 at 17:10
    
@MartinScharrer It had not fallen in my perception this question I will definitely use it in my main document –  karathan Feb 6 '13 at 17:46

1 Answer 1

up vote 6 down vote accepted

Well the main points to solve things like this are

  1. hide the actually extend of the graphic so that LaTeX thinks it has neither width nor height.
  2. Move it around e.g. with \hspace and \raisebox. Picture environments can be use too.

    \documentclass{article}
    \usepackage{kantlipsum}
    \usepackage{fancyhdr}
    \usepackage[demo]{graphicx}
    
    \usepackage[right=2.5cm,left=2.5cm,top=2.5cm,
              bottom=2.0cm,total={165mm,243mm},showframe,includeheadfoot]{geometry}
    
    \pagestyle{fancy}
    
    \fancyhead[L]{%
      \hspace*{\dimexpr -1in-\oddsidemargin}%
      \makebox[0pt][l]{\normalsize %the [0pt] hides the width
          \raisebox{\dimexpr\headheight-\dp\strutbox
              +1in+\topmargin-\height}[0pt][0pt]{% the [0pt][0pt] hides height and depth
         \includegraphics[width=\paperwidth,height=2.5cm]{logo.png}}}%
    }
    
    
    
    \begin{document}
    \kant
    \end{document}
    
share|improve this answer
    
Great answer. Just for reference here how to do the same using adjustbox: \usepackage[export]{adjustbox} \fancyhead[L]{% {\normalsize \includegraphics[width=\paperwidth,height=2.5cm,lap={0pt}{-1in-\oddsidemargin}, raise={\headheight-\dp\strutbox+1in+\topmargin-\height}{0pt}{0pt}]{example-image‌​}}% } –  Martin Scharrer Feb 6 '13 at 17:34
    
I delayed because I did my tests and works extremely! :) –  karathan Feb 6 '13 at 17:49
    
Could you give a clarification on "hide the actually extend of the graphic..." . Where exactly happens this inside the code? As you understand I'm not an expert I have lot of work ahead :) –  karathan Feb 6 '13 at 18:01
    
@karathan: I added two comments. –  Ulrike Fischer Feb 6 '13 at 18:02
    
@UlrikeFischer after addition of your comments I think I get it, definitely an excellent approach –  karathan Feb 6 '13 at 18:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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