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}
In case of numbering sections independent from chapters, the question will be raised how to number definitions/propositions/examples that are placed in a chapter but are not be placed in a section?
E.g.:
Chapter 0 Basics
1 Elements
2 Combinations
Def. 2.1: Some definition
Def. 2.2: Some definition
Pro. 2.3 Some proposition
Exm. 2.4: Some Example
2.1 Permutations
2.2 Sets
Def. 2.2.1: Some definition
Def. 2.2.2: Some definition
Pro. 2.2.3 Some proposition
Exm. 2.2.4: Some Example
Chapter 1 Groups
Def. <???>1: Some definition
Pro. <???>2 Some proposition
Exm. <???>3: Some Example
3 Groups
Def. 3.1: Some definition
Pro. 3.2 Some proposition
Exm. 3.3: Some Example
Chapter 2 Rings and Fields
Def. <???>1: Some definition
Pro. <???>2 Some proposition
Exm. <???>3: Some Example
4 Rings
5 Fields
How should definitions/propositions/examples in Chapter 1 be named?
They don't belong to section 2. And they don't belong to section 3.
How should definitions/propositions/examples in Chapter 2 be named?
They don't belong to section 3. And they don't belong to section 4.
I suggest <???>=<chapter>/<definition/proposition/example number>
in these cases:
Chapter 0 Basics
1 Elements
2 Combinations
Def. 2.1: Some definition
Def. 2.2: Some definition
Pro. 2.3 Some proposition
Exm. 2.4: Some Example
2.1 Permutations
2.2 Sets
Def. 2.2.1: Some definition
Def. 2.2.2: Some definition
Pro. 2.2.3 Some proposition
Exm. 2.2.4: Some Example
Chapter 1 Groups
Def. 1/1: Some definition
Pro. 1/2 Some proposition
Exm. 1/3: Some Example
3 Groups
Def. 3.1: Some definition
Def. 3.2: Some definition
Pro. 3.3 Some proposition
Exm. 3.4: Some Example
Chapter 2 Rings and Fields
Def. 2/1: Some definition
Pro. 2/2 Some proposition
Pro. 2/3 Some proposition
Exm. 2/4: Some Example
4 Rings
5 Fields
Another question is about the numbering of footnotes, tables, figures and equations.
I suggest numbering footnotes per chapter.
I suggest numbering tables, figures and equations per section as deeper sectioning-levels might have equally numbered definition/proposition/example-pendants.
I suggest handling the case of tables/figures/equations in a chapter but
not in a section in the same way as definition/proposition/example in a chapter but not in a section, i.e. by prepending "/" to the corresponding number.
Yet another question:
Do you want definitions/propositions/examples to occur within the table of contents as well?
Do you wish something like a separate List of definitions / List of propositions / List of examples.
I suggest not having definitions/propositions/examples occur within the table of contents.
I suggest not having a a separate List of definitions / List of propositions / List of examples.
These things require more crude hacking of the documentclass / of the book class.
\documentclass{book}
\usepackage{hyperref}
\makeatletter
\newcounter{TheoremElement}
\newcounter{sectionfake}
\begingroup
\def\tempa#1{\global\csname c@#1\endcsname\z@}%
\expandafter\endgroup\ifx\tempa\@stpelt
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{%
\def\c@sectionfakehack\z@
}{%
\def\c@sectionfakehack\m@ne\stepcounter#1%
}%
{%
\let\c@sectionfake\c@sectionfake\stepcounter{sectionfake}%
}%
\renewcommand\cl@chapter{%
\@elt{sectionfake}%
\@elt{footnote}%
\@elt{equation}\@elt{figure}\@elt{table}%
\@elt{subsection}\@elt{subsubsection}%
\@elt{paragraph}\@elt{subparagraph}%
\@elt{TheoremElement}%
}%
\renewcommand\cl@section{%
\@elt{sectionfakehack}%<-the hack increments sectionfake instead of resetting
% to zero whenever section is incremented via \stepcounter
\@elt{equation}\@elt{figure}\@elt{table}%
\@elt{subsection}\@elt{subsubsection}%
\@elt{paragraph}\@elt{subparagraph}%
\@elt{TheoremElement}%
}%
\renewcommand\cl@subsection{%
\@elt{subsubsection}%
\@elt{paragraph}\@elt{subparagraph}%
\@elt{TheoremElement}%
}%
\renewcommand\cl@subsubsection{%
\@elt{paragraph}\@elt{subparagraph}%
\@elt{TheoremElement}%
}%
\renewcommand\cl@paragraph{%
\@elt{subparagraph}%
\@elt{TheoremElement}%
}%
\renewcommand\cl@subparagraph{%
\@elt{TheoremElement}%
}%
\renewcommand*\cl@TheoremElement{}%
%
\newcommand\sectionfakefork{%
\ifnum\number\value{sectionfake}>0 %
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}%
\newcommand\AllSectionLevelsArabic{%
\sectionfakefork
{%
\AllSectionLevelsArabicLoop{\AllSectionLevelsArabicLoop{%
\AllSectionLevelsArabicLoop{\AllSectionLevelsArabicLoop{%
\@firstoftwo{\arabic{section}.}%
}{subsection}.}{subsubsection}.%
}{paragraph}.}{subparagraph}.%
\@firstoftwo
}{%
\arabic{chapter}/%
}%
\arabic{TheoremElement}%
}%
\newcommand\AllSectionLevelsArabicLoop[4]{%
#4{\ifnum\number\value{#2}>0 %
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{#1\@secondoftwo\arabic{#2}#3}{#1#4}%
}{#1\@secondoftwo\arabic{#2}#3}%
}%
\newcommand\insertbehindnumber[2]{%
#1\@insertbehimdnumber{#2}%
}%
\newcommand\@insertbehimdnumber{}%
\long\def\@insertbehimdnumber#1#2\endcsname{#2\endcsname#1}%
\renewcommand\theTheoremElement{\AllSectionLevelsArabic}
\newtheorem{definition}[TheoremElement]{\insertbehindnumber{Def.}{:}}%
\newtheorem{proposition}[TheoremElement]{\insertbehindnumber{Pro.}{:}}%
\newtheorem{example}[TheoremElement]{\insertbehindnumber{Exm.}{:}}%
\renewcommand\theequation{\sectionfakefork{\arabic{section}.}{\arabic{chapter}/}\arabic{equation}}%
\renewcommand\thetable{\sectionfakefork{\arabic{section}.}{\arabic{chapter}/}\arabic{table}}%
\renewcommand\thefigure{\sectionfakefork{\arabic{section}.}{\arabic{chapter}/}\arabic{figure}}%
\renewcommand\thesection{\protect\S\texorpdfstring{\protect\,}{ }\arabic{section}}%
\AtBeginDocument{%
% Remove the dot after chapter-numbers in headers of verso pages:
%\renewcommand*\chaptermark[1]{%
% \markboth{%
% \MakeUppercase{%
% \ifnum\c@secnumdepth>\m@ne\if@mainmatter\@chapapp\ \thechapter\quad\fi\fi#1%
% }%
% }{}%
%}%
% Remove the dot after sectioning-paragraph-numbers in headers of recto pages:
\renewcommand*\sectionmark[1]{%
\markright{%
\MakeUppercase{\ifnum\c@secnumdepth>\z@\thesection\quad\fi#1}%
}%
}%
\@ifpackageloaded{hyperref}{%
% Ensure uniqueness of hyperref' anchor names:
\renewcommand\theHsection{\arabic{section}}%
\renewcommand\theHTheoremElement{\AllSectionLevelsArabic}%
\renewcommand\theHequation{\sectionfakefork{\arabic{section}.}{\arabic{chapter}/}\arabic{equation}}%
\renewcommand\theHtable{\sectionfakefork{\arabic{section}.}{\arabic{chapter}/}\arabic{table}}%
\renewcommand\theHfigure{\sectionfakefork{\arabic{section}.}{\arabic{chapter}/}\arabic{figure}}%
\renewcommand\theHfootnote{\arabic{chapter}.\arabic{footnote}}%
}{%
\providecommand\texorpdfstring[2]{#1}%
}%
}%
\makeatother
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{\value{secnumdepth}}
\usepackage[open,openlevel=\value{secnumdepth},atend,numbered]{bookmark}
\begin{document}
\tableofcontents
\setcounter{chapter}{-1}%
\chapter{Basics}
\begin{definition}
Some definition.
\end{definition}
\section{Sets}
\begin{definition}
\label{deflabel}Some definition.
\end{definition}
\begin{definition}
Some definition.
\end{definition}
\begin{proposition}
\label{proplabel}Some proposition.
\end{proposition}
\begin{example}
\label{exlabel}Some example.
\end{example}
\section{Other section}
\section{Other section}
\begin{definition}
Some definition.
\end{definition}
\begin{definition}
Some definition.
\end{definition}
\begin{proposition}
Some proposition.
\end{proposition}
\begin{example}
Some example.
\end{example}
\section{Other section}
\chapter{Groups, Rings and Fields}
\begin{definition}
\label{otherdeflabel}Some definition.
\end{definition}
\section{Groups}
\begin{definition}
Some definition.
\end{definition}
\subsection{SubGroups}
\begin{definition}
Some definition.
\end{definition}
\subsubsection{SubSubGroups}
\begin{definition}
\label{yetanotherdeflabel}Some definition.
\end{definition}
\section{Rings}
\cleardoublepage
\section{Testing referencing}
referencing a definition: \ref{deflabel}\\
referencing a proposition: \ref{proplabel}\\
referencing an example: \ref{exlabel}\\
referencing another definition: \ref{otherdeflabel}\\
referencing yet another definition: \ref{yetanotherdeflabel}
\end{document}
Best Answer
There are classes that use
\Alph
for subsections. Examplerevtex4-1
:However, redefining the counter macro
\the<counter>
usually works as expected: