[Tex/LaTex] fancyhdr style problem

fancyhdrheader-footerpage-numbering

I am having some problems with the fancyhdr package. How can I achieve the following in my big thesis file:
The header should consists of the chapter name at the left side and the page number at the right side. The page with number 1 should be the first page of the first chapter.
The "fancy" style should start after the table of contents and everything before should be enumerated with the letter i, ii and so on.

Best Answer

In the following MWE I've created two different page styles: frontmatter and mainmatter. Your typical document structure will most likely include resetting the page style between these document components, including a call to \frontmatter/mainmatter to reset the page number and presentation (\roman and \arabic) as well as other ToC-related stuff:

enter image description here

\documentclass[leqno,12pt,a4paper,oneside]{book}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\fancypagestyle{frontmatter}{%
  \renewcommand{\headrulewidth}{0pt}% No header rule
  \renewcommand{\footrulewidth}{0pt}% No footer rule
  \fancyhf{}% Clear header/footer
  \fancyfoot[C]{\thepage}%
}
\fancypagestyle{mainmatter}{%
  \renewcommand{\headrulewidth}{.4pt}% Header rule
  \renewcommand{\footrulewidth}{.4pt}% Footer rule
  \fancyhf{}% Clear header/footer
  \fancyhead[L]{\leftmark}% Chapter in header Left
  \fancyhead[R]{\thepage}% Page number in header Right
}
\begin{document}
\frontmatter%
\pagestyle{frontmatter}% frontmatter page style
\tableofcontents
\chapter{Preface}
\lipsum[1-20]% Some dummy text

\mainmatter
\chapter{Introduction}%
\pagestyle{mainmatter}% mainmatter page style
\lipsum[1-20]% Some dummy text
\end{document}

You don't mention any hyperref-compatibility requirement. However, that could also be incorporated.