0

I am using fancydhr for my title page to display logos on its header and footer. For the rest of my report I use \pagestyle{plain} to get the standard footer with only the page number. But using the \pagestyle{fancy} on the first page causes the entire document to be like shifted down, and the page numbering disappears. I can only recover it by increasing the bottom margin up to 6 cm but it keeps a 6 cm space between the end of the text and the end of the page, so this solution does not suit me well.

Here is my code with my desired margins :

\documentclass[11pt,a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage[french]{babel}
\usepackage{ragged2e}


\usepackage{graphicx}
\usepackage{esint}
\usepackage{gensymb}
\usepackage{lipsum} 

\usepackage{fancyhdr} 
\usepackage[left=2.5cm, right=2.5cm, top=2cm, bottom=2cm, includehead, includefoot, heightrounded, footskip=30pt, headheight=12pt]{geometry}
\usepackage{titlesec}
\usepackage[pdfa]{hyperref}

\setlength{\parindent}{4ex} % alinea size
\hypersetup{linkbordercolor=1 1 1, urlbordercolor=1 1 1}


% ============================  Header with logo ===============================

% -----------------------------------
\renewcommand{\headrulewidth}{0pt} % supprime la ligne de header
\fancyhf{}
% ------------- Header --------------
\fancyhead[L]{\includegraphics[width=2.5cm]{example-image-a}}
\fancyhead[R]{\includegraphics[width=2.5cm]{example-image-b}}
\fancyhead[C]{\includegraphics[width=2.5cm]{example-image-c}}
% ------------- Footer --------------
\fancyfoot[L]{\includegraphics[width=4.5cm]{example-image-b}}
\fancyfoot[R]{\includegraphics[width=4.5cm]{example-image-b}}
% -----------------------------------
\pagestyle{plain}

% ==============================================================================
% ================================= DOCUMENT ===================================
% ==============================================================================
\begin{document}

% Title Page
\thispagestyle{fancy}
\vspace*{3cm}   
\begin{center}
        \Huge \textsc{Rapport de stage}\\
    \vspace{10mm}
    \large \textit{présenté par}\\
    \vspace{5mm}
    \Large \textbf{Anderson DA SILVA} \\
    \vspace{7mm}
        \hrulefill \\ 
        \vspace{0,5cm}
            \Huge \textbf{Étude de la couche limite atmosphérique en Atlantique tropical dans le cadre de la campagne EUREC$^4$A}\\ 
        \hrulefill \\
    \vspace{10mm}

    \large Stage effectué au LATMOS du \textit{19 avril 2021} au \textit{19 juillet 2021}.\\
    Sous la direction et la tutelle de \textbf{Richard WILSON} et de \textbf{Hugo BELLENGER}.\\ \vspace{1cm}
\newpage

\end{center}

% -------------- Document corps ----------------
\lipsum[1-24]

\end{document}

2
  • 1
    Don't you get an error message when you compile? I get the message that \hypersetup{linkbordercolor=1 1 1, urlbordercolor=1 1 1} is an undefined control sequence. Disactivating this line for me makes the file compilable (except for not having your images).
    – C. Peters
    Jun 6, 2021 at 17:12
  • When I add \usepackage[pdfa]{hyperref} (found on tex.stackexchange.com/questions/498987/…) the error message disappears. Please adapt your file by inserting example logos and have a look whether the problem is solved.
    – C. Peters
    Jun 6, 2021 at 17:36

2 Answers 2

0

The .log file says you have to increase \headheight and \footskip. Do this by including headheight=...,footskip=... in the geometry line. Use the numbers as given in the warnings (or rounded up).

And good advice: always check the .log file

Edit : Then, for the rest of the document with no header, set a newgeometry with \newgeometry{left=2.5cm, right=2.5cm, top=2cm, bottom=2cm, includefoot, heightrounded, footskip=30pt} for example.

6
  • I've added the example images, and modified the geometry package options but nothing really changed. I've tried different lengths for footskip and headheight but it only acts like changing the bottom margin.
    – Andersyes
    Jun 6, 2021 at 19:25
  • The .log file says headheight should be at least 57.42738pt and footskip at least 100.11116pt. You didn't do that. Jun 6, 2021 at 20:33
  • You're right, my bad. I didn't read the right values in the .log. But what about the blank space on every pages that seems to be kept in case I would like to draw my header and footer on them ? I want the text to begin at the distance decided by the top margin, and to end at the distance told by the bottom margin
    – Andersyes
    Jun 6, 2021 at 21:17
  • You can put at the beginning of the next page, after the \newpage, which by the way should be AFTER the \end{center}: \newgeometry{includeheadfoot, headheight=12pt, footskip=30pt} Jun 6, 2021 at 21:52
  • And if you don't know where the next page begins, for example if the text continues at the page break: \usepackage{afterpage} ... \afterpage{\globaldefs=1 \newgeometry{includeheadfoot, headheight=12pt, footskip=30pt}} before \begin{document} Jun 6, 2021 at 21:54
1

I'd use a different approach: the images at top and bottom aren't really headers and footers.

\documentclass[11pt,a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage[french]{babel}
\usepackage{ragged2e}


\usepackage{graphicx}
\usepackage{esint}
\usepackage{gensymb}
\usepackage{lipsum} 

\usepackage[
  left=2.5cm,
  right=2.5cm,
  top=2cm,
  bottom=2cm,
  includehead,
  includefoot,
  heightrounded,
  footskip=30pt,
  headheight=14pt
]{geometry}
\usepackage{titlesec}
\usepackage[pdfa]{hyperref}

\setlength{\parindent}{4ex} % alinea size
\hypersetup{linkbordercolor=1 1 1, urlbordercolor=1 1 1}

\newcommand{\headimage}[2][]{%
  \raisebox{-\height}[0pt][0pt]{%
    \includegraphics[#1]{#2}%
  }%
}
\newcommand{\footimage}[2][]{%
  \raisebox{0pt}[0pt][0pt]{%
    \includegraphics[#1]{#2}%
  }%
}

\pagestyle{plain}

% ==============================================================================
% ================================= DOCUMENT ===================================
% ==============================================================================
\begin{document}

% Title Page
\thispagestyle{empty}

\begin{center}

\vspace*{-2cm} % adjust to suit

\headimage[width=2.5cm]{example-image-a}\hfill
\headimage[width=2.5cm]{example-image-b}\hfill
\headimage[width=2.5cm]{example-image-c}

\vspace*{\stretch{1}}

{\Huge\scshape Rapport de stage\\}

{\large\itshape présenté par\\}

{\Large\bfseries Anderson DA SILVA\\}

\hrulefill \\ 

\vspace{0,5cm}

{\Huge\bfseries Étude de la couche limite atmosphérique en Atlantique 
  tropical dans le cadre de la campagne EUREC$^4$A\\}

\vspace{0,5cm}

\hrulefill \\

\vspace{10mm}

{\large Stage effectué au LATMOS du \textit{19 avril 2021} au \textit{19 juillet 2021}.\\
  Sous la direction et la tutelle de \textbf{Richard WILSON} et de \textbf{Hugo BELLENGER}.\\}

\vspace*{\stretch{2}}

\footimage[width=4.5cm]{example-image-b}\hfill
\footimage[width=4.5cm]{example-image-b}

\vspace*{-1cm} % adjust to suit

\end{center}

\clearpage
% -------------- Document corps ----------------
\lipsum[1-24]

\end{document}

Adjust the spacings to suit.

enter image description here

1
  • This was my old setup, and for sure it works !
    – Andersyes
    Jun 7, 2021 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .