titlesec-package 阻止目录显示完整的子节编号

titlesec-package 阻止目录显示完整的子节编号

我用它titlesec来自定义章节标题。问题是,它阻止目录显示完整的(子)子章节编号。这也适用于引用章节标签:

\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}

平均能量损失

我必须更改/指定什么才能在目录/参考资料中显示完整数字?提前致谢!

答案1

您需要完成/修复子部分的重新定义:

\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}

在此处输入图片描述

相关内容