Forum How do I...?

chapter counter does not increase - how to solve

osprofi
Hello Prince Users
I created a book structure with prefaces, chapters and appendices.
Using the ideas for automatic chapter numbering I can not achieve automatic increase of chapter numbering.
Can you have a look and tell me what I am doing wrong ? Here is the html code:
[html]
<div class="preface">
<h1 class="preface">title preface</h1>
</div>
<div class="chapter">
<h1 class="chapter">title chapter 1</h1>
</div>
<div class="chapter">
<h1 class="chapter">title chapter 2</h1>
</div>
<div class="appendix">
<h1 class="preface">title appendix</h1>
</div>
[/html]

[css]
body {
counter-reset: h1counter;
}
h1.chapter:before {
content: counter(h1counter, upper-roman) ".\0000a0\0000a0";
}
/* the next is for the running header increasing chapter number */
h1 { counter-increment: h1counter;
string-set: title counter(h1counter, upper-roman) ".\0000a0\0000a0" content(text)
}
[/css]

Thanks very much for your advice.

regards, Peter
dauwhe
If I run your code as-is, I do get incrementing numbers on the chapter titles:

title preface
II. title chapter 1
III. title chapter 2
title appendix

I noticed that you're incrementing the counter for every h1, not just h1 class="chapter" (that's why chapter 1 is labelled "II.") I'd probably increment the counter on div class="chapter" rather than on the h1, but I don't know what your content looks like.

Thanks,

Dave
osprofi
Hello Dave
- the increment on the counter div class="chapter" works perfectly
- but the running header text is then the full div class="chapter" text

[css]
div.chapter {
counter-increment: h1counter;
string-set: title counter(h1counter, upper-roman) ".\0000a0\0000a0" content(text)
}
[/css]

when inserting content(div.chapter>h1) instead of content(text) this does not work

Do you have an idea here?

Thanks for assistance

Peter