1

I'm using titlesec for customizing section titles. The problem is, that it prevents TOC from showing full (sub)subsection numbers. This applies to referring to section labels as well:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{titlesec} % Allows customization of titles
\renewcommand\thesection{\arabic{section}} % Arabic numerals for the sections
\renewcommand\thesubsection{\arabic{subsection}} % Arabic numerals for subsections
\renewcommand\thesubsubsection{\arabic{subsubsection}} % Arabic numerals for subsubsections
\titleformat{\section}[block]{\Large\scshape\centering}{\thesection}{1em}{} 
\titleformat{\subsection}[block]{\large\scshape}{\thesection.\thesubsection}{1em}{} 
\titleformat{\subsubsection}[block]{\large\scshape}{\thesection.\thesubsection.\thesubsubsection}{1em}{}

\begin{document}
\tableofcontents

\vspace{1cm}
\hrule

\section{section 1}
\subsection{subsection 1.1}
\subsection{subsection 1.2}
\label{subsection 1.2}

\section{section 2}
\subsection{subsection 2.1}
\subsection{subsection 2.2}
Referring to subsection \ref{subsection 1.2}.
\subsubsection{subsubsection 2.2.1}

\end{document}

MWE

What do I have to change/specify in order to have the full number shown in TOC/references? Thanks in advance!

1 Answer 1

2

You need to complete/fix the re-definitions of subsections:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{titlesec}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\arabic{section}.\arabic{subsection}} % %new code
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}} % new code
\titleformat{\section}[block]{\Large\scshape\centering}{\thesection}{1em}{}
\titleformat{\subsection}[block]{\large\scshape}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{\large\scshape}{\thesubsubsection}{1em}{}

\begin{document}
\tableofcontents

\vspace{1cm}
\hrule

\section{section 1}
\subsection{subsection 1.1}
\subsection{subsection 1.2}
\label{subsection 1.2}

\section{section 2}
\subsection{subsection 2.1}
\subsection{subsection 2.2}
Referring to subsection \ref{subsection 1.2}.
\subsubsection{subsubsection 2.2.1}

\end{document}

enter image description here

0

You must log in to answer this question.

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