Chapter title numbering, counting sections from zero in a specific chapter

Manohar_1024
Posts: 49
Joined: Wed Mar 27, 2019 10:12 am

Chapter title numbering, counting sections from zero in a specific chapter

Post by Manohar_1024 » Wed Sep 02, 2020 2:39 pm

Hello,

I want to get my chapter title numbers be like
1.1, 1.2, 1.2.1...
2.0, 2.0.1....2.1, 2.1.1
We have 3 chapters but for only 2nd chapter i want to get like 2.0 ...2.0.1 ...like that
I have tried using CSS..

Code: Select all

*[class ~= "map/map"] {
    counter-reset: page 1
                     section1 0 !important;
  *[class ~= "map/map"] *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before{
        content: counter(chapter) "." counter(section1) ". "!important;
}
 *[class ~= "map/map"] *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] {
    counter-increment:section1;
    counter-reset:page 1 section2 tablecount figcount !important;
}
So basically i want to get a 0 in chapter title and that to for 2nd chapter like using (If type condition in CSS way)

I using Pdf with CSS transformation scenario

Thank you,
Manohar.

Dan
Posts: 462
Joined: Mon Feb 03, 2003 10:56 am

Re: Chapter title numbering

Post by Dan » Thu Sep 03, 2020 10:01 am

This is a very specific requirement.

The solution is to reset the section1 counter to 0 by matching the topic chapter with a specific ID (or outputclass), or the first topic from that chapter.

You need to do this in both the TOC and content counters, so you will need an outputclass set on the topicref as well).

Pay attention to the counter-reset property, it will override other counter reset properties completely, even if you reset just one counter!

To speed up CSS development, please use a browser (like Chrome) to open the merged HTML file and make incremental changes to the CSS (refreshing in browser to see how counters are applied).

Many regards,
Dan

Manohar_1024
Posts: 49
Joined: Wed Mar 27, 2019 10:12 am

Re: Chapter title numbering

Post by Manohar_1024 » Mon Sep 07, 2020 10:04 am

Hello,

Thanks dan. It is working for chapter titiles. But can u help in getting the same in toc and footers...?
U have already mentioned about giving them in topic ref i have studied some of the oxygen xml links., but i am not able to figure it properly. So can you provide some sample about title numbering for topic ref in toc it will be more helpful for me.

Thankyou,
Manohar

Dan
Posts: 462
Joined: Mon Feb 03, 2003 10:56 am

Re: Chapter title numbering

Post by Dan » Tue Sep 08, 2020 9:18 am

For the TOC you should see how the counters toc-section1 and toc-chapter-and-sections are used in the p-numbering-deep.css file (similar to section1 and chapter-and-section counters that are used for titles in the main content). The default numbering CSS file is located in:
OXYGEN_INSTALL_DIR/DITAplugins/com.oxygenxml.pdf.css/css/print/p-numbering-deep.css

If you set an outputclass attribute on a topicref in the map, it is copied in the TOC section of the merged map and also on the element of the referred topic, in the main content. In this way you can mark both the topicref and the content of the chapter with special numbering. Let's assume we use 'zero-numbering' for a chapter topicref in the map. Then, you need to cancel incrementation for the first section from the marked chapter.

I would use the following selectors to solve both TOC and content numbering (they affect the headers and footers, bookmarks tree, because the counters are automatically used in all these places)

Code: Select all

*[class ~= "map/map"][numbering^='deep'] 
*[class ~= "map/topicref"][is-chapter]:not([is-part])[outputclass ~= 'zero-numbering'] 
> *[class ~= "map/topicmeta"] + *[class ~= "map/topicref"]{
    counter-increment:none;    
}

*[class ~= "map/map"][numbering^='deep'] 
*[class ~= "topic/topic"][is-chapter]:not([is-part])[outputclass ~= 'zero-numbering'] > *[class ~= "topic/topic"] {
    counter-increment:none;
}

*[class ~= "map/map"][numbering^='deep'] 
*[class ~= "topic/topic"][is-chapter]:not([is-part])[outputclass ~= 'zero-numbering'] > *[class ~= "topic/topic"] + *[class ~= "topic/topic"] {
    counter-increment:section1 chapter-and-sections;
}
Try this CSS on several map structures and let us know if it worked.
Many regards,
Dan

Post Reply