Take the 2-minute tour ×

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 :

% setting language                                                                          

% geometry --> margin ++                                                                    



\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}                                                                                                                                                  


         Left part                                          
         Right part       
\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{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}                                                                                  

share|improve this question
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

1 Answer 1

up vote 2 down vote accepted

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.

    \chancery{\textbf{\LARGE Masidaso Consulting}}\\
    E-mail :  \href{mailto:minou@gmail.com}{minou@gmail.com}\\
    Tel : 0486609929\\
    ligne \\ ligne \\ ligne \\ ligne \\ ligne
    \textbf{Devis n° 5}\\
    Page \thepage{} / \pageref{LastPage}

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

share|improve this answer
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

Your Answer


