[Tex/LaTex] referencing Subsubsection is not working as intended

numberingsectioningsections-paragraphs

I am having an issue with referencing a sub-subsection.

Problem:

The problem is that SubSubSection (2) is numbered as 1.1.1. LaTeX seems to treat each sub-subsection as independent.

The latex code below generates the following (tested on ShareLaTex online.)

Result:

SubSubSection (1) 1.1.1, and SubSubSection (2) 1.1.1

Code:

\documentclass[12pt]{report}
\usepackage{graphicx}

\title{Example}
\author{}
\date{}

\begin{document}

\maketitle
\chapter{Chapter}
\section{Section}
\subsection{SubSection} 
SubSubSection (1) \ref{sub1}, and SubSubSection (2) \ref{sub2}. 
\subsubsection{Sub sub 1} 
\label{sub1}

\subsubsection{Sub sub 2} 
\label{sub2}

%\mynotes {fast review needed}
\end{document}

Best Answer

You need to set the secnumdepth counter to at least 3 to get the correct sectioning numbers to be generated:

\documentclass[12pt]{report} 
\setcounter{secnumdepth}{3}
\begin{document}
\chapter{Chapter}
\section{Section}
\subsection{SubSection}

SubSubSection (1) \ref{sub1}, and SubSubSection (2) \ref{sub2}. 
\subsubsection{Sub sub 1} \label{sub1}
\subsubsection{Sub sub 2} \label{sub2}
\end{document}

See the following question for more explanation on how this works: