How to Add a Link to the TOC
For making the navigation easier in the PDF, you may want to add a link that sends the reader
back to the table of contents. To add this link, use an Oxygen Publishing Template and
follow these steps:
- If you have not already created a Publishing Template, you need to create one. For details, see How to Create a Publishing Template.
- Link the folder associated with the publishing template to your current project in the Project view.
- Using the Project view, create an xslt folder inside the project root folder.
- In the newly created folder, create an XSL file (for example, named
merged2html5Extension.xsl) with the following
content:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="3.0"> <!-- Add an anchor after the TOC title. --> <xsl:template match="*[contains(@class, 'toc/title')]" mode="div-it"> <div> <xsl:attribute name="class" select="'- toc/anchor anchor'"/> <xsl:attribute name="id" select="'toc-anchor'"/> </div> <xsl:next-match/> </xsl:template> </xsl:stylesheet> - Open the template descriptor file associated with your publishing
template (the .opt file) and set the XSLT stylesheet created in the previous
step with the
com.oxygenxml.pdf.css.xsl.merged2html5XSLT extension point:<publishing-template> ... <pdf> ... <xslt> <extension id="com.oxygenxml.pdf.css.xsl.merged2html5" file="xslt/merged2html5Extension.xsl"/> </xslt> - Create a css folder in the publishing template
directory. In this directory, save a custom CSS file with rules that style the
glossary structure. For
example:
@page chapter:first:left:right { @top-right { content: "Back to Table of Contents"; -oxy-link: "#toc-anchor"; color: #337ab7; } } @page chapter:left:right { @top-right { content: "Back to Table of Contents"; -oxy-link: "#toc-anchor"; color: #337ab7; } } - Open the template
descriptor file associated with your publishing template (the
.opt file) and reference your custom CSS file in the
resourceselement:<publishing-template> ... <pdf> ... <resources> <css file="css/custom.css"/> </resources> - Edit the DITA Map PDF - based on HTML5 & CSS transformation scenario.
- In the Templates tab, click the Choose Custom Publishing Template link and select your template.
- Click OK to save the changes and run the transformation scenario.