[Tex/LaTex] hide section numbering but continue adding-up

numberingsectioning

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?

Best Answer

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)