[Tex/LaTex] Alternate fancy page header? left page = page number + chapter, right page = page number + section

fancyhdrheader-footerpage-numbering

I currently use fancyhdr to display the chapter name and page number on each page. However, I would like to change this so that it displays the chapter on the left page and section on the right. I know how to do this manually, but it will take a long time. Is there a quick and easy way to do this?

Also, I would like the option to be able to add and change a horizontal line at the bottom of the page. I guess 0.5 textwidth would be good but I may want to change this later. Also, I don't want the font to all be in capitals and I don't want to include 'CHAPTER N:' at the top. It would also be nice to remove the page number from the top.

So on left page: name of chapter with line underneath at textwidth, then on the right page, the section name. I would like both of these headers on the inner part of the page. Then, at the bottom I would like a horizontal line with the page number underneath in the center.

Best Answer

Using the new and modern package scrlayer-scrpage gives you all you need. Of course, you can use fancyhdr for your document as well. The length of the rules can be changed pretty easily using scrlayer-scrpage but need much more effort with fancyhdr as the default width is synchronized with the headwidth.

\documentclass[twoside,
footsepline,plainfootsepline,
headsepline]{report}
\usepackage{blindtext}
\usepackage[automark,clines,markcase=nouppercase]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot[\pagemark]{\pagemark}
\ihead{\headmark}
\KOMAoption{footsepline}{:.5\textwidth}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\usepackage{showframe}
\begin{document}
\blinddocument
\end{document}

Using fancyhdr

\documentclass[twoside,draft]{report}
\usepackage{fancyhdr}
\newlength{\footrulelength}
\setlength{\footrulelength}{.5\textwidth}

\usepackage{showframe}
\makeatletter
\def\footrule{
    \if@fancyplain\let\footrulewidth\plainfootrulewidth%
    \fi%
    \vskip-\footruleskip\vskip-\footrulewidth%
    \null\hfill%
    \rule{\footrulelength}{\footrulewidth}\hfill\null%
    \vskip\footruleskip%
}
\makeatother
\fancypagestyle{plain}{%
    \fancyhf{}
    \fancyfoot[c]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{.4pt}
}

\usepackage{blindtext}
\fancyhf{}
\fancyhead[ER]{\rmfamily\leftmark}
\fancyhead[OL]{\rmfamily\rightmark}
\fancyfoot[c]{\thepage}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{.4pt}
\renewcommand{\plainfootrulewidth}{.4pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\begin{document}
\blinddocument
\end{document}