LyX ⇒ How to reset section numbering by part?
How to reset section numbering by part?
I'm using the article class, and I would like the section numbering to restart after every Part.
Specifically, I want something like this:
PART I
Section 1
Section 2
...
PART II
Section 1
Section 2
...
I know that I can do this by inserting some LATEX code into the preamble, but I have no idea how to do this.
Help much appreciated!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
How to reset section numbering by part?
Code: Select all
\documentclass{article}
\usepackage{blindtext}
\usepackage{chngcntr}
\counterwithin*{section}{part}
\begin{document}
\part{some thing}
\section{words}
\blindtext
\section{numbers}
\blindtext
\part{some other}
\section{trees}
\blindtext
\section{mobile phones}
\blindtext
\end{document}
Re: How to reset section numbering by part?
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
How to reset section numbering by part?
LyX produces stuff like that in the background, you never see it. But in this case you need to add
Code: Select all
\usepackage{chngcntr}
\counterwithin*{section}{part}
BTW: You can click on »Open in writelatex« above the full example above to see the output.
Re: How to reset section numbering by part?
I hit "Open in writelatex" on the first code you posted and it's exactly what I need.
As for the lyx code you posted, I added it to the preamble but that still didn't work for some reason

I attached below a screenshot of the preamble box, and of the lyx output that still numbers the second section as "2".
- Attachments
-
- Untitled.png (127.74 KiB) Viewed 37322 times
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: How to reset section numbering by part?
What happens if you export to pdf?
You might need to wait, till someone with more LyX experience comes along.
Re: How to reset section numbering by part?
This is still not a perfect fix since I like using Lyx because I can see the formatting in the lyx document itself (in which it is incorrect).
Thanks very much for your help!
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: How to reset section numbering by part?
-
- Posts: 89
- Joined: Fri Jan 24, 2014 12:42 am
How to reset section numbering by part?
Code: Select all
Counter section
Within part
End
Re: How to reset section numbering by part?
The combination of both of your solutions is perfect.
If I could add another minor question - is there a way to reset the equation numbering as well? So that it begins numbering from (1) every new Part?
Again thanks alot!