[Tex/LaTex] How to insert a document’s title and the chapter’s name into a header

chaptersheader-footersectioning

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}

\rhead{\bfseries \chaptermark}
\lfoot{\thepage\ of \pageref{LastPage}}
\rfoot{My Company}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

% redefine headers and footers for chapters
\fancypagestyle{plain}{%
 \fancyhf{}
 \rhead{\bfseries \chaptermark}
 \lfoot{\thepage\ of \pageref{LastPage}}
 \rfoot{My Company}
 \renewcommand{\headrulewidth}{0.4pt}
 \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.

Best Answer

For the title:

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

For the chapter name, use \leftmark not \chaptermark (which is the command which is used by \chapter in order to set up the marks).