number contents in the frontmatter of a dita book
Post here questions and problems related to editing and publishing DITA content.
number contents in the frontmatter of a dita book
Hello,
I need to create a DITA Book that includes an Overview chapter before the TOC. So, I included a Topic Group (alternatively a referenced Map) in the frontmatter. The chapter is listed in the TOC but the numbering of chapters starts with the first chapter after the TOC, which is actually all right, however, the document I need to create has to follow an official template, which requires that the chapter numbering starts with the Overview chapter, which is before the TOC, and even the TOC itself requires a number. (1 Overview, 2 Table of Contents, 3 Introduction…). Is there a way to accomplish that? Thank you very much for your help.
I need to create a DITA Book that includes an Overview chapter before the TOC. So, I included a Topic Group (alternatively a referenced Map) in the frontmatter. The chapter is listed in the TOC but the numbering of chapters starts with the first chapter after the TOC, which is actually all right, however, the document I need to create has to follow an official template, which requires that the chapter numbering starts with the Overview chapter, which is before the TOC, and even the TOC itself requires a number. (1 Overview, 2 Table of Contents, 3 Introduction…). Is there a way to accomplish that? Thank you very much for your help.
-
- Posts: 393
- Joined: Wed Oct 16, 2019 3:47 pm
Re: number contents in the frontmatter of a dita book
Post by julien_lacour »
Hello,
This seems quite hard to realize: you can easily number the chapters before the TOC from a custom CSS stylesheet, but for the TOC itself that's different.
By default the TOC doesn't include itself, which will lead to a different numbering inside and outside the TOC:
Julien
This seems quite hard to realize: you can easily number the chapters before the TOC from a custom CSS stylesheet, but for the TOC itself that's different.
By default the TOC doesn't include itself, which will lead to a different numbering inside and outside the TOC:
- The TOC will have:
1 Overview
2 Introduction
… - The Content and the Bookmarks will be:
1 Overview
2 Table of Contents
3 Introduction
...
Julien
-
- Posts: 22
- Joined: Thu Jul 29, 2021 12:02 pm
Re: number contents in the frontmatter of a dita book
Post by InspectorSpacetime »
Chiming in...
I decided to give this problem a try. Here's what I got so far:
My solution is pretty much a hack: The "Table of Contents" entry in the TOC is created as an :after pseudo element of the "Overview" entry. Also the toc-chapter counter is reset to a new value, so that the numbering aligns with the actual one in the PDF bookmarks.
There's 2 problems: The "Table of Contents" link doesn't work. Because it's a pseudo element of the first entry, the link also points to the "Overview" chapter. I don't suppose there's a way to change or erase the href in the :after element? Erasing would suffice, because you're already in the TOC if you're trying to click it...
Also, I wasn't able to change any of the page number styles in the PDF using the counter(page, decimal) command. Because of this, the TOC entry in the...well, TOC...is in roman numerals.
But if you can live with these I can share the CSS with you.
I decided to give this problem a try. Here's what I got so far:
- tocsample.png (14.74 KiB) Viewed 309 times
There's 2 problems: The "Table of Contents" link doesn't work. Because it's a pseudo element of the first entry, the link also points to the "Overview" chapter. I don't suppose there's a way to change or erase the href in the :after element? Erasing would suffice, because you're already in the TOC if you're trying to click it...
Also, I wasn't able to change any of the page number styles in the PDF using the counter(page, decimal) command. Because of this, the TOC entry in the...well, TOC...is in roman numerals.
But if you can live with these I can share the CSS with you.
-
- Posts: 22
- Joined: Thu Jul 29, 2021 12:02 pm
Re: number contents in the frontmatter of a dita book
Post by InspectorSpacetime »
Some requirements for this to work:
1) You must use the PDF Based on HTML5 & CSS transformation
2) You can have only one chapter before the TOC
3) Your bookmap should be arranged like this:
So, no topicgroup in the frontmatter. Just a single topicref (Overview). I suspect using a topicgroup would break this solution.
Here's the CSS. I got the roman numeral thing fixed. Unfortunately I haven't yet commented the CSS at all:
Do try it out and see if it works. I'm sure this is not the only solution, and this is certainly not the most elegant one. But before something else comes up, maybe this works as an intermediate solution?
1) You must use the PDF Based on HTML5 & CSS transformation
2) You can have only one chapter before the TOC
3) Your bookmap should be arranged like this:
Code: Select all
<bookmap>
<booktitle>
<mainbooktitle>MapTitle</mainbooktitle>
</booktitle>
<frontmatter>
<topicref href="topics/overview.dita"/>
<booklists>
<toc/>
</booklists>
</frontmatter>
<chapter href="topics/introduction.dita"/>
<chapter href="topics/installation.dita"/>
</bookmap>
Here's the CSS. I got the roman numeral thing fixed. Unfortunately I haven't yet commented the CSS at all:
Code: Select all
@page {
@bottom-right-corner {
content: counter(page, decimal);
}
}
@page table-of-contents:left {
@top-left {
content: string(toc-header) " | " counter(page, decimal);
}
}
@page table-of-contents:right {
@top-right {
content: string(toc-header) " | " counter(page, decimal);
}
}
*[class ~= "toc/title"]:before {
content: "2. Table of Contents" !important;
}
.topic[is-chapter] > .topictitle1:before {
content: counter(chapter) ". " !important;
}
.topic[is-frontmatter] > .topictitle1:before {
content: "1. ";
}
.topic[is-chapter]#unique_2 {
counter-reset: chapter 2;
}
*[class ~= "map/topicref"].frontmatter {
font-weight: bold;
}
*[class ~= "map/topicref"].frontmatter .navtitle:before {
content: counter(toc-chapter) ". ";
}
*[class ~= "map/topicref"].frontmatter .navtitle:after(1) {
content: leader(".") 2;
}
*[class ~= "map/topicref"].frontmatter .navtitle:after(2) {
content: "2. Table of Contents" leader(".") counter(page);
display: block;
margin-top: 0.5em;
}
*[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]:before {
content: counter(toc-chapter) ". ";
}
*[class ~= "map/topicref"][is-chapter]:nth-of-type(4) {
counter-reset: toc-chapter 2;
}
*[class ~= "map/topicref"]:first-of-type {
counter-increment: toc-chapter;
}
Re: number contents in the frontmatter of a dita book
Thank you very much for your help but unfortunately it doesn’t work this way for me. The entry for the TOC appears several times in the TOC and the numbering in the TOC differs from the numbering in the document. Part of the problem seems to be the subtopics in the frontmatter chapter. However even if I delete them it doesn't work.
If there is no simple solution I’d rather switch to Word to create the document. Thank you very much again for your time.
If there is no simple solution I’d rather switch to Word to create the document. Thank you very much again for your time.
- TOC.png (41.79 KiB) Viewed 269 times
-
- Posts: 22
- Joined: Thu Jul 29, 2021 12:02 pm
Re: number contents in the frontmatter of a dita book
Post by InspectorSpacetime »
I'm sorry it didn't work. The "issue" seems to be that your map structure is more complex than what I was using. Hope someone else can help.
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service