1

What I essentially want to do is to remove numbering of sections everywhere(primarily, the header and in the main body) except the table of contents so that sections are numbered there but my left header only displays the name of the section, not its numbering. How do I go about this?

This is my code:

\documentclass[a4paper,english,oneside]{article}
\usepackage{fancyhdr}
\usepackage[top=1in,left=1in,right=1in,bottom=1in]{geometry}
\pagestyle{fancy}

\begin{document}
\tableofcontents
\newpage
\section{Section}
\end{document}

If there are any issues of or suggestions about the way I've posed the question, I'd appreciate it if you could mention them.

  • Well, what's the purpose of maintaining section numbers in the ToC then if they should be removed in the main body? – user31729 Mar 21 '16 at 18:04
1

You can remove the sectional enumeration display from the header and main document using the following in your preamble:

\makeatletter
\renewcommand{\@seccntformat}[1]{}
\AtBeginDocument{\renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{#1}}}}
\makeatother

The first updates the way sectional headings are formatting inside the document. Each sectional unit has its number (or counter) and the subsequent gap to the title text formatted by \@seccntformat. This holds for all the default formatting of sectional units that issue \@startsection.

The second updates \sectionmark to only set the section title and completely avoids any reference to \thesection (the section counter representation). We delay this redefinition to until \AtBeginDocument as a choice in \pagestyle may redefine it. One would have to do something similar for other sectional levels (like \subsection, ...).

enter image description here

\documentclass{article}

\makeatletter
\renewcommand{\@seccntformat}[1]{}
\AtBeginDocument{\renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{#1}}}}
\makeatother

\pagestyle{headings}

\usepackage{lipsum}% Just for this example
\sloppy% Just for this example

\begin{document}

\tableofcontents

\section{A section}
\lipsum[1-20]

\section{Another section}
\lipsum[1-20]

\section{Yet another section}
\lipsum[1-20]

\section{A final section}
\lipsum[1-20]

\end{document}

The above works under the default document setup. Other packages that may influence the sectional construction may require more tweaking.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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