当我设置子小节以便文本从标题开始运行时,子小节编号不会出现。添加命令以编号到深度 3 也无济于事。除了手动添加每个标签外,我还能做什么吗?
\documentclass{article}
\usepackage{titlesec}
%Styles for sections and (sub-)subsections
\titleformat*{\subsection}{\normalsize\itshape}
\titleformat{\subsubsection}[runin]{\normalsize\itshape}{}{0em}{}
\titleformat*{\paragraph}{\normalsize\itshape}
\titlespacing*{\section}{0pt}{18pt}{6pt plus 1pt minus 1pt}
\titlespacing*{\subsection}{0pt}{12pt}{0pt plus 1pt minus 1pt}
%Add dot after section numbers but not (sub-)subsection numbers
\usepackage{subfigure}
\usepackage[subfigure]{tocloft}
\titleformat{\section}
{\normalfont\bfseries}{\thesection.}{0.5em}{}
\renewcommand\cftsecaftersnum{.}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\setcounter{secnumdepth}{3}
\begin{document}
\section{Section}
This is the start of a section.
\subsection{Subsection}
This is the start of a subsection.
\subsubsection{Subsubsection}\label{3.1.1}
This is a subsubsection, but the number's missing.
\subsubsection{1.1.2\quad Another subsubsection}\label{3.1.2}
This is a subsubsection manually numbered to look roughly as it should. Why is the label for \S\ref{3.1.1} not showing?
\paragraph{Paragraph}
For completeness.
\end{document}
答案1
您的 似乎缺少一个参数\titleformat{\subsubsection}[runin]{\normalsize\itshape}{\thesubsubsection}{0.5em}{}
。与 不同,\titleformat*{}
必须手动将编号参数传递给它。
\documentclass{article}
\usepackage{titlesec}
%Styles for sections and (sub-)subsections
\titleformat*{\subsection}{\normalsize\itshape}
\titleformat{\subsubsection}[runin]{\normalsize\itshape}{\thesubsubsection}{0.5em}{}
\titleformat*{\paragraph}{\normalsize\itshape}
\titlespacing*{\section}{0pt}{18pt}{6pt plus 1pt minus 1pt}
\titlespacing*{\subsection}{0pt}{12pt}{0pt plus 1pt minus 1pt}
%Add dot after section numbers but not (sub-)subsection numbers
\usepackage{subfigure}
\usepackage[subfigure]{tocloft}
\titleformat{\section}
{\normalfont\bfseries}{\thesection.}{0.5em}{}
\renewcommand\cftsecaftersnum{.}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\setcounter{secnumdepth}{3}
\begin{document}
\section{Section}
This is the start of a section.
\subsection{Subsection}
This is the start of a subsection.
\subsubsection{Subsubsection}
This is a subsubsection, but the number's missing.
\subsubsection{Another subsubsection}
This is a subsubsection manually numbered to look roughly as it should. Why is the label for not showing?
\paragraph{Paragraph}
For completeness.
\end{document}