9

I am trying to use subsection, subsubsection, subsubsubsection, paragraph and subparagraph on my article, and I using a code that was given below.

How to add an extra level of sections with headings below \subsubsection

The solution was posted below:

\subsubsubsection count not reset when starting a new section, subsection, etc

But I am still unable to get proper numbering.

I admit that I am using article class because I am new to Latex and dont know much about other classes. Also, some would argue that I dont need so many indentations but in my reports I unfortunately have 9 levels of indentation that I want to show in ToC.

Below is my MWE

\documentclass{article}
\usepackage{titlesec}
\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}[subsubsection]

\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}}
\renewcommand\thesubparagraph{\theparagraph.\arabic{subparagraph}}

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother

\makeatletter
\@addtoreset{subsubsubsection}{section}
\@addtoreset{subsubsubsection}{subsection}
\makeatother

\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{6}

\author{Author}
\title{Title}
\date{2014}

\begin{document}
\maketitle
\newpage
\tableofcontents
\newpage
\section{Section 1}
\subsection{subsection 1}
\subsubsection{subsubsection 1}
\subsubsubsection{Subsubsubsection 1}
Some description here
\paragraph{paragraph 1}
Some description here
\paragraph{Paragraph 2}
Some description here
\subsubsubsection{subsubsubsection 2}
Description here
\subsubsubsection{subsubsubsection 3}
description here
\subsubsubsection{subsubsubsection 4}
description here
\paragraph{paragraph 1} 
Some description here
\paragraph{paragraph 2}
some description here
\paragraph{Paragraph 3}
\subsubsubsection{subsubsubsection 5}
description here

\end{document}

PDF Result

As you can see from ToC, paragraph 1 under subsubsubsection 4 started from 1.1.1.4.3 (I want it to start from 1.1.1.4.1) Similarly paragraph 2 under subsubsubsection 4 should be 1.1.1.4.2 respectively.

8
  • 2
    do you really need 9 levels (you only show adding one additional level)? If you only want one additional level it would be simpler just to use report instead of article as the main difference is the extra level (\chapter) Mar 10, 2014 at 0:38
  • yes, There are 1-2 cases where indentation goes to 9 levels. But if I change it to report class, I'll have to change section to chapter and subsection to section and so forth? Will I have to do any additional changes as well?
    – MSB
    Mar 10, 2014 at 0:53
  • Ok, I tried using report class but the problem remains same. The numbering I was talking about above still increments as I documented. The counter doesn't reset.
    – MSB
    Mar 10, 2014 at 0:57
  • The additional level is essentially the only difference. If you do want to ad an additional level to article (or report) it's easier to add them to the bottom of the hierarchy ie subsubparagraph... by inserting subsubsubsection at the level where paragraph is defined you force to redefine paragraph and subparagraph which is possible of course but extra complication for no actual extra functionality Mar 10, 2014 at 0:58
  • 1
    I meant if you only want one extra level just use report class and don't do the above redefinitions/ Mar 10, 2014 at 0:59

1 Answer 1

14

The immediate problem is that you need the counter for paragraphs to be reset when you start a new subsubsubsection. To do this, all you need to do is add:

\@addtoreset{paragraph}{subsubsubsection}

Note, though, that you probably will also find you want to add some further resets depending on the structure of your document.

More generally, I have to say that the fact that you find the need to do this indicates to me that you need to rethink the structure of your document. Even if you are writing a book or thesis (for which article would not be a suitable class), 9 levels is just going to be confusing. The only exception is probably legal documentation which seems to positively require insane levels of hierarchy. I think you should really be asking what you expect your readers to gain from the structure in terms of clarity. If the answer is nothing or, worse, greater complexity and confusion, you know you need to rethink.

However, this is TeX SE and so I can provide a 'solution' with a clean conscience since the site is not in the business of ensuring people write well, but only of assisting them to write whatever they do in TeX.

\documentclass{article}
\usepackage{titlesec}
\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}[subsubsection]

\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}}
\renewcommand\thesubparagraph{\theparagraph.\arabic{subparagraph}}

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\@addtoreset{subsubsubsection}{section}
\@addtoreset{subsubsubsection}{subsection}
\@addtoreset{paragraph}{subsubsubsection}
\makeatother

\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{6}

\author{Author}
\title{Title}
\date{2014}

\begin{document}
\tableofcontents

\section{Section 1}
\subsection{subsection 1}
\subsubsection{subsubsection 1}
\subsubsubsection{Subsubsubsection 1}
Some description here
\paragraph{paragraph 1}
Some description here
\paragraph{Paragraph 2}
Some description here
\subsubsubsection{subsubsubsection 2}
Description here
\subsubsubsection{subsubsubsection 3}
description here
\subsubsubsection{subsubsubsection 4}
description here
\paragraph{paragraph 1}
Some description here
\paragraph{paragraph 2}
some description here
\paragraph{Paragraph 3}
\subsubsubsection{subsubsubsection 5}
description here

\end{document}

Excessive levels shown in TOC

4
  • 5
    +1 for "the site is not in the business of ensuring people write well". sigh. Mar 10, 2014 at 14:14
  • 2
    Hi - Thanks a lot for the solution. I totally agree with you about the structure of document and so many levels of indentation. I am trying to reduce it to just 4 levels but I have to create the document "once" to show someone how "difficult" and confusing the current structure is.
    – MSB
    Mar 12, 2014 at 15:45
  • @MSB Ah, yes. That unfortunately makes a lot of sense! Good luck...
    – cfr
    Mar 12, 2014 at 18:50
  • Should the \def\toclevel@paragraph{6}be a \def\toclevel@subparagraph{6}? Sep 10, 2019 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .