1

I am relying on the following thread to help solve my problem

can Latex recognise odd and even pages without 'twoside'

Essentially, what I would like to do is something like

\documentclass[12pt]{article}

\usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{}

\fancyhead[OL]{something} % print "something" on even pages \fancyhead[EL]{something else} % print "something else" on odd pages

however, the "something" gets printed on every page (instead of odd pages), while the "something else" is completely ignored.

Any idea on what is happening and how to fix the issue?

  • Probably, something is written to both sides (like \markboth), then something else get written to both sides, erasing something. – John Kormylo Jun 22 '20 at 01:09
  • 1
    BTW, you can have twoside and still use symmetrical margins. OTOH, \marginpar would also alternate sides. – John Kormylo Jun 22 '20 at 01:11
  • Right, however twoside is problematic for me, which is why I seek an alternative approach. Including an \if \else block does not appear to help either, as I just get a bunch of error messages – compbiostats Jun 22 '20 at 01:15
  • You can always create your own headers using everypage and tikzpagenodes. – John Kormylo Jun 22 '20 at 01:16

2 Answers2

2

You can add a test to the header. In the header such a test is safe:

\documentclass[12pt]{article}

\usepackage{fancyhdr,etoolbox,lipsum} \pagestyle{fancy} \fancyhf{}

\fancyhead[OL]{\ifnumodd{\value{page}}{something on odd pages}{something on even pages}}

\begin{document} \lipsum

\end{document}

Ulrike Fischer
  • 327,261
1

Use the changepage package to see if a page is odd or even.

\documentclass[12pt]{article}
\usepackage%[strict] % to guarantee the correct answer
  {changepage}
%

\usepackage{fancyhdr,etoolbox,lipsum} \pagestyle{fancy} \fancyhf{}

\fancyhead[OL]{\ifoddpage something on odd pages \else something on even pages \fi}

\begin{document} \lipsum

\end{document}

Peter Wilson
  • 28,066