Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
\subsection and in the preamble \renewcommand*\thesubsection{\arabic{subsection}} will do? –  Count Zero Nov 22 '12 at 14:37
    
Take a look at this question: Deeper levels of (sub)sections –  mkota Nov 22 '12 at 14:38
    
Yeah okay... But the sections already have subsections of their own... –  Pieterjan Nov 22 '12 at 14:46

1 Answer 1

up vote 2 down vote accepted

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}
share|improve this answer
    
Yes! That's exactly it :) Thank you Jay! –  Pieterjan Nov 22 '12 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.