Page 1 of 1
Add TOC title into TOC
Posted: Fri Oct 24, 2025 9:50 am
by gyinshuen
Hi,
Do I have a way to insert TOC title (Contents) into DITA PDF toc? Just like the left-hand side of the image shown, the right-hand side shows my DITA PDF-CSS output.
image.png
Re: Add TOC title into TOC
Posted: Fri Oct 24, 2025 12:49 pm
by julien_lacour
Hi,
Yes, you have the possibility to insert it, there's a
use-case in our user-guide from which you can start the customization:
- The XSLT part is similar except <xsl:next-match/> must be called before the actual <div>:
Code: Select all
<xsl:template match="*[contains(@class, 'toc/title')]" mode="div-it">
<xsl:next-match/>
<div>
<xsl:attribute name="class" select="'- toc/anchor anchor'"/>
<xsl:attribute name="id" select="'toc-anchor'"/>
</div>
</xsl:template>
- Replace all the CSS by:
Code: Select all
*[class ~= "toc/anchor"] {
content: "Contents";
-oxy-link: "#toc-anchor";
}
*[class ~= "toc/anchor"]:after {
content: leader('.') target-counter(attr(id), page);
}
Regards,
Julien