Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to remove section names in headers. I am using fancyhdr package. When I try to specify new text in \lhead{}, text is just overlayed on section name. P.S. 3 hours of googling did not help.

Here is the section of code that I want to make work.

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Student ID: 1123123/1}
\chead{University}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{Page \thepage\ of \pageref{LastPage}}

UPDATE: \fancyhf{} is not working - nothing changes.

Edit by Speravir – Example taken from http://pastebin.com/W6V9GUCs
(link given by OP in comment to Gonzalo’s answer):

\documentclass{report}
\usepackage[a4paper]{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{fullpage, graphicx, wrapfig, subcaption, setspace}
\usepackage[T1]{fontenc}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage{fourier}
\usepackage[protrusion=true, expansion=true]{microtype}
\usepackage[english]{babel}

\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\onehalfspacing

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HEADER & FOOTER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{Student ID: 1123123/1}
\fancyhead[C]{University}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TITLE PAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\title{ \normalsize \textsc{SUBTITLE}
        \\ [2.0cm]
        \HRule{0.5pt} \\
        \LARGE \textbf{\uppercase{TITLE}}
        \HRule{2pt} \\ [0.5cm]
        \normalsize \today
}

\date{}

\author{\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
        SID:  \\ 
        University \\
        Department of Life Sciences
}

\maketitle

\pagebreak


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BODY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section*{\textsc{SECTION}}

\end{document}
share|improve this question
1  
Put \fancyhf{} before \lhead{Student ID: 1123123/1}. –  Harish Kumar Apr 5 '13 at 1:46
1  
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say "thank you" to users who helped you. –  hpesoj626 Apr 5 '13 at 1:47
    
Please provide crucial information. Which document class are you using? –  Gonzalo Medina Apr 5 '13 at 2:04
add comment

1 Answer

up vote 4 down vote accepted

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}

enter image description here

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}
share|improve this answer
    
How did you produce this image with two pages on the same file? –  Sigur Apr 5 '13 at 2:10
    
@Sigur I produce all my images by opening the generated PDF document in Okular; then I zoom them (in or out according to the case), and use the "Selection" tool to select the region I want to copy here. –  Gonzalo Medina Apr 5 '13 at 2:12
1  
@Sigur Ah, take into account that in this case I used a5paper; the zooming was 118.91%. –  Gonzalo Medina Apr 5 '13 at 2:14
2  
@doc please see my updated answer; what you were seeing is was not a header; was actually the title of your section. Don't load the fullpage package; to change the page layout, use the geometry package instead. I did some other changes to your document to prevent bad boxes; in some minutes I'll add some explanations. –  Gonzalo Medina Apr 5 '13 at 2:23
1  
@doc please see my updated answer; I added some other modifications (particularly to the section title formatting) and added the headings option to fullpage in case you decide to keep using it. I also added some explanations. –  Gonzalo Medina Apr 5 '13 at 2:50
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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