Apologies if this has already been asked and answered but I did do a fair amount of looking and couldn't find anything.
\documentclass{article}
\begin{document}
\tableofcontents
\section{Section One}
blah
\subsection{Subsection One}
blah blah
\section{Section Two}
blah blah blah
\end{document}
All I want is for the above MWE to come out as (in the document itself):
Section One
blah
1.1 Subsection One
blah blah
Section Two
blah blah blah
… and in the table of contents:
- Section One
1.1 Subsection One - Section Two
So basically, using:
\section*{Section One}
\subsection{Subsection One}
\section*{Section Two}
… works for what I want for the document itself (i.e. using asterisks with the sections but not with the subsections), but this does not work with the table of contents. I still want the numbers in the table of contents, and no matter what I do with \addtocontents
or \addcontentsline{toc}{section}{}
etc., nothing seems to work.
Any help would be greatly appreciated.
EDIT
To those saying this is confusing, I just want the numbering to be absent in the main document for the SECTION, NOT the subsections (and subsubsections etc.), of which there are many. This is because I want there to be a Section followed by a quote, followed by a bunch of (numbered) subsections in the main document … but I still want the TOC to have the numbering for the Sections. I am well aware that the "book" class is probably easier for this, but I want to use article for other features.
Best Answer
REVISED
ORIGINAL APPROACH
I don't recommend it, because it is very confusing.
The macro
\@seccntformat
sets the appearance of the section numbering. So here, after the\tableofcontents
, I nullify the macro, so that no formatting is done on the section numbering.