how to limit the toc depth to 2 (css-based PDF)

Post here questions and problems related to editing and publishing DITA content.
galanohan
Posts: 115
Joined: Mon Jul 10, 2023 11:49 am

how to limit the toc depth to 2 (css-based PDF)

Post by galanohan »

Hi I'm modifying the css so that only level 1 and 2 topics are displayed in the TOC.

I took a reference from here:https://www.oxygenxml.com/doc/versions/ ... tents.html
and modify it like this:
/* Hide sections below level 2. */
*[class ~= "map/topicref"][is-chapter] >
*[class ~= "map/topicref"][is-chapter] >
*[class ~= "map/topicref"]:not([is-chapter]) >
*[class ~= "map/topicref"] >
*[class ~= "map/topicref"] {
display: none;
}
It doesn't work.

And I also tried with the following generic css rules:

.toc-entry.toc-h1,
.toc-entry.toc-h2
{
display: block;
}
.toc-entry.toc-h3,
.toc-entry.toc-h4,
.toc-entry.toc-h5,
.toc-entry.toc-h6
{
display: none;
}
They don't work either.

By the way, in the publishing template, I have the following parameter specified: <parameter name="args.css.param.numbering" value="shallow"/>. Being shallow means to have only level 1 topic titles included in the TOC, but changing to "deep" doesn't make sense either, as it will include all nested topic titles in the TOC.

Any hint? Thanks!
andrei_pomacu
Posts: 39
Joined: Mon Jul 25, 2022 11:18 am

Re: how to limit the toc depth to 2 (css-based PDF)

Post by andrei_pomacu »

Hi,

In order to have shallow numbering and in TOC be displayed level 1 and level 2, use this CSS rule which i have created using CSS debugging topic.
I was looking to the elements which need to be hide, level 3 and below and saw that the class on that element is "map/topicref".
The I was looking to the rule that styles the parent of that element and find *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"]:not(is-chapter).
I combined this 2 element to create a rule which will display:none any element that is children of the parent element and contains topicref.

Code: Select all

*[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"]:not(is-chapter) >  *[class ~= "map/topicref"]{
    display: none;
}
Regards,
Andrei
galanohan
Posts: 115
Joined: Mon Jul 10, 2023 11:49 am

Re: how to limit the toc depth to 2 (css-based PDF)

Post by galanohan »

Thanks Andrei, it doesn't work, was it because I didn't include these rules within @media print {} , or is it a must to claim the usage by specifying @media and print?
andrei_pomacu
Posts: 39
Joined: Mon Jul 25, 2022 11:18 am

Re: how to limit the toc depth to 2 (css-based PDF)

Post by andrei_pomacu »

Hi,

Could you sent me your CSS customization file on our support email, support@oxygenxml.com ?
I will to try to debug it in order to see why the rule that I gave you is not working.

Regards,
Andrei
galanohan
Posts: 115
Joined: Mon Jul 10, 2023 11:49 am

Re: how to limit the toc depth to 2 (css-based PDF)

Post by galanohan »

Hi Andrei,

I've sent an email to the support account with subject starts with "To Andrei:". Also, the attachment includes a sample project which I used for testing yesterday.

Thank you!

Regards,
Galano
Post Reply