# How to set style of header and footer with horizontal lines in report document type?

How can I set the header and footer for pages as in the picture below:

1. On the top - title of the document and horizontal line below it.
2. On the bottom - author's name and title of subsection on the left side and page numbering on the right, with horizontal line above.

-

Here's an example using the scrpage2 package from the KOMA-Script bundle.

\documentclass{report}

\automark{section}
\ofoot[\pagemark]{\pagemark}% Optional argument controls chapter-starting pages

\renewcommand*{\footfont}{\normalfont\slshape}

\usepackage{blindtext}

\begin{document}

\blinddocument

\end{document}


EDIT: Used the \automark command in order to display section headings.

-
I needed to add \usepackage[english]{babel} before this would compile... – Seamus Nov 29 '10 at 13:46
@Seamus: No, you only need to delete all auxiliary files before compiling. – lockstep Nov 29 '10 at 14:50
you forgot about plainheadsepline but it works fine. – pixel Nov 29 '10 at 21:11

If you can use the memoir documentclass, then setting \makeheadrule and makefootrule appropriately should do it.

\documentclass[openany,oneside]{memoir}
\usepackage{lipsum} % This package generates blind text. It's not part of the example per se...

\title{This is the title}
\author{A. Author}

\makefootrule{plain}{\textwidth}{\normalrulethickness}{0ex}
\makeoddfoot{plain}{\theauthor}{}{\thepage}

\pagestyle{plain}
\begin{document}
\maketitle
\chapter{The First Chapter}
\section{First section}
\lipsum
\section{Section another}
\lipsum
\end{document}


If you'd rather the rules didn't appear on the title page and on the first page of the chapter, replace plain by something else throughout.

-
\makefootrule doesn't seem to work. Also, memoir has a \normalrulethickness macro which pretty much does the first line there... – Seamus Nov 28 '10 at 20:42
\makefootrule takes a fourth argument: skip, which should be a vertical distance – Seamus Nov 28 '10 at 20:45
I have a working memoir version that almost works, I can edit it into your answer if you'd like? \sectiontitle doesn't work, though... – Seamus Nov 28 '10 at 21:11
@Seamus: Sure. I'll CW this. – Charles Stewart Nov 29 '10 at 7:10
I've added a MWE. The only thing that doesn't work is the section title in the footer... – Seamus Nov 29 '10 at 13:43

Your best bet is probably the titlesec package. Here's a MWE for the article class that almost works... (The titling package defines \theauthor and \thetitle commands that should print the contents of \author{} and \title{} respectively. But \thetitle seems to have broken...

\documentclass{report}
\newcommand{\mytitle}{This is the title}
\title{\mytitle}
\author{A. Author}
\usepackage{titling}
\usepackage{titlesec}
\renewpagestyle{plain}{
\setfoot{\theauthor --- \sectiontitle}{}{\thepage}
\footrule
}
\pagestyle{plain}

\begin{document}
\section{First section}
\newpage

\section{Section another}

\end{document}


Of course, since the title of the document doesn't change you can just set it yourself. Or use a trick like defining \newcommand{\mytitle}{This is the Title} and then putting \title{\mytitle} and then putting \mytitle in the relevant place in this example.

This all works fine with report class, and since the OP asked for report class, that's what I went with. But I'd actually recommend the KOMA or memoir solutions, since they're better in general...

As it stands at the moment, this solution does everything automatically except the document title (which can be done with the \mytitle trick. There's a memoir solution that works with everything except the subsection title. Lockstep's KOMA solution can automatically do title and author if you add the titling package...

-
OK, titlesec seems to be breaking titling. Or rather, it's breaking \thetitle – Seamus Nov 28 '10 at 20:20
@Seamus: I modified my example so that section headings will be displayed. – lockstep Nov 28 '10 at 22:12
@Seamus: Your minimal example uses the article class. With report, you also have to redefine the plain pagestyle - that's why I prefer the scrpage2 package, which handles this in an elegant way. – lockstep Nov 28 '10 at 22:27
@lockstep Or you can just renew the plain page style. I personally prefer not having a header above the chapter heading. I guess if you wanted the footer, but not the header it would involve some shenanigans... – Seamus Nov 29 '10 at 13:36
@Seamus: My minimal example does exactly that - footer, but no header. – lockstep Nov 29 '10 at 14:49