section counter is reset by unnumbered section
KOMA-Script is a bundle of versatile LaTeX classes and packages
Brought to you by:
kohm
Using \section* or \subsection* as well as \addsec or \addsec* resets the counter at the corresponding level.
\documentclass[headings=small]{scrartcl}
\begin{document}
\section{expected 1}
\subsection{expected 1.1}
\subsection{expected 1.2}
\section*{section*}
\subsection{expected 1.3}
\subsection{expected 1.4}
\section{expected 2}
\subsection{expected 2.1}
\subsection{expected 2.2}
\subsubsection{expected 2.2.1}
\subsubsection{expected 2.2.2}
\section*{section*}
\subsubsection{expected 2.2.3}
\section{expected 3}
\subsection{expected 3.1}
\subsection{expected 3.2}
\subsubsection{expected 3.2.1}
\subsubsection{expected 3.2.2}
\subsection*{subsection*}
\subsubsection{expected 3.2.3}
\section{expected 4}
\subsection{expected 4.1}
\subsection{expected 4.2}
\subsubsection{expected 4.2.1}
\subsubsection{expected 4.2.2}
\addsec{addsec}
\subsubsection{expected 4.2.3}
\end{document}
This works as intended. The reset is explicitly done, because not numbered sections have the same level and are part of the same hierarchy as numbered and therefore it is not strait but consequent to reset the number.
BTW: The feature has been added because of a user request / bug report in 2020. And you always can define your own section command of the same level and with the same settings but without resetting any counter using
\DeclareNewSectionCommand:Currently for old documents you can also use
version=3.30to switch of this feature (and several other changes):BTW: In my opinion mixing numbered and not numbered section of the same level with numbered sections of a lower level (but same hierarchy) as shown in the example here is nonsense.
Last edit: Markus Kohm 2022-09-16
You are absolutely right, mixed numbering is non-sense. I stumbled across this issue during the work on a tutorial about
glossarieswhere I just wanted to show the result of an given code snippet using\printacronyms,\printsymbols,\printglossaryetc. This output should not interfere with the outline of the actual document but as the heading configuration for those commands is rather strict (onlysection,subsectionetc. are permitted) using a custom sectioning command is not possible. Seems, like I have to deal with the counters manually. The document in question looks more or less like this:As
\printacronymsuses\section*by default for the heading, the outline of the actual document gets messed up. But I can deal with it. Probably, I will go withLast edit: tudscr 2022-09-16