Forum How do I...?

Title counters in Table of Content

rologica
I've managed to counter (and subcounter) the different titles and subtitles of a chapter. But how can I get these numbers in front of the titles in the Table of Contents?

Thanks in advance...
Rogier
mikeday
Use target-counter() in generated content to create cross-references.
rologica
Thank you for the reply. A little further now, but still not whats expected. Can you tell me what I'm doing wrong here:

To count and number the content:
.module .chapter h2.chapterNumber{ /* from the content */
	string-set:strChapterNumber content();
	display:none;
}

.module .chapter h2.chapterTitle{ /* stop title numbering, start over */
	counter-reset: strTopicNumber;
}

.module .chapter h2.topicTitle{ /* count titles in this chapter */
	counter-increment: strTopicNumber;
}

.module .chapter h2.chapterTitle::before{ /* present chapter number */
	content:string(strChapterNumber)" ";
}

.module .chapter h2.topicTitle::before{ /* present chapter and topic numbers */
	content:string(strChapterNumber) "." counter(strTopicNumber) " ";
}


And this for the numbering in the Table of contents:
#module0 ul.toc a::after { /* page numbering */
	content:leader('.') target-counter(attr(href), page);
}

#module0 ul.toc ul li a::before { /* chapter and topic numbering */
	content: target-counter(attr(href),strChapterNumber)"."target-counter(attr(href), strTopicNumber)" ";
}



The page numbering operates perfectly, but the chapter and topic numbering is rendering it's own numbers: 0.0 0.1 0.2 for every chapter.

What am I doing wrong?
mikeday
I think the problem is strChapterNumber, which is a string not a counter, and can't be referenced with target-counter. You could try using target-content(attr(href)) to reference the content of the referenced element.