[Tex/LaTex] Define new section

countersnumberingsectioning

I have this document in the article documentclass. Everything is divided into sections and subsections. Now I'd like to have an example in my chapter two, that is also divided into sections. So I have my normal document and in the second section there is an example of some code where the section numbering starts again from 1… Not sure if I can make myself clear enough but here is some pseudocode;

\section{1}
\section{2}
     \section{Here starts the example counter with 1}
     \section{New section in the example}
\section{3}

Best Answer

I'm not sure if I understand your question. Is this what you require?

\documentclass{article}
\begin{document}

\section{Section 1}
\section{Section 2}

\newcounter{sectionOld}
\setcounter{sectionOld}{\thesection}
\setcounter{section}{0}

\section{Here starts the example counter with 1}
    \subsection{Subsection 1}
\section{New section in the example}
    \subsection{Subsection 2}

\setcounter{section}{\thesectionOld}

\section{Section 3}

\end{document}