[Tex/LaTex] Reset counter \section in \part*

chngcntrcountersparts

I'm a rookie with LaTeX, I'm using LyX, but I think this is a LaTeX problem.

Im using this LaTeX preamble for reset counter after parts

\usepackage{chngcntr}
\counterwithin*{section}{part}

But it only works with \part and no with \part*… I need to have no-numbered parts. What can I do? I don't find anything on the net and my attempts don't work (counterwith, part*…).

Best Answer

This works for article.cls \parts since there are no \chapters which must be reset too. It's regardless whether \part or \part* is used, the \setcounter{section}{0} just before \part does no harm and is done automatically here.

\documentclass{article}

%\usepackage{chngcntr}
%\counterwithin*{section}{part}

\usepackage{xpatch}

\xpretocmd{\part}{\setcounter{section}{0}}{}{}

\begin{document}

\part*{A part}

\section{A section in part}
\section{Another section in part}

\part*{Another part}

\section{A section in another part}

\section{Another section in another part}

\end{document}

enter image description here