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.

I am trying to insert a logo on the first page without moving the header on every page down. With the following code the logo get inserted but every header on every page is pushed down.

The code (before \begin{document}):

\usepackage{fancyhdr, graphicx}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[L]{}
\fancyhead[R]{
\includegraphics[width=3.5cm]{jedem.pdf}
}
\pagestyle{plain}

The code (after \begin{document}):

\thispagestyle{fancy}

Appreciate if someone can point me in the right direction.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

If you include it like this,

\fancyhead[R]{%
  \raisebox{0pt}[0pt][0pt]{\includegraphics[width=3.5cm]{jedem.pdf}}%
}

then it will not change the vertical header position. But you must make sure there is enough space to the top margin so that the logo doesn't go off the page.

Edit: If you want to move the logo down, replace {0pt} by e.g. {-1ex}.

share|improve this answer
    
I have set the top margin to the following: \setlength{\topmargin}{-8mm} - any changes to it will cause all top-margins to move. I also tried to change the first 0pt but then all pages move. This seems to be a good solution but the logo needs to be pushed down without moving the top-margin of subsequent pages. –  kexxcream Apr 7 '12 at 6:25
    
I updated the answer with a way to move the logo down (without moving anything else). The fancyhdr package doesn't seem to offer an easy interface to changing the page geometry for accomodating a larger header. Try the geometry package for this. –  Stephan Lehmke Apr 7 '12 at 6:58
    
This seems to work quite well. It produce the result that I wanted. What is the function of {0pt}? –  kexxcream Apr 7 '12 at 8:23
    
It is the primary function of \raisebox: To raise (or lower in case of a negative value) something relative to the baseline. –  Stephan Lehmke Apr 7 '12 at 12:28

This is tikz way of doing things like this. You can use \thispagestyle option to apply logo settings only for one page.

\documentclass[oneside,12pt]{article}
\usepackage[demo]{graphicx}% <-----remove demo in your file
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage[charter]{mathdesign}
\usepackage{lipsum} %<-----provides dummy text, remove in your file
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,,headheight=\baselineskip,
   headsep=7mm,footskip=13mm,showframe]{geometry} % <-----remove showframe and alter other things in your file
%---------------------------------------------
\fancypagestyle{logo}{%
  \fancyhf{}   % Clear all headers and footers first
\fancyhead[L]{}
\fancyhead[R]{%
\begin{tikzpicture}[baseline,remember picture,overlay]
\node at ([xshift=-2.5cm,yshift=-2.5cm]current page.north east) {\includegraphics[width=3.5cm]{jedem.pdf}};
\end{tikzpicture}
}%
\setlength{\headsep}{1.1in}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}%
%Change the values in xshift and yshift as per your needs
%---------------------------------------------
\thispagestyle{logo}
\begin{document}
\lipsum[1-5]
\newpage
\lipsum[6-8]
\end{document} 

The first page:

enter image description here

and the second page:

enter image description here

Edit: This is the confusion you will be causing by not providing a complete MWE. You gave only a code snippet and I was left wandering alone to make wild guesses regarding your need. Now that I know - you are using a \maketiltle. \maketitle comes bundled with \thispagestyle{plain}. Hence you have to redefine the \pagestyle{plain}.

Further you used xshift=3cm,yshift=3cm that falls outside the page range. Hence with these shifts you will never get an image inside the page. Please keep these values negative. Here is the code.

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}

\usepackage[demo]{graphicx}
\usepackage[T1]{fontenc}
\usepackage{tikz,lipsum}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,,headheight=\baselineskip, headsep=7mm,footskip=13mm]{geometry}
%---------------------------------------------
\fancypagestyle{plain}{%
 \fancyhf{}%
\fancyhead[L]{}%
\fancyhead[R]{%
\begin{tikzpicture}[baseline,remember picture,overlay]
\node at ([xshift=-3cm,yshift=-3cm]current page.north east) {\includegraphics[width=3.5cm]{jedem.pdf}};
\end{tikzpicture}%
}%
\setlength{\headsep}{0in}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}%
%---------------------------------------------


\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{titling}
\pretitle{\begin{flushleft}\LARGE}
\posttitle{\par\end{flushleft}}
\preauthor{\begin{flushleft}\large}
\postauthor{\par\end{flushleft}\vskip 1.5em}
\predate{\begin{flushleft}\large}
\postdate{\par\end{flushleft}\vskip -5em}

\setlength{\parskip}{1.2ex}        % space between paragraphs
\setlength{\parindent}{1em}        % amount of indention
\setlength{\textwidth}{17cm}       % default = 6.5"
\setlength{\oddsidemargin}{-5mm}   % default = 0"
\setlength{\textheight}{225mm}     % default = 9"
\setlength{\topmargin}{-8mm}       % default = 0"

\title{Testing}
\author{Mr Test}
\date{}
\begin{document}
\maketitle
\noindent
{\bf Abstract}
\end{document}

enter image description here

share|improve this answer
    
I have tried your suggestion but the logo in the pdf does not show up. This is the current code: pastebin.com/PM77sKPD –  kexxcream Apr 7 '12 at 8:18
    
@kexxcream You have to remove the [demo] option from \usepackage{graphicx}, which Harish Kumar used not having your graphic file available. –  egreg Apr 7 '12 at 23:43

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.