To clear all predefined fields in the header and footer, use \fancyhf{}
before assigning your headers and footers. Also, it's preferable to use the modern syntax \fancyhead
, \fancyfoot
:
\documentclass{article}
\usepackage[a5paper]{geometry}% just for the example
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate text for the example
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{Student ID: 1123123/1}
\fancyhead[C]{University}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
\begin{document}
\section{Test Section}
\lipsum[1-40]
\end{document}
After a MWE was provided, it was clear that the problem was the use of the fullpage
package without the headings
option; since headers/footers were used and the option was not passed, the header and the text area overlapped. The solution is then to load fullpage
in the following manner
\usepackage[header]{fullpage}
By the way, since the geometry
package is also used, I think there's some redundancy; you can use only one of those packages, depending on the desired page layout.
I also made some other changes to the document provided as MWE; particularly, I used the sectsty
package to use small caps for the section titles (this was being made manually), and suppressed the incorrect use of several consecutive \\
commands (producing underfull bad boxes).
I would also suggest not (ab)using the \title
and \author
commands to design a full titlepage (this could have undesired effects in bookmarks, for example), but to design a customized titlepage.
The code showing the changes mentioned:
\documentclass{report}
\usepackage[a4paper]{geometry}
\usepackage[myheadings]{fullpage}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{graphicx, wrapfig, subcaption, setspace}
\usepackage[T1]{fontenc}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage{fourier}
\usepackage[protrusion=true, expansion=true]{microtype}
\usepackage[english]{babel}
\usepackage{sectsty}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\onehalfspacing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HEADER & FOOTER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{12pt}
\fancyhead[L]{Student ID: 1123123/1}
\fancyhead[C]{University}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TITLE PAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\normalsize \textsc{SUBTITLE}
\\[2.0cm]
\HRule{0.5pt} \\
\LARGE \textbf{\MakeUppercase{TITLE}}
\HRule{2pt} \\[0.5cm]
\normalsize\today\vspace*{10\baselineskip}
}
\date{}
\author{
SID: \\
University \\
Department of Life Sciences}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Section title formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\sectionfont{\scshape}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BODY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\maketitle
\newpage
\section*{Section}
\end{document}
You can do this more simply by defining a personal command. This is the simplest way:
\newcommand{\problem}{%
\refstepcounter{section}%
\section*{Problem \thesection}}
Here's a skeleton document:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\problem}{%
\refstepcounter{section}%
\section*{Problem \thesection}}
\numberwithin{equation}{section}
\begin{document}
\problem\label{easy}
Compute the following expression:
\begin{equation}\label{compute}
1+1
\end{equation}
\problem\label{difficult}
Using the result obtained from~\eqref{compute} in Problem~\ref{easy},
express
\begin{equation}
\int_{0}^{x} e^{-t^2}\,dt
\end{equation}
in terms of elementary functions.
\end{document}
There are many possible refinements. For example, you seem to want to have sequences of problems. Here's an attempt at it:
\documentclass{article}
\usepackage{amsmath,xparse}
\NewDocumentCommand{\problem}{ s }
{%
\IfBooleanTF{#1}
{\refstepcounter{subproblem}%
\section*{Problem \thesubproblem}}%
{\refstepcounter{section}%
\section*{Problem \thesection}}%
}
\newcounter{subproblem}[section]
\renewcommand{\thesubproblem}{\thesection\alph{subproblem}}
\numberwithin{equation}{section}
\begin{document}
\problem\label{easy}
Compute the following expression:
\begin{equation}\label{compute-easy}
1+1
\end{equation}
\problem*\label{less-easy}
Compute the following expression:
\begin{equation}\label{compute-less-easy}
1-1
\end{equation}
\problem\label{difficult}
Using the result obtained in~\eqref{compute-easy} and
Problem~\ref{less-easy}, express
\begin{equation}
\int_{0}^{x} e^{-t^2}\,dt
\end{equation}
in terms of elementary functions.
\end{document}
A “main problem” is started with \problem
, while a “subproblem” is started with \problem*
. The equation number will still be the one established by the main problem.
Avoiding the explicit number in the command allows for easily change the order of the problem, by just shuffling around their texts.
Best Answer
I have this idea to achieve that. But it end up with shifting the star version section heading down as well (As I labeled in figure with red rectangle). You can always add local
titleformat
to avoid it (e.g. add anothertitleformat
define before\tableofcontents
). But this seems to be a little complicated. Maybe somebody have better solution.