# Fancy Header is not at the same place on first page

I'm currently writing a latex code generator to make invoices and I have a problem with my headers. I'm using fancy headers to make my headers and I'm using the output of the compiler to set the height of the header and the text. My problem is that my header is not at the same position on the first and the second page. It is higher on the first page and I don't find any solution to this problem.

Here is the code :

\documentclass[a4paper]{article}
% setting language
\usepackage[frenchb]{babel}

% geometry --> margin ++
\geometry{a4paper,margin=1cm}

\usepackage{tabularx}
\usepackage{booktabs}

%\usepackage[absolute,overlay]{textpos}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{0.4pt}
\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}

\usepackage{lipsum}

\renewcommand{\arraystretch}{1}
\raisebox{0\height}{
\begin{tabular}{p{4.99cm}l}
Left part
&
Right part
\\
\end{tabular}
}}
\fancyhead[R]{ \vtop{\begin{tabular}{l} \textbf{Devis n° 5}\\\textbf{Original}\\Page  \end{tabular}}}
\fancyfoot[C]{\textbf{Masidaso Consulting - N° TVA :BE0834757576}\\}

% début du corps
\begin{document}

\parskip=0pt\parindent=0pt

\renewcommand{\arraystretch}{1.4}

\begin{tabularx}{\linewidth}{!{\VRule[2pt]}X!{\VRule[2pt]}X!{\VRule[2pt]}X!{\VRule[2pt]}}  \specialrule{2pt}{0pt}{0pt} Client & Intelocuteur & Page \\   \specialrule{2pt}{0pt}{0pt} 2 - Minou Chat & Mr le vendeur & page \\  \specialrule{2pt}{0pt}{0pt} \end{tabularx}
\lipsum
\lipsum
\renewcommand{\arraystretch}{1}

\end{document}
-
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  N.N. Jan 13 '12 at 15:18
try adding \thispagestyle{fancy} after \begin{document} but before anything else is set. –  barbara beeton Jan 13 '12 at 15:28
Ok I wont thank people in advance next :-) You guys are quite fast! @barbara beeton : your solution does not work but the one given below does. –  Thibault Dory Jan 13 '12 at 16:47
This is a lot of code. Even though you already got an answer, it'd be nice if you could remove everything from the code that's not related to your problem to make it a so-called minimal working example (MWE), that people can copy and compile to reproduce your problem. This way, your problem becomes relevant for a wider audience. All the tables and font definitions have nothing to do with the headers. If you need filler text, you can use e.g. the lipsum package. –  doncherry Jan 13 '12 at 17:27
I've updated the code to remove what's not related to the problem. Nevertheless, I still need at least one table in the document section for the \renewcommand{\arraystretch}{X} to be relevant. I hope it's short enough. If there are other concerns, just tell me and I'll try to fix them :-) –  Thibault Dory Jan 13 '12 at 18:59

The problem is that you're changing \arraystretch in the middle of the document, and this is reflected in the typesetting of the headers. Add \renewcommand{\arraystretch}{1} in the fields \fancyhead where you use tabulars. However the definitions seem quite complicated; the following code seems simpler.

\renewcommand{\arraystretch}{1}%
\raisebox{\dimexpr-\height+\ht\strutbox}{%
\includegraphics[keepaspectratio,width=4.99cm,height=1.23cm]{logo.png}}%
\begin{tabular}[t]{l}
\chancery{\textbf{\LARGE Masidaso Consulting}}\\
E-mail :  \href{mailto:minou@gmail.com}{minou@gmail.com}\\
Tel : 0486609929\\
ligne \\ ligne \\ ligne \\ ligne \\ ligne
\end{tabular}\hfill
\begin{tabular}[t]{l}
\textbf{Devis n° 5}\\
\textbf{Original}\\
Page \thepage{} / \pageref{LastPage}
\end{tabular}}

For this header, fancyhdr reports a height of 102pt.

-
It works perfectly! Could you tell me how you get the height of the header with fancyhdr? For the moment I simply run the compiler and get the height from the warning in the log. –  Thibault Dory Jan 13 '12 at 17:11
@ThibaultDory The same method I used: I put no setting of \headheight and compiled. :) –  egreg Jan 13 '12 at 17:16