How do I keep my section numbering in Latex but just hide it?
I need something like this:
Chapter 1
Preliminaries
1.1 Banach Algebras
I tried this:
\chapter{}
\section*{Preliminaries}
\subsection{Banach Algebras}
The problem is: As soon as I hid开发者_开发问答e the section number using \section*{Preliminaries}
, it changes the numbering of the subsection to 0.1 Banach Algebras
.
How do I hide the number of the section but keep the number ordering in my subsection?
A quick fix without the hassles of renewing the section command is to use addtocounter.
Everytime you use the \section*{} command, right after that you can say \addtocounter{section}{1}
\chapter{}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
This will give you a result of,
Chapter 1
Preliminaries
1.1.1 Banach Algebras
Preliminaries
1.2.2 Banach Algebras
Essentially, it is just adding 1 to your section counter whenever you create a section so when the subsection checks the section counter, it has the updated counter.
And the advantage is that if you add another section now which needs to be numbered like,
\chapter{}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
\section{Preliminaries}
You will get the correct section number (i.e. 1.3)
Chapter 1
Preliminaries
1.1.1 Banach Algebras
Preliminaries
1.2.2 Banach Algebras
1.3 Preliminaries
The main drawback is that you will have to remember to add to the counter everytime you created a \section*{}
You can add \setcounter{subsection}{0} everytime you create one of those sections to reset the subsection counter... sorry I missed that one. Thanks for clarifying.
So you just don't want to see the number displayed? Just use \renewcommand to renew the \section command, as thus:
\renewcommand{\thesection}{}
If you're using KOMA-script document classes (e.g., scrartcl), include in your preamble
\renewcommand*{\sectionformat}{}
The same goes for \subsectionformat, \subsubsectionformat, \paragraphformat, and \subparagraphformat, to whatever depth you've set with \setcounter{secnumdepth}{}. Though you've hidden the counter label, the counter counts the section anyway and includes it in TOC and bookmarks. (Tested with hyperref and bookmark packages loaded.)
This same question is asked here, and its accepted answer by @zwol works just like I wanted.
I think your best bet is to redefine
\thesection
, which is the macro that normally prints the section number.\renewcommand\thesection{}
If you want subsection numbers to include the section numbers that aren't getting printed, you will also need to redefine
\thesubsection
, which normally calls\thesection
:\makeatletter \renewcommand\thesection{} \renewcommand\thesubsection{\@arabic\c@section.\@arabic\c@subsection} \makeatother
精彩评论