0

I am using a custom template to write my thesis, and I am trying to align the page headers on the right side and the page numbers on the left side, in odd pages. The template by default has the same alignment style for all pages (page headers on the top left and page numbers on the top right), as seen below: Default alignment for odd pages

I have succeeded in changing the alignment of the page numbers in odd pages using the code from this question:

\fancyhead[R]{\thepage\ifodd\value{page}\else\hfill\fi}

However, the header now overlaps with the page number in odd pages:

Page number overlaps with header

Could someone offer a hint/solution on how to move the page header to the top right, in odd pages only, so that it doesn't overlap with the page number? It must be something similar in syntax to the line above but I've been trying for a while with \leftmark and \rightmark and can't get it to work.

Many thanks in advance.

Edit: What seems to be causing the problem is that each chapter contained the \lhead{<Chapter header>} code, which is similar to \fancyhead[L]{<Chapter header>}. This is what is pushing the Chapter headers to the left all the time.

2
  • Fancyhdr can hand even/odd internally using [RE] for right even pages and [RO] for right odd pages, etc.l Mar 18 at 14:32
  • Indeed. I think the problem has been resolved.
    – D T
    Mar 18 at 15:48

1 Answer 1

2

What was causing the problem was that each chapter contained the \lhead{<Chapter header>} code, which is similar to \fancyhead[L]{<Chapter header>}. This is what was pushing the Chapter headers to the left all the time.

This was replaced by \fancyhead[LO,RE]{<Chapter header>}

I also added \fancyhead[LE,RO]{\thepage} to the preamble, to keep the page number on the top left side for even pages, and on the top right side for odd pages.

I then deleted:

\fancyhead[R]{\thepage\ifodd\value{page}\else\hfill\fi}

because of what I read here.

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.