我希望每个部分都有一个新的计数器。
\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}
如果目录中还有子部分,也需要进行类似的修改。