Difficulty styling TOC content using CSS
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 6
- Joined: Mon Dec 18, 2023 6:46 pm
Difficulty styling TOC content using CSS
Hello,
This forum has been a goldmine when it comes to solving my DITA to (mainly) PDF transformations in combination with using CSS to style the output. Now I encounter a problem for which I am unable to find a solution, even on this forum.
I am attempting to replicate the styling a customer uses for the TOC in their word manuals. More specifically, I am attempting to create more space between the chapter numbering and the chapter title, like in the image below.
I have no succes with peuso elements like ::before and ::marker.
Any and all help is greatly appreciated!
Kind regards,
Tom
This forum has been a goldmine when it comes to solving my DITA to (mainly) PDF transformations in combination with using CSS to style the output. Now I encounter a problem for which I am unable to find a solution, even on this forum.
I am attempting to replicate the styling a customer uses for the TOC in their word manuals. More specifically, I am attempting to create more space between the chapter numbering and the chapter title, like in the image below.
image1.png
I am able to target the different map/topicrefs and thus, styling them. But when I move them the chapter number moves as well.I have no succes with peuso elements like ::before and ::marker.
Any and all help is greatly appreciated!
Kind regards,
Tom
You do not have the required permissions to view the files attached to this post.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Difficulty styling TOC content using CSS
Post by julien_lacour »
Hello,
You're right the <topicref> element includes both chapter number and title, to add a space you should use an deeper element in the structure, for example navtitle:
You can use your favorite browser to debug the CSS and see the actual structure, how the CSS is applied and the stylesheets order.
Regards,
Julien
You're right the <topicref> element includes both chapter number and title, to add a space you should use an deeper element in the structure, for example navtitle:
Code: Select all
*[class ~= "map/topicref"] *[class ~= "topic/navtitle"] {
margin-left: 1em;
}
Regards,
Julien
-
- Posts: 6
- Joined: Mon Dec 18, 2023 6:46 pm
Re: Difficulty styling TOC content using CSS
Hello Julien,
Thank you for your reply. That does indeed work... mostly. When the amount of chapters enters the double digits the chapters are nog longer aligned the way I want them to be, see the image below.
Again, thanks in advance for your help,
Kind regards,
Tom
PS: Thank you for the tip about debugging the css using a browser, will definitely be using that in the future
Thank you for your reply. That does indeed work... mostly. When the amount of chapters enters the double digits the chapters are nog longer aligned the way I want them to be, see the image below.
afbeelding.png
Is there any way to prevent this from happening?Again, thanks in advance for your help,
Kind regards,
Tom
PS: Thank you for the tip about debugging the css using a browser, will definitely be using that in the future
You do not have the required permissions to view the files attached to this post.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Difficulty styling TOC content using CSS
Post by julien_lacour »
Hello,
In this case you need to set the args.css.param.title-layout parameter value to "table".
Then, you can set a width for each cell containing the chapter numbering:
You can use any unit from the moment the chapter numbering fits in the given width.
Regards,
Julien
In this case you need to set the args.css.param.title-layout parameter value to "table".
Then, you can set a width for each cell containing the chapter numbering:
Code: Select all
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-part] > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before {
width: 1cm;
}
Regards,
Julien
-
- Posts: 6
- Joined: Mon Dec 18, 2023 6:46 pm
Re: Difficulty styling TOC content using CSS
Hello Julien,
Thanks again for your help. Your solution works but presents a new problem, one I vaguely remember seeing in a different forum post once.
I have set my numbering to "deep", instead of the default "shallow". I have figured out that this setting is the reason the following problem occurs:
The page numbering on the right side of the TOC is no longer correctly aligned when numbering is set to deep in combination with the parameter "args.css.param.title-layout" value set to "table", see the below image.
When the numbering is set to default [shallow], this is the output:
Thanks again for your help. Your solution works but presents a new problem, one I vaguely remember seeing in a different forum post once.
I have set my numbering to "deep", instead of the default "shallow". I have figured out that this setting is the reason the following problem occurs:
The page numbering on the right side of the TOC is no longer correctly aligned when numbering is set to deep in combination with the parameter "args.css.param.title-layout" value set to "table", see the below image.
deep numbering.png
Page numbers are indented at seemingly random places and the indentation also seems to be quite random.When the numbering is set to default [shallow], this is the output:
default shallow numbering.png
You do not have the required permissions to view the files attached to this post.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Difficulty styling TOC content using CSS
Post by julien_lacour »
Hello,
I tested on my side using <oXygen/> XML Editor 26.0, build 2023100905, the CSS I gave you previously and deep numbering, the result is the following:
Regards,
Julien
I tested on my side using <oXygen/> XML Editor 26.0, build 2023100905, the CSS I gave you previously and deep numbering, the result is the following:
deep_toc.png
Maybe you have other rules disrupting the TOC display: different fonts, margins, paddings, etc.Regards,
Julien
You do not have the required permissions to view the files attached to this post.
-
- Posts: 6
- Joined: Mon Dec 18, 2023 6:46 pm
Re: Difficulty styling TOC content using CSS
Hi Julien,
I decided to attempt to replicate your example.
1. I duplicated the DITA Map PDF - based on HTML5 & CSS scenario.
2. Changed the numbering to 'deep'.
3. Changed the args.css.param.title-layout parameter value to 'table'.
4. Added a new CCS file, containing only the CSS you gave me, with the exception of adding a background color for visual purposes.
Unfortunately I get the same problem, see the image below.
Any ideas what I might be missing/doing wrong?
Thanks again!
I decided to attempt to replicate your example.
1. I duplicated the DITA Map PDF - based on HTML5 & CSS scenario.
2. Changed the numbering to 'deep'.
3. Changed the args.css.param.title-layout parameter value to 'table'.
4. Added a new CCS file, containing only the CSS you gave me, with the exception of adding a background color for visual purposes.
Code: Select all
/* together with setting 'args.css.param.title-layout' parameter value to "table", this evens out the width of the chapter numbering */
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-part] > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before,
*[class ~= "map/map"][title-layout='table'] *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before {
width: 1cm;
background-color: rgb(51, 255, 0);
}
afbeelding.png
I am using <oXygen/> XML Editor 25.1, build 2023042509Any ideas what I might be missing/doing wrong?
Thanks again!
You do not have the required permissions to view the files attached to this post.
Last edited by Tomh94 on Fri Dec 22, 2023 5:02 pm, edited 3 times in total.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Difficulty styling TOC content using CSS
Post by julien_lacour »
Hello,
I don't have <oXygen/> XML Editor 25.1, build 2023042509, only the last maintenance build 2023070306 but the problem doesn't seems to be present on this version.
Maybe you could try to update to this last maintenance build and see if the page numbers align.
Regards,
Julien
I don't have <oXygen/> XML Editor 25.1, build 2023042509, only the last maintenance build 2023070306 but the problem doesn't seems to be present on this version.
Maybe you could try to update to this last maintenance build and see if the page numbers align.
Regards,
Julien
-
- Posts: 6
- Joined: Mon Dec 18, 2023 6:46 pm
Re: Difficulty styling TOC content using CSS
Hello,
I have updated to oXygen editor 26.0, my colleagues have author 26.0 and we all still encounter the same problem.
Whenever the args.css.param.title-layout parameter value is set to "table", the numbering is set to 'deep' and the CSS contains the code you provided we get something like this:
I have targeted the green ' ......X' part by changing :before to :after, but I cannot manage to meaningfully change its position. I had hoped I could just align those to the right side of the TOC but no luck...
I find it strange that you seemingly are able to get the right output, while we can't. Even with empty, clean css and scenario's.
Could you maybe try and test again while also marking the chapter number prefix with a colored background, like in my example?
Thanks again for your time!
I have updated to oXygen editor 26.0, my colleagues have author 26.0 and we all still encounter the same problem.
Whenever the args.css.param.title-layout parameter value is set to "table", the numbering is set to 'deep' and the CSS contains the code you provided we get something like this:
afbeelding.png
Even if the custom css file contains only your code and we use the standard oXygen template we get a wobbly column of page numbers on the right.I have targeted the green ' ......X' part by changing :before to :after, but I cannot manage to meaningfully change its position. I had hoped I could just align those to the right side of the TOC but no luck...
Code: Select all
*[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]::after,
*[class ~= "map/topicref"] > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]::after{
background-color: #77ca29;
}
Could you maybe try and test again while also marking the chapter number prefix with a colored background, like in my example?
Thanks again for your time!
You do not have the required permissions to view the files attached to this post.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Difficulty styling TOC content using CSS
Post by julien_lacour »
Hello,
I added your CSS to my sample, and using <oXygen/> XML Editor 26.0, build 2023100905 I still obtain aligned numbers in TOC.
I tried to debug my CSS and opened the merged.html file in Author mode:
The inspection only shown your custom rule and the default rule on the after block (displaying the leader and the page number).
You could try to check it on your side too and see if you have the same style.
If you have the same display, could you send us a small sample where this problem occurs at support@oxygenxml.com for analysis?
Regards,
Julien
I added your CSS to my sample, and using <oXygen/> XML Editor 26.0, build 2023100905 I still obtain aligned numbers in TOC.
I tried to debug my CSS and opened the merged.html file in Author mode:
Code: Select all
*[class~='map/topicref'] > *[class~='map/topicmeta'] > *[class~='topic/navtitle']:after {
background-color : rgb(119 , 202 , 41) ;
}
*[class~='map/topicref']:not(*[scope='external']) *[class~='topic/navtitle']:after {
content : leader(".") target-counter(attr(href) , page) ;
}
You could try to check it on your side too and see if you have the same style.
If you have the same display, could you send us a small sample where this problem occurs at support@oxygenxml.com for analysis?
Regards,
Julien
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 JSON Editor
- ↳ 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