Table of ContentsEdit online
The table of contents is a hierarchy of topic titles with links to the topic content.
Table of Contents - Input XML fragmentEdit online
In the merged DITA map, the <opentopic:map> contains a hierarchy of
<topicref> elements, or other elements (such as
<chapter> or <part>) that are specializations
of <topicref>.
Each of the <topicref> elements include a metadata section that
includes the topic title.
<bookmap ...> <oxy:front-page> ... </oxy:front-page> <oxy:front-matter> ... </oxy:front-matter> <opentopic:map xmlns:opentopic="http://www.idiominc.com/opentopic"> <oxy:toc-title xmlns:oxy="http://www.oxygenxml.com/extensions/author" empty="true"/> <booktitle class="- topic/title bookmap/booktitle "> <booklibrary class="- topic/ph bookmap/booklibrary ">Retro Tools</booklibrary> <mainbooktitle class="- topic/ph bookmap/mainbooktitle ">Tasks</mainbooktitle> <booktitlealt class="- topic/ph bookmap/booktitlealt ">Product Tasks</booktitlealt> </booktitle> <chapter is-chapter="true" class="- map/topicref bookmap/chapter " href="#unique_5" type="topic"> <topicmeta class="- map/topicmeta " data-topic-id="installing"> <navtitle href="#unique_5" class="- topic/navtitle ">Installing</navtitle> ... </topicmeta> <topicref class="- map/topicref " href="#unique_6" type="task"> <topicmeta class="- map/topicmeta " data-topic-id="installstorage"> <navtitle href="#unique_6" class="- topic/navtitle ">Installing</navtitle> ... </topicmeta> ... </topicref> ... </chapter>
For the DITA Map PDF - based on HTML5 &
CSS transformation type, the merged map is further processed
resulting in a collection of HTML5 <div> elements. These
elements preserve the original DITA @class attribute values and
add a new value derived from the DITA element name.
<div class="- bookmap/bookmap map/map map bookmap" ...> <div class="- front-page/front-page front-page"> ... </div> <div class="- bookmap/frontmatter frontmatter"> ... </div> <div class=" toc/toc toc"> <div class="toc/toc-title toc-title" empty="true"/> <div class="- topic/title bookmap/booktitle booktitle"> <div class="- topic/ph bookmap/booklibrary booklibrary">Retro Tools</div> <div class="- topic/ph bookmap/mainbooktitle mainbooktitle">Tasks</div> <div class="- topic/ph bookmap/booktitlealt booktitlealt">Product Tasks</div> </div> <div is-chapter="true" class="- map/topicref bookmap/chapter topicref chapter " href="#unique_5" type="topic"> <div class="- map/topicmeta topicmeta" data-topic-id="installing"> <div href="#unique_5" class="- topic/navtitle navtitle">Installing</div> ... </div> <div class="- map/topicref topicref chapter " href="#unique_6" type="task"> <div class="- map/topicmeta topicmeta" data-topic-id="installstorage"> <div href="#unique_6" class="- topic/navtitle navtitle">Installing</div> ... </div> ... </div> ... </div>
<oxy:toc-title> element is used as a placeholder for the name
of the TOC. For instance, you can use the string "Contents", specified on a pseudo element, in
the CSS.Table of Contents - Built-in CSSEdit online
The built-in CSS rules are in: [PLUGIN_DIR]/css/print/p-toc.css.
How to Style the Table of Contents EntriesEdit online
map/topicref class.In your customization CSS, add the following two selectors:
/* The toc item label - the topic title */ *[class ~= "map/topicref"] *[class ~= "topic/navtitle"] { font-style:italic; color: navy; } /* The dotted line between the topic name and the page number. */ *[class ~= "map/topicref"] *[class ~= "topic/navtitle"]:after { content: leader('-') target-counter(attr(href), page); color: navy; }
And if you need to alter the indent of the nested table of content items, use the following selector:
*[class ~= "map/topicref"] *[class ~= "map/topicref"] { margin-left: 1em; }
The numbers can be styled like this:
*[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before, *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]:before{ color:blue; }
The following is an example of customizing the font size for the items representing chapters.
The chapters are level one topics and are marked in the merged DITA document TOC with the
attribute @is-chapter.
*[class ~= "map/topicref"][is-chapter = "true"] > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]{ font-size:2em; }
How to Change the Header of the Table of ContentsEdit online
In the built-in CSS, there is a page named table-of-contents. The default is to
have the word 'Contents' in its header (this is localized, using the
toc-header string defined in the p-18n.css)
alternating in the left or right side of the header:
@page table-of-contents:left { @top-left { content: string(toc-header) " | " counter(page, lower-roman); font-size: 8pt; } } @page table-of-contents:right { @top-right { content: string(toc-header) " | " counter(page, lower-roman); font-size: 8pt; } }
If you need to change this string, or change the color, you should use the following
@page selectors as a starting point in your customization CSS:
@page table-of-contents:left { @top-left { content: "My publication table of contents | " counter(page, lower-roman); color:red; } } @page table-of-contents:right { @top-right { content: "My publication table of contents | " counter(page, lower-roman); color:red; } }
How to Make the Table of Contents Start on an Odd PageEdit online
In your customization CSS, add the following snippet for the table-of-contents page:
@page table-of-contents{
-oxy-initial-page-number: auto-odd;
}
How to Display a Topic Before the Table of ContentsEdit online
- Make sure the topic is referenced on the first level in the DITA map.
- Set the
@outputclasstobefore-tocon the<topicref>.
<topicref href="pathToMyTopic" outputclass="before-toc">
Result: When the PDF is processed, the topic will automatically appear before the table of contents.
How to Display Short Descriptions in the TOCEdit online
To display the short descriptions from the topics in the table of contents, you need to make
the <shortdesc> element visible.
The following examples only makes the short descriptions associated with the chapters
visible. The chapters are level one topics and are marked in the merged DITA document TOC with
the attribute @is-chapter.
In your customization CSS, add the following CSS selector:
*[class ~= "map/topicref"][is-chapter = "true"] > *[class ~= "map/topicmeta"] > *[class ~= "map/shortdesc"] { display:block; /* The default is none - the shortesc is hidden. */ color:gray; }
[is-chapter] condition.