我希望我的介绍出现在目录中而不带章节编号,但因为我使用命令\chapter*
来实现这一点,所以介绍中的所有部分都编号为:
0.1 章节标题
我不想在那里使用零(即我希望简介的第一部分编号为 1)。但对于所有其他章节,我确实希望章节编号包含在节编号中(例如,我希望第 1 章的第 2 节编号为 1.2)。有没有办法让章节编号单个章节忽略章节号?谢谢!
以下是 MWE:
\documentclass[12pt, twoside]{report}
\usepackage[explicit]{titlesec} %adjust titles
\usepackage{lipsum}
\titleformat{\chapter}[display]{\LARGE\bfseries\centering}{\thechapter}{10pt}{#1}
\titleformat{\section}{\normalfont\fontsize{20}{20}\centering}{\thesection}{1em}{\MakeUppercase{#1}}
\titleformat{\subsection}{\normalfont\centering}{\thesubsection}{1em}{\textit{{#1}}}
\setcounter{tocdepth}{1} %removes subsubsections from toc
%%%%%%%%%removes dots from toc
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
%%%%%%%%%
\begin{document}
\tableofcontents
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\section{Here's a Section}
I want this section just to be numbered `1' rather than `0.1'. I would also like it to be numbered `1' instead of `0.1' in the table of contents.
\section{And Here's Another One}
This one should be numbered `2' rather than `0.2'.
\chapter{The First Chapter}
\section{Here's Another Section}
This section is numbered correctly.
\section{And Here's Another One}
And so is this one.
\end{document}
答案1
在适当的地方更改章节编号样式。
% secnumprob.tex SE 561571
\documentclass[12pt, twoside]{report}
\usepackage[explicit]{titlesec} %adjust titles
\usepackage{lipsum}
\titleformat{\chapter}[display]{\LARGE\bfseries\centering}{\thechapter}{10pt}{#1}
\titleformat{\section}{\normalfont\fontsize{20}{20}\centering}{\thesection}{1em}{\MakeUppercase{#1}}
\titleformat{\subsection}{\normalfont\centering}{\thesubsection}{1em}{\textit{{#1}}}
\setcounter{tocdepth}{1} %removes subsubsections from toc
%%%%%%%%%removes dots from toc
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
%%%%%%%%%
\begin{document}
\tableofcontents
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\renewcommand{\thesection}{\arabic{section}} % PW ADDED
\section{Here's a Section}
I want this section just to be numbered `1' rather than `0.1'. I would also like it to be numbered `1' instead of `0.1' in the table of contents.
\section{And Here's Another One}
This one should be numbered `2' rather than `0.2'.
\chapter{The First Chapter}
\renewcommand{\thesection}{\thechapter.\arabic{section}} % PW ADDED
\section{Here's Another Section}
This section is numbered correctly.
\section{And Here's Another One}
And so is this one.
\end{document}