# hide section numbering but continue adding-up

When I hide a section with the asterisk it doesn't show the number in the heading and the section doesn't show up in the TOC.

How to hide a section but have the counter beeing added-up correctly so that \thesection gives the correct number of the section?

-
Do you use a documentclass which is provided by KOMA? Then you can use addchap or addsec –  Marco Daniel Sep 30 '11 at 11:23
\setcounter{section}{12} allows me to set the counter manually. But I'm looking for a more comfy way to only hide the number or even better allow me to place the number in the heading manually or leave it completly out. –  Sebastian Sep 30 '11 at 11:28
@Marco: I guess he likes to have the counter incremented even though the number isn’t displayed … and that’s not what \addchap does. –  Tobi Sep 30 '11 at 11:29

I don’ think there’s a finished macro/package for that but you can increment the counter either with \stepcounter{section} or with \refstepcounter{section} which increments the counter and updates the belonging \ref-lables.

So If you need a command for this try

\newcommand{\unnumsec}[1]{\refstepcounter{section}\section*{#1}}


or if you’re using KOMA-Script

\newcommand{\unnumsec}[1]{\refstepcounter{section}\addsec{#1}}


The main difference between \section* and \addsec is that the latter also sets the headmarks and generates a ToC entry, where \section* only prints text formatted like the section headline. (See the scrguien.pdf [or the german scrguide] for more information about \addsec command)

-

Option 1 (use \section*, then \addtocounter to increment section counter):

\documentclass{article}

\begin{document}
\tableofcontents
\section{uno}
\section{dos}
\section*{hide}
\section{tres}
\end{document}


Option 2 (suppress \addcontentsline temporarily):

\documentclass{article}

\newcommand{\nocontentsline}[3]{}

\begin{document}
\tableofcontents
\section{uno}
\section{dos}
\tocless\section{hide}
\section{tres}
\end{document}

-
I would need \numberless then.. –  Sebastian Sep 30 '11 at 11:35
\renewcommand{\thesection}{}

The section counter gets incremented, but no number is displayed. (You still get the number in the TOC, though; not sure if you want that.)
No I want to place the section number individually in the section heading \section{This is \thesection . approach}. Not sure how this works. –  Sebastian Oct 3 '11 at 13:06