# How do I insert a document's title and the chapter's name into a header?

I am attempting to place the document's title on the left side of a header and the chapter's name on the right side of the header. However, I am unable to find how to use the title variable specified in by \title{my title} in the header. Additionally, whenever I use \chaptermark the right section of the header appears blank on all pages.

How do I insert a document's title and the chapter's name into a header?

My tex file contents are pasted below:

\documentclass{report}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\begin{document}

\lfoot{\thepage\ of \pageref{LastPage}}
\rfoot{My Company}
\renewcommand{\footrulewidth}{0.4pt}

% redefine headers and footers for chapters
\fancypagestyle{plain}{%
\fancyhf{}
\lfoot{\thepage\ of \pageref{LastPage}}
\rfoot{My Company}
\renewcommand{\footrulewidth}{0.4pt}
}

\title{My Document Title}
\author{Ryan Taylor}
\date{\today}
\maketitle
\tableofcontents
\chapter{Version Control}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sapien metus, tempus sit amet feugiat id, feugiat in diam. Integer ut nunc eget orci hendrerit ullamcorper nec at enim.

\chapter{Introduction}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sapien metus, tempus sit amet feugiat id, feugiat in diam. Integer ut nunc eget orci hendrerit ullamcorper nec at enim.

-

For the title:

\let\oldtitle\title
\renewcommand{\title}[1]{\oldtitle{#1}\def\titletext{#1}}

For the chapter name, use \leftmark not \chaptermark (which is the command which is used by \chapter in order to set up the marks).
Slightly off-topic, but I think this is a design bug in LaTeX. The standard classes' \maketitle contain \global\let\@title\@empty. There's very little reason to do this. There should be nothing wrong with \lhead{\@title}. I guess that after \title{foo}, one could write \expandafter\lhead\expandafter{\@title}, but that should probably be unnecessary. – TH. Aug 25 '10 at 11:07
@TH.: I believe \@title, etc., are cleared for historical reasons due to memory limitations back when LaTeX was first written in the 80s. – Will Robertson Sep 23 '10 at 11:25