1

I am using the following document class:

\documentclass[a4paper,12pt]{ociamthesis}

I am also using the fancyhdr package to put headers and footers on my pages.

\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE,LO]{\leftmark}

At the moment, the header appears on the left-hand side of every page, whether or not it is odd or even. I want it to be on the outer edge of each page.

If I use 'twoside' in the document class line, then it works. But having 'twoside' screws up other things that I haven't been able to find a fix for, and so I'm trying to find another way around the problem.

Is it possible to not use 'twoside' but have the fancyhdr package still put headers in different places, depending if the page is odd or even?

  • 1
    try \fancyhead[L]{\ifodd\value{page}\else\hfill\fi\leftmark} – touhami Aug 24 '15 at 14:40
  • This works almost perfectly, thank you. Only issue it, if the header text is so long that it goes onto two lines. Now, the second line always aligns to the left. I need it to alternate left and right. Is that a quick fix? – user1551817 Aug 24 '15 at 18:02
1

Here is what you need

\documentclass{report}
\usepackage{lipsum}


\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{%
\ifodd\value{page}
\leftmark%
\else
\makebox[0pt][l]{\parbox[b]{\headwidth}{\raggedleft\leftmark}}%
\fi}
\begin{document}
\chapter{chapter 1 bla bla bla bla bla a bla bla bla blaa bla bla bla bla}
\section{section 1}
\lipsum[1-20]

\end{document}

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.