2

Concretely, if the header has two lines, the page number takes the position of the second line and therefore is one line below the page numbers of all pages with only one line in the header. I use the twoside document class and the fancyhdr package for creating the header. I guess that the problem lies in the vertical alignment of the header. The header should be aligned to the top, but apparently is aligned to bottom. My Latex code is

\fancyhead[RO,LE]{\thepage}
\fancyhead[LO,RE]{}
\fancyhead[CO]{\textit{very title}}
\fancyhead[CE]{\textit{long title}}
\fancyheadoffset[LE, RO]{0cm}
\fancyfoot{}

Thank you so much for any advice!

2

Here is a solution. fancyhdr use \parbox[b] one can change it to \parbox[t]

\documentclass[twoside]{article}
\usepackage{fancyhdr}

\makeatletter
\def\@fancyhead#1#2#3#4#5{#1\hbox to\headwidth{\fancy@reset
  \@fancyvbox\headheight{\hbox
    {\rlap{\parbox[t]{\headwidth}{\raggedright#2}}\hfill
      \parbox[t]{\headwidth}{\centering#3}\hfill
      \llap{\parbox[t]{\headwidth}{\raggedleft#4}}}\headrule}}#5}
\makeatother

\fancyhead[RO,LE]{\thepage}
\fancyhead[LO,RE]{}
\fancyhead[CO]{\textit{very title}}
\fancyhead[CE]{\textit{long title long title long title long title long title long title    long title long title long title long title long title long title}}
\fancyheadoffset[LE, RO]{0cm}
\fancyfoot{}
\pagestyle{fancy}

\begin{document}

\section{Introduction}
bla bla
\newpage
bla bla
\newpage
bla bla
\newpage
bla bla

\end{document}

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.