编号小节

编号小节

我在使用 格式化子小节标题时遇到问题titlesec。从我的代码来看,我本以为子小节标题的编号是 I.1.1,但我在生成的文件中没有看到任何数字:

结果

我注意到,通过\documentclass{article},问题没有发生

你知道问题可能出在哪里吗?

我的代码:

\RequirePackage{fix-cm}
\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage[french]{babel}
\usepackage[left=1.5cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{array}
\usepackage{enumitem}  %pour l'option [resume] qui permet de reprendre la numérotation
\usepackage{pifont}
%\usepackage{tabularx}
%\usepackage{tabulary}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,booktabs,counter,diagbox,siunitx,varwidth}
\usepackage[export]{adjustbox}
%\usepackage{verbatim}
\usepackage{multicol}
\usepackage{appendix}
\usepackage{libertine}
\usepackage{graphicx}
%\usepackage{picinpar}

\usepackage[european, RPvoltages, straightvoltages]{circuitikz}
\usepackage{siunitx}
\usepackage{hyperref}
\usepackage[normalem]{ulem}
\usepackage{titlesec}
\usepackage{caption}



\hypersetup{colorlinks=true, linkcolor=black}
\usetikzlibrary{babel}
\usepackage{lmodern}
\newenvironment{manip}{\begin{itemize}[label=\ding{45}]}{\end{itemize}}
\usepackage{booktabs}
\usepackage{tikzsymbols}
\usepackage{moresize}

\usepackage[Rejne]{fncychap}

\usepackage{pgf-spectra}

\newcolumntype{Y}{>{\centering\arraybackslash}X} 
\titleformat{\section}[hang]{\LARGE \bfseries}{\Roman{section}.}{1em}{}
\titlespacing*{\section}{0pt}{*6}{*0.5}
\titleformat{\subsection}[hang]{\Large \bfseries}{\Roman{section}.\arabic{subsection}}{1em}{}
\titlespacing*{\subsection}{0pt}{*5}{*0.5}
\titleformat{\subsubsection}[hang]{\large \bfseries}{\Roman{section}.\arabic{subsection}.\alph{subsubsection}}{1em}{}
\titlespacing*{\subsubsection}{0pt}{*5}{*0.5}
\titleformat{\paragraph}[hang]{\large \bfseries}{\theparagraph}{0em}{}
\titlespacing*{\paragraph}{0pt}{*3}{*0.5}
\titleformat{\subparagraph}[hang]{\normalsize \bfseries}{\theparagraph}{0em}{}
\titlespacing*{\subparagraph}{0pt}{*3}{*0.5}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\begin{document}
        \mainmatter
        \chapter{Chapter1}
        \section{Section1}
\subsection{Subsection1}
\subsubsection{Subsubsection1}
\end{document}

答案1

如果您希望 -level 标题的数量\subsection(可能\section还包括 -level 标题的数量)包含章节编号,则需要更改

\titleformat{\section}[hang]{\LARGE \bfseries}{\Roman{section}.}{1em}{}
\titleformat{\subsection}[hang]{\Large \bfseries}{\Roman{section}.\arabic{subsection}}{1em}{}

\titleformat{\section}[hang]{\LARGE\bfseries}{\arabic{chapter}.\Roman{section}.}{1em}{}
\titleformat{\subsection}[hang]{\Large\bfseries}{\arabic{chapter}.\Roman{section}.\arabic{subsection}}{1em}{}

如果你希望子节级别的标题被编号,你还需要运行

\setcounter{secnumdepth}{3}

secnumdepth因为计数器的默认值2在文档类中book

相关内容