Page 1 of 1

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

Posted: Tue Oct 24, 2023 11:06 am
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!

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

Posted: Tue Oct 24, 2023 12:24 pm
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

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

Posted: Tue Oct 24, 2023 1:31 pm
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?

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

Posted: Wed Oct 25, 2023 9:15 am
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

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

Posted: Wed Oct 25, 2023 10:49 am
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