0

I'm trying to make a custom header using fancyhdr package. For some reason if I haven't specified the \headheight=3cm, the rest of the document gets wrong header height, even the pages with \pagestyle{plain}. The page with long header is exactly as it needs to be, though. I need to add the header to just one of the pages where a new chapter starts. I just need to use the blankspace without affecting the rest of the layout. I would be happy to use other solutions without fancyhdr package as well.

\documentclass[12pt]{report}
\usepackage[top=1in, bottom=1in]{geometry}
\pagestyle{plain}
\usepackage{fancyhdr}
\usepackage{lipsum}

\fancypagestyle{longheader}{
    \fancyhf{}%
    \fancyhead[R]{a\\b\\c\\d\\e}
    \fancyfoot[C]{\thepage}%
    %\headheight=3cm
}

\begin{document}
    \chapter{}  
    \thispagestyle{longheader}
    This page looks exactly as it should.

    \chapter{}
    This page is shifted.\\
    \lipsum[1-7]    
\end{document}
2
  • Welcome to TeX.SX! That's probably one problem of using many line breaks in a header...
    – TeXnician
    May 25, 2017 at 14:09
  • So how to add headers which include more than one line?
    – Kaur
    May 25, 2017 at 14:28

1 Answer 1

1

You could use a top aligned \parbox and hide its depth. Note that the resulting header overlaps with the text area and you have to ensure that there is enough space.

\documentclass[12pt]{report}
\usepackage[top=1in, bottom=1in,
headheight=14.5pt% <- added
]{geometry}
\pagestyle{plain}
\usepackage{fancyhdr}
\usepackage{lipsum}
%\usepackage{showframe}% to show the page layout

\fancypagestyle{longheader}{
    \fancyhf{}
    \fancyhead[R]{\parbox[t][1ex]{\linewidth}{%
      \raggedleft a\\b\\c\\d\\e\\
      \rule[\ht\strutbox]{\linewidth}{.4pt}%
    }}
    \fancyfoot[C]{\thepage}
    \renewcommand{\headrulewidth}{0pt}
}

\begin{document}
\chapter{}
\thispagestyle{longheader}
This page looks exactly as it should.
\chapter{}
This page is shifted.
\lipsum[1-7]
\end{document}

enter image description here

You must log in to answer this question.

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