# \fancyhead Even vs Odd pages failing

I am creating worksheets in which odd pages should say "Exercises" in the header while even pages should say "Solutions" in the header using documentclass article, printed twosided.

Why does this code make ALL pages say "Odd Pages for Exercises" in the header?

\documentclass[twosided]{article}

\usepackage{fancyhdr}
\pagestyle{fancy}

\begin{document}

should be odd and say so in header

\newpage

should be even and say so in header

\newpage

should be odd and say so in header

\newpage

should be even and say so in header

\end{document}


The issue in your case is very simple: the class option you have to use is twoside instead your used twosided. See also the warnings in the log file you got!

So with the correct code

\documentclass[twoside]{article} % <====================================

\usepackage{fancyhdr}
\pagestyle{fancy}

\begin{document}

should be odd and say so in header page 1

\newpage

should be even and say so in header page 2

\newpage

should be odd and say so in header page 3

\newpage

should be even and say so in header page 4

\end{document}


you get the wished result:

• Thank you! I didn't even notice that problem in the log file because TeXMaker put it in blue and the file compiled... there was no red, so I didn't even read it. – WeCanLearnAnything Apr 30 at 15:35

This should do it:

\documentclass[twoside]{article}

\usepackage{fancyhdr}
\fancypagestyle{somepagestyle}{
\pagestyle{somepagestyle}

\begin{document}

should be odd and say so in header

\newpage

should be even and say so in header

\newpage

should be odd and say so in header

\newpage

should be even and say so in header

\end{document}


Btw, the class option is twoside, not twosided.

• Thanks! What was the purpose of the \pagestyle{...}... changes to the code? – WeCanLearnAnything Apr 30 at 15:36
• In this code it's probably not that useful, but if you want to have more than one pagestyle throughout your document that's the syntax to use. – noibe Apr 30 at 16:18
• And by "pagestyle", you mean templates for footers and headers, right? – WeCanLearnAnything May 6 at 0:52