![让该部分重新叙述](https://linux22.com/image/345359/%E8%AE%A9%E8%AF%A5%E9%83%A8%E5%88%86%E9%87%8D%E6%96%B0%E5%8F%99%E8%BF%B0.png)
我希望每个部分都有一个新的计数器。
\documentclass[UTF8,10pt,a4paper]{article}
\author{wsy}
\title{test}
\begin{document}
\maketitle
\tableofcontents
\part{part $1$}
\section{part 1, section 1}
\part{part $2$}
\section{ how to make this section label become 1}
%(* now it is 1 *)
\end{document}
答案1
很chngcntr
简单:
\documentclass[10pt,a4paper]{article}
\usepackage{chngcntr}
\counterwithin*{section}{part}
\author{wsy}
\title{test}
\begin{document}
\maketitle
\tableofcontents
\part{part 1}
\section{part 1, section 1}
\part{part 2}
\section{how to make this section label become 1}
\end{document}
注意\counterwithin*
,所以的定义\thesection
没有改变。
如果您想要样式中的部分和章节使用阿拉伯数字part.section
,您可以这样做
\documentclass[10pt,a4paper]{article}
\usepackage{chngcntr}
\usepackage{xpatch}
\renewcommand{\thepart}{\arabic{part}}
\counterwithin{section}{part}
\makeatletter
\xpatchcmd{\l@section}{1.5em}{2em}{}{}
\xpatchcmd{\l@subsection}{1.5em}{2em}{}{}
\xpatchcmd{\l@subsection}{2.3em}{2.8em}{}{}
\makeatother
\author{wsy}
\title{test}
\begin{document}
\maketitle
\tableofcontents
\part{part 1}
\section{part 1, section 1}
\subsection{what's this}
\part{part 2}
\section{how to make this section label become 1}
\end{document}
如果目录中还有子部分,也需要进行类似的修改。