1

This question already has an answer here:

My structure begin on section (this is a monograph with documentclass article), so I don't use \chapter.

I have one section with I need expand to 'level 6' (as a precaution, expand to 'level 10').

Example:

1.

1.1.

1.1.1.

1.1.1.1.

1.1.1.1.1.

...

1.1.1.1.1.1.1.1.1.1.

How can I do that without change too much the structure?

P.S: I try this (great) suggestion (More section headings?), but he needed chapter to begin.

marked as duplicate by egreg sectioning Mar 4 '15 at 18:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Welcome to TeX.SX! Some unsolicited advice: consider restructuring your document instead of adding this many extra sectional units. Numbering this deep will be confusing for readers and rarely adds value. – Paul Gessler Mar 4 '15 at 15:57
  • 1
    The linked post uses level 0 for chapter. Just don't use level 0. – Werner Mar 4 '15 at 15:57
  • That's too many sections! With the standard article class you get six: part, section, subsection, subsubsection, paragraph, and subparagraph – Thruston Mar 4 '15 at 15:58
  • What makes you think that the code in the linked answer needs chapters? – egreg Mar 4 '15 at 18:47
  • I tried my code (in the second part of the answer), changing report into article and removing the \level{0} line. It worked well, even for the table of contents. As such, I'll vote for closing as duplicate – egreg Mar 4 '15 at 18:54
3

egreg's code does not need \chapter here using article instead of report just don't use level 0:

\documentclass[a4paper]{article}

\makeatletter
\newcommand\level[1]{%
  \ifcase#1\relax\expandafter\chapter\or
    \expandafter\section\or
    \expandafter\subsection\or
    \expandafter\subsubsection\else
    \def\next{\@level{#1}}\expandafter\next
  \fi}
\newcommand{\@level}[1]{%
  \@startsection{level#1}
    {#1}
    {\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\bfseries}}

\newcounter{level4}[subsubsection]
\@namedef{thelevel4}{\thesubsubsection.\arabic{level4}}
\@namedef{level4mark}#1{}
\count@=4
\loop\ifnum\count@<100
  \begingroup\edef\x{\endgroup
    \noexpand\newcounter{level\number\numexpr\count@+1\relax}[level\number\count@]
    \noexpand\@namedef{thelevel\number\numexpr\count@+1\relax}{%
      \noexpand\@nameuse{thelevel\number\count@}.\noexpand\arabic{level\number\numexpr\count@+1\relax}}
    \noexpand\@namedef{level\number\numexpr\count@+1\relax mark}####1{}}
  \x
  \advance\count@\@ne
\repeat
\makeatother
\setcounter{secnumdepth}{100}

\begin{document}

%\level{0}{abc}
\level{1}{abc}
\level{2}{abc}
\level{3}{abc}
\level{4}{abc}
\level{5}{abc}
\level{6}{abc}
\level{7}{abc}
\level{8}{abc}
\level{9}{abc}
\level{10}{abc}
\level{11}{abc}
\level{12}{abc}
\end{document}
  • This generates a faulty \tableofcontents – Uwe Ziegenhagen Mar 4 '15 at 16:32
  • @UweZiegenhagen The code used by David is the first I gave in my answer; the extended code in the second part works also for the TOC. – egreg Mar 4 '15 at 18:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.