You get three times a page 1 in the front matter: in the report
class the titlepage
environment which is used also by abstract
resets the page number to 1.
I suggest you to use the book
class with its \frontmatter
and \mainmatter
commands, with \chapter{\abstractname}
for the abstract in the front matter.
However also the report
class can be used, after patching the relevant commands; I show only the important parts, add the rest to suit. It's probably better to \usepackage[<options>]{geometry}
for setting the page parameters and \usepackage{setspace}
for the interline spacing.
Remember the \clearpage
command before \pagenumbering{arabic}
.
\documentclass[12pt]{report}
%%% PATCHES %%%
\usepackage{etoolbox}
\makeatletter
% Patch `titlepage` not to reset the page number
\patchcmd{\titlepage}{\setcounter{page}\@ne}{}{}{}
\patchcmd{\endtitlepage}{\setcounter{page}\@ne}{}{}{}
% Patch `abstract` so that it shows the page number
\patchcmd{\abstract}{\titlepage}{\titlepage\thispagestyle{plain}}{}{}
\makeatother
%%% END PATCHES %%%
\begin{document}
\pagenumbering{roman}
\begin{titlepage}
abc
\end{titlepage}
\begin{abstract}
dddd
\end{abstract}
\tableofcontents
\clearpage %%%%% <---- IMPORTANT
\pagenumbering{arabic}
\pagestyle{myheadings} \markright{}
\chapter{A}
\end{document}
Since you have to define the \headheight
at the begining of the code within geometry package irredeemably, this will stablish that same height for the header throughout the document.
To change that, you can define a \newgeometry
with the \headheight
equal to 0pt
at the begining of even pages, but you have to redefine your previous geometry in the next page again. This is a manual procedure, but I don't know another way to do that.
Here I post you some code. As you can see, I have defined two styles with \fancypagestyle
, one for even pages and another one for de odd ones. If you want to disable the numbering of the pages, just remove the \fancyfoot
and \renewcommand\footrulewidth
lines inside each style.
\documentclass[12pt,twoside]{article}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=2cm,includeheadfoot,headheight=44pt]{geometry}
\usepackage{lipsum}
\fancypagestyle{odd}{ %
\fancyhf{}
\fancyhead[OL]{COURSE}
\fancyhead[OR]{
\begin{tabular}{ c c }
NAME & NO \\
NAME1 & xxx \\
NAME2 & yyy \\
\end{tabular}
}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[C]{\thepage}
}
\fancypagestyle{even}{ %
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[C]{\thepage}
}
\begin{document}
\thispagestyle{odd}
\lipsum[1-2]
\newpage
\thispagestyle{even}
\newgeometry{margin=2cm,includefoot,headheight=0pt} %Just \includefoot
\lipsum[1-2]
\newpage
\thispagestyle{odd}
\newgeometry{margin=2cm,includeheadfoot,headheight=44pt}
\lipsum[1-2]
\end{document}
The first page is messed up because the \headheight
is by default 12pt
but should be 44pt
in this case. Is there any way to calculate this automatically? I would like to avoid typing 44pt
manually.
I don't know any way to avoid calculate this manually. Just compile your document and wait for the log message referring to the \headheight
and set that lenght as minimum.
Best Answer
This is a little hackish, but you can use the titling package to remove the space after the date, in effect reducing the abstract's top margin:
You may notice that some other vertical spacing regarding the title matter is affected somewhat by using the titling package, but the good thing about it is every aspect of this spacing is easily customizable; e.g.,
will raise all of the title matter vertically by
1em
; similar commands can be found for pretty much any part of the title material.