[Tex/LaTex] Why is \markboth not working?

header-footer

I'm attempting to make my own headers for a book I'm writing. I want to alternate between two headings: "Left" and "Right" My problem is: I'm not getting the Left and Right printing out when I use \markboth.

The code is

\documentclass{book}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{graphics,color}
\usepackage[superscript]{cite}

\begin{document}
\pagestyle{myheadings}
\markboth{Right}{Left}

First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page

 \end{document}

This provides:
enter image description here

2nd page:
enter image description here

But I want like this (below):
enter image description here

2nd page:
enter image description here

3rd:
enter image description here

4th:
enter image description here

Best Answer

The pictures you post of the desired output include a rule under the header and reducted margins. For setting the margins the best choice is to use the geometry package. For the headers the fancyhdr package provides the required facilities. Using your syntax (which really has Right and Left the wrong way round), you can write:

Sample page 2

\documentclass[a4paper,12pt]{book}

\usepackage[vmargin=0.2cm,hmargin=1cm,head=16pt,includeheadfoot]{geometry}
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\slshape\rightmark}
\fancyhead[RE]{\slshape\leftmark}
\pagestyle{fancy}

\begin{document}

\markboth{Right}{Left}
\thispagestyle{empty}

First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page

\end{document}

\pagestyle{empty} ensures the first page (or the page that command is on) has no headers.

To use \markboth the standard way around you should use:

\documentclass[a4paper,12pt]{book}

\usepackage[vmargin=0.2cm,hmargin=1cm,head=16pt,includeheadfoot]{geometry}
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\slshape\leftmark}
\fancyhead[RE]{\slshape\rightmark}
\pagestyle{fancy}

\begin{document}

\markboth{Left}{Right}
\thispagestyle{empty}

First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page

\end{document}