# fancyhdr - how to disable auto section number and still show section name in header

\documentclass[fleqn,12pt,a4paper]{article}
%\RequirePackage{Kaumudi_Package}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\section{section-1}
\newpage
\section{section-2}
\end{document}


In the above MWE, section name is placed in the page header which is great. However it also places a number in front of each section. I want to disable the number in front of the section. I managed to do that with \section*{} but that takes it off of the header as well. How can I disable the number in front of section and also show the name of the section in the header

-

You need to redefine \sectionmark (refer to the package documentation for details); for example, you could use the following:

\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand\sectionmark[1]{\markboth{\MakeUppercase{#1}}{}}

\begin{document}
\section{section-1}
\newpage
\section{section-2}
\end{document}


After processing the above exampe code you'll get the warning

Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 14.49998pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.


which indicates that the defined header is too big; you can then add to the preamble something like

 \renewcommand\headheight{14.5pt}


To remove the section numbering for the body of the document, you could use \titleformat from the titlesec package:

\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{titlesec}
\usepackage{fancyhdr}

\titleformat{\section}
{\normalfont\Large\bfseries}{}{0em}{}

\pagestyle{fancy}
\renewcommand\sectionmark[1]{\markboth{\MakeUppercase{#1}}{}}

\begin{document}
\section{section-1}
\newpage
\section{section-2}
\end{document}


Is is to be noticed that the above code only suppresses the section numbering in the actual titles, but the numbering will still appear in the ToC and in the lower level sectional units; if the section numbering must be removed from the ToC and from the lower level sectional units, the following lines need to be added to the preamble:

\renewcommand\thesection{}
\renewcommand\thesubsection{\arabic{subsection}}

-
there is still a number in front of the section in the document, I wanted to remove that as well. but if I do that then it removes from the header as well. I want the auto of section out in both places, in the document and also in the header. Sorry if my question did not make it clear. – Raama May 10 '12 at 16:41
@Raama please see my updated answer. – Gonzalo Medina May 10 '12 at 17:01
awesome, you guys are great – Raama May 10 '12 at 17:03
@Raama Please accept Gonzalo Medina's answer if it solved your problem. – JohnReed May 10 '12 at 19:17
\renewcommand\headheight{14.5pt} results with "! You can't use the character 1' after \the."; \setlength\headheight{14.5pt} seems to work for me. Cheers! – sdaau Jun 11 '12 at 15:59

I would suggest to switch to a newer and more powerfull class like scrartcl which already has suitable commands:

\documentclass[fleqn,12pt,a4paper]{scrartcl}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
`