# Header on even or odd pages

Hi everyone I have been trying to create a different header for even or odd pages where I want to see the name of the section and the name of subsections. This is what I have done but it is not working.

\usepackage{fancyhdr}
\makeatother

\usepackage{babel}
\begin{document}
\pagenumbering{Roman}

\renewcommand{\thesection}{\Roman{section}}

\section{Introduction}
\newpage

\renewcommand{\thesection}{\arabic{section}}
\setcounter{section}{0}

\pagenumbering{arabic}
\pagestyle{fancy}

\fancyhf{}
\fancyfoot{}

\section{First Section}
\newpage
\subsection{First subsection}
\newpage
\subsection{Second subsection}
\newpage
\section{Second Section}
\newpage
\subsection{First subsection}
\newpage
\subsection{Second subsection}

\end{document}


This is pretty much my example, I would like to see something like this: On even pages the name of the section, and on odd pages the name of the subsection, but I am having the same result always. Only the name of the section appears, and the numeration is not located according with the kind of page (even or odd).

What else do I need to add or erase?.

• Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. Dec 2 '13 at 15:14
• Does this answer of mine help? tex.stackexchange.com/a/122383/27635 Dec 2 '13 at 15:28
• The minimal working example (MWE) should start with \documentclass{...}... Dec 2 '13 at 15:50

Your MWE seems to give what you are asking for if you add \documentclass[english, twoside]{article} to the beginning. The twoside option is necessary in order to have different even and odd sides.

The titleps package provides similar functionality to that of fancyhdr. Here's an implementation using the former which specifies a new main page style using

\newpagestyle{main}[\small]{
[]%                                     even-center
[\thesection\ \sectiontitle]%           even-right
{\thesubsection\ \subsectiontitle}%     odd-left
{}%                                     odd-center
{\thepage}%                             odd-right
}


Also see titleps for fancyhdr users for the similarities/transition between the two packages.

\documentclass[twoside]{article}

\usepackage{titleps}% http://ctan.org/pkg/titleps

\newpagestyle{main}[\small]{
[]%                                     even-center
[\thesection\ \sectiontitle]%           even-right
{\thesubsection\ \subsectiontitle}%     odd-left
{}%                                     odd-center
{\thepage}%                             odd-right
}
\begin{document}
\pagenumbering{Roman}

\renewcommand{\thesection}{\Roman{section}}

\section{Introduction}
\newpage

\renewcommand{\thesection}{\arabic{section}}
\setcounter{section}{0}

\pagenumbering{arabic}
\pagestyle{main}

\section{First Section}
\newpage
\subsection{First subsection}
\newpage
\subsection{Second subsection}
\newpage
\section{Second Section}
\newpage
\subsection{First subsection}
\newpage
\subsection{Second subsection}

\end{document}