1

I want every part have a new counter.

\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 Answers1

0

With chngcntr it's easy:

\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}

Note \counterwithin*, so the definition of \thesection is not changed.

enter image description here

If you want arabic numbers for parts and sections in the style part.section, you can do like

\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}

Similar modifications are needed if you also have subsubsections in the table of contents.

enter image description here

egreg
  • 1,121,712