1

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.

2

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}
  • thanks, worked brilliantly! however, how could I remove the 'Chapter 1:' part of the heading? and also I have realised, it looks nice to keep the page number at the bottom of the page, rather than using fancyhdr. How can I remove the page number? – Michael Oct 20 '14 at 9:28
  • Also, how could I shorten the length of the footrulewidth? I have tried using width=0.5/textwidth but I can't get it to work.. – Michael Oct 20 '14 at 9:37
  • Which solution do you want to use? It will be easier using scrlayer-scrpage and even more easy using the corresponding KOMA-class. Changing the length of the footrulewidth (width a half of the textwidth seems to be unreasonable) involves hacking the fancyhdr internals – Johannes_B Oct 20 '14 at 14:19
  • I tried to use scrlayer-scrpage but it could not define a lot of things and returned 4 errors, hence why I used fancyhdr – Michael Oct 20 '14 at 15:48
  • Telling me what the error was would be helpful ;-) Also, what do you want to define? – Johannes_B Oct 20 '14 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.