4

I am using article class. There are no chapters in the document. I want the section numbers to read as 1.1, 1.2, .... and then 2.1, 2.2, ..., and then 3.1, 3.2, ...

I have tried the code below

\documentclass{article}

\begin{document}

\renewcommand{\thesection}{1.\arabic{section}} % one block of sections
\section{ section one}
\section{second}
\section{third}

\renewcommand{\thesection}{2.\arabic{section}} % another block of sections
\section{First section}
\section{Second}

\end{document}

The code above gives 1.1, 1.2, 1.3 and then 2.4, 2.5. What I want is 1.1, 1.2, 1.3 and then 2.1, 2.2. Is there any way to do this? Thank you in advance.

1
  • Welcome to TeX.SE.
    – Mico
    Commented Apr 23, 2023 at 2:15

1 Answer 1

4

I think that what you want is to define a counter called, say, block, and "tie" the section counter (that's the counter that's stepped each time the \section macro is executed) to the block counter. By "tie", I mean that (a) the section counter is reset to 0 each time the block counter is stepped and (b) the section number is shown as being subordinated to the block number.

enter image description here

\documentclass{article}

\newcounter{block}
\counterwithin{section}{block} % tie 'section' counter to 'block' counter 

\begin{document}

\stepcounter{block} % one block of sections
\section{ section one}
\section{second}
\section{third}

\stepcounter{block} % another block of sections
\section{First section}
\section{Second}

\end{document}

That said, I'd also like to suggest that you start using \subsection commands instead of \section commands, as the subsection counter is tied to the section counter by default.

\documentclass{article}
\begin{document}

\stepcounter{section} % first block
\subsection{first}
\subsection{second}
\subsection{third}

\stepcounter{section} % another block
\subsection{First}
\subsection{Second}

\end{document}
1
  • 1
    Thank you very much @Mico, your solution perfectly gives me what I wanted. Commented Apr 23, 2023 at 2:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .