Menu

#35 section counter is reset by unnumbered section

Never ever
closed
feature (1)
2022-09-16
2022-09-16
tudscr
No

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}

Discussion

  • Markus Kohm

    Markus Kohm - 2022-09-16
    • labels: --> feature
    • status: open --> closed
    • assigned_to: Markus Kohm
    • Milestone: KOMA-Script 3.38 --> Never ever
     
  • Markus Kohm

    Markus Kohm - 2022-09-16

    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:

    \documentclass[headings=small,headings=optiontoheadandtoc]{scrartcl}
    \DeclareNewSectionCommand[%
      style=section,%
      level=1,%
      indent=0pt,%
      beforeskip=-3.5ex plus -1ex minus -.2ex,%
      afterskip=2.3ex plus.2ex,%
      tocstyle=section,%
      tocindent=0pt,%
      tocnumwidth=1.5em%
    ]{xsection}
    \begin{document}
    \section{expected  1}
      \subsection{expected  1.1}
      \subsection{expected  1.2}
                                 \xsection*{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}
                                  \xsection*{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}
                                  \xsection[nonumber=true]{addsec}
        \subsubsection{expected  4.2.3}
    \end{document}
    

    Currently for old documents you can also use version=3.30 to switch of this feature (and several other changes):

    \documentclass[headings=small,version=3.30]{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}
    

    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
  • tudscr

    tudscr - 2022-09-16

    You are absolutely right, mixed numbering is non-sense. I stumbled across this issue during the work on a tutorial about glossaries where I just wanted to show the result of an given code snippet using \printacronyms, \printsymbols, \printglossary etc. This output should not interfere with the outline of the actual document but as the heading configuration for those commands is rather strict (only section, subsection etc. 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:

    \subsection{Verzeichnisse}
    \subsubsection{Abkürzungsverzeichnis}
    \begin{VerbatimExample}
    \printacronyms
    \end{VerbatimExample}
            <output of \printacronyms>
    \subsubsection{Symbolverzeichnis}
    

    As \printacronyms uses \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 with

    \begingroup
    \makeatletter
    \let\@stpelt\@gobble
    \printacronyms
    \endgroup
    
     

    Last edit: tudscr 2022-09-16

Log in to post a comment.

MongoDB Logo MongoDB