Automatic Chapter title (odd page) and Section title (even page) in a one-sided thesis format

fancyhdrheader-footerpage-numbering

Our university has instructions to write the thesis in a one-sided format.
I am trying to place the chapter title and section title in the odd-even pages.
I have succeeded (with manual inputs) in placing these along with the page number using the code from this link.

I manually put the following code in every section (of every chapter) to get this.

\pagestyle{fancy}
\newcommand\cotitle{Chapter 1 Title}
\newcommand\secco{Chapter 1, Section 1 Title}
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[C]{%
\ifodd\value{page}
  \small\scshape\cotitle
\else
  \small\scshape\secco
\fi }
\fancyhead[R]{\thepage\ifodd\value{page}\else\hfill\fi}

Is it possible to use \rightmark and \leftmark to get automatic chapter title (say, in the odd pages) and section title (say, in the even pages) in a one-sided thesis format?

Note that, I have 5 chapters and each containing 4-6 sections.

Any help will be highly appreciated. Thanks in advance.

Best Answer

As Peter Wilson said you could use a twoside document but with the same left and right margins, which can be done with the geometry package. Something like

\usepackage[leftmargin=5cm,rightmargin=5cm]{geometry}

The other way is to use a oneside document and use the \ifodd\value{page} as you have done in your code, but using \leftmark and \rightmark. This is the solution that I am offering you.

\documentclass[oneside]{report}

\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\newcommand\cotitle{Chapter 1 Title}
\newcommand\secco{Chapter 1, Section 1 Title}
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[C]{%
  \small\scshape
  \ifodd\value{page}
    \leftmark
  \else
    \rightmark
  \fi}
\fancyhead[L]{\ifodd\value{page}\else\thepage\fi}
\fancyhead[R]{\ifodd\value{page}\thepage\fi}


\begin{document}

\chapter{Introduction}

\lipsum[1]

\section{The first section}

\lipsum[2-11]

\end{document}

enter image description here

enter image description here