2

I am trying to create a latex class that allows sectioning below subparagraph. For doing that, I modified the article.cls class of the texlive distribution adding two more options \thesubsubsubsection and \thesubsubsubsubsection. So now, the sectioning tree goes as follows:

\thesection  
\thesubsection  
\thesubsubsection  
\thesubsubsubsection  
\thesubsubsubsubsection
\theparagraph  
\thesubparagraph

Please see below myarticle.cls, mysectioning.tex and the resulting mysectioning.pdf.

I achieved the wanted effects in terms of numbering, table of contents and section formatting. The only problem that I have is that in the new two headings, \thesubsubsubsection and \thesubsubsubsubsection, the heading title is repeated in the following paragraph as indented text (see Sections 1.1.1.1 and 1.1.1.1.1 below).

Do you know how can I avoid this behavior?

Many thanks in advance for your help and ideas!
Sebastian

myarticle.cls

mysectioning.tex

mysectioning.pdf

myarticle PDF document

3

The duplicate of the title stem from a call to do something with the sectional mark. That is, each numbered sectional unit \<section> has an associated \<section>mark that is used for printing content to the header/footer. The LaTeX kernel defines these, not the class, as

\let\sectionmark\@gobble
\let\subsectionmark\@gobble
\let\subsubsectionmark\@gobble
\let\paragraphmark\@gobble
\let\subparagraphmark\@gobble

This way they all do nothing (they \@gobble their argument) but they're defined. As such, you need to add

\let\subsubsubsectionmark\@gobble
\let\subsubsubsubsectionmark\@gobble

within the class file somewhere so they are at least defined.

You may wonder why there is no error reported since there is a call made to the undefined marks...? That's because they're called via a control sequence construction using

\csname <section>mark\endcsname

Here's an extraction of \@sect - called by \@startsection when you execute a generic sectional unit that should be numbered:

\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M #8\@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}% <=================== Call the sectional unit mark
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\csname the#1\endcsname}%
      \fi
      #7}%
  \else
    \def\@svsechd{%
      #6{\hskip #3\relax
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c@secnumdepth \else
          \protect\numberline{\csname the#1\endcsname}%
        \fi
        #7}}%
  \fi
  \@xsect{#5}}

The highlighted macro shows the call to the mark. This type of call doesn't report errors if the control sequence is not known.

| improve this answer | |
  • Thank you very much for the solution and the detailed explanation of the reasons! I just copied the two \@gobble lines into myarticle.cls and I got the desired effects mysectioning.pdf. Very easy/elegant solution after digging into the Latex Kernel. And great didactic exposition! Thanks a lot Werner! – chan gimeno Sep 16 '16 at 8:40
  • While I might agree that the duplicate I pointed to can be debatable, this is certainly a duplicate of tex.stackexchange.com/questions/241351/… – egreg Sep 17 '16 at 9:32
  • @egreg: Indeed. The first one wasn't, but the new one is. – Werner Sep 17 '16 at 13:22