LyX ⇒ How to reset section numbering by part?
How to reset section numbering by part?
Hello,
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!
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.

- 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}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Re: How to reset section numbering by part?
Hey, thanks for the reply, but I'm not quite sure how to use this code. I tried simply copy-pasting it into the preamble but it didn't work. What should I be doing?
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
How to reset section numbering by part?
This is a complete minimal example, this is valent LaTeX code. There are not only LyX people around.
LyX produces stuff like that in the background, you never see it. But in this case you need to add to your preamble.
BTW: You can click on »Open in writelatex« above the full example above to see the output.
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.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Re: How to reset section numbering by part?
OK I understand.
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".
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 37708 times
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: How to reset section numbering by part?
I don't have LyX installed, so i can't test anything.
What happens if you export to pdf?
You might need to wait, till someone with more LyX experience comes along.
What happens if you export to pdf?
You might need to wait, till someone with more LyX experience comes along.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Re: How to reset section numbering by part?
Weird: Exporting to PDF actually displays the correct form, meaning both sections are labeled "1"...!
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!
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?
LyX and LaTeX are seperated systems. LyX does things, creates a tex-file and LaTeX typesets it. With the code above, you put just the things needed to the tex. This is completely independent of LyX. If you want to have this implemented directly (visibly) in LyX, please send a mail to the LyX-support team.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
-
- Posts: 89
- Joined: Fri Jan 24, 2014 12:42 am
How to reset section numbering by part?
What's happening is that, behind the scenes, there's a layout file that tells LyX what to put on the screen and that still has the old counters in it. Luckily this is a really simple fix because LyX has this feature called Local Layout so you can change the layout just for this one document. Go into Document Settings, select Local Layout from the list, paste the contents of the Code section below into the box and click the Validate button, then click OK.
Code: Select all
Counter section
Within part
End
Re: How to reset section numbering by part?
Hi, thanks very much!
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!
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!