Discussion:
Reset Section Numbering by Part
Andrew Hills
2009-06-23 01:44:59 UTC
Permalink
Hi all,

I want the section numbering to restart for each part in the article
class. The only way I have devised is a simple hack in the LaTeX preamble:

\let\oldpart\part
\renewcommand{part}[1]{\oldpart{#1}
\setcounter{section}{0}}

This works great, except for the Table of Contents. When I generate a
PDF, every Section N links to the first Section N; e.g., clicking on
Part III, Section 2 takes me down to Part I, Section 2.

I understand that I can define a new counter with
\newcounter{newsection}[part] to reset when I want it to. Is there a way
to force sections to display this new counter while still being linked
with the old one? If not, is there another way to solve my problem?

Other information: LyX 1.6.2 on Windows XP (MiKTeX 2.7)

--Andrew Hills
Ingar Pareliussen
2009-06-23 07:52:39 UTC
Permalink
Hi
Post by Andrew Hills
I want the section numbering to restart for each part in the article
class. The only way I have devised is a simple hack in the
\let\oldpart\part
\renewcommand{part}[1]{\oldpart{#1}
\setcounter{section}{0}}
This works great, except for the Table of Contents. When I generate a
PDF, every Section N links to the first Section N; e.g., clicking on
Part III, Section 2 takes me down to Part I, Section 2.
I understand that I can define a new counter with
\newcounter{newsection}[part] to reset when I want it to. Is
there a way
to force sections to display this new counter while still
being linked
with the old one? If not, is there another way to solve my problem?
I think your problem is that hyperef only uses the section number
when making the bookmarks in toc. So, if I haven't overlooked somthing,
a new section wouldn't help you. Or atleast not if you didn't change
the hyperref-package to understand the newsection as well.

I think you have three options. The first is to use the report-class instead
of article, and chapter instead of part. This would have some side effects,
but in my head if you need a toc and to start sections anew for each
part, you do not write an article ;).

The second is to read the manual for the hyperef-peackage and hope that
there is someway to make hyperef to use the text of the section. I do not
know if this is the case, as I never have had the need.

The third is to construct the toc yourself from somthing like cross-ref.

I would go for option one, but you may have good reasons to use
article-class that I do not know of.

HTH,
Ingar
Andrew Hills
2009-06-23 15:05:19 UTC
Permalink
Post by Ingar Pareliussen
but in my head if you need a toc and to start sections anew for each
part, you do not write an article ;).
You caught me; I'm not writing an article. The article class is just the
one I'm most familiar manipulating. I'm also not releasing the source
for my document, so I'm more comfortable with unorthodox hacks.

It turns out there's a simple preamble command that accomplishes what I
want: \@addtoreset{section}{part}. It turned up after hours of poring
over documentation when Google searches failed.

--Andrew Hills

Loading...