DITA-FMx User Guide

Using Templates to Define Alternate TOC Entries

By default, the paragraph styles applied to all titles in all generated FM files are the same (title.0, title.1, etc., as defined by the Book structure application). When pulled into a TOC file, they become “title.0TOC”, “title.1TOC”, and so on. Your TOC generated list template (“gentpl~toc.fm”) defines the handing for these styles on the “TOC” reference page. If you want to be able to support multiple types of entries, such as “Chapter”, “Appendix”, and “Part”, you’ll need to do the following.

Note: As of DITA-FMx 1.1.09, the component-templates folder in the default Book application folder contains component templates for appendix and part, and the default TOC template is set up to handle chapter, appendix, and part TOC entries.
Create a custom EDD and template for each TOC type

The component template (tpl~<mapelemtype>.fm) will apply alternate formatting to the specific book component, but if you want the underlying paragraph styles to change, you need to create a modified EDD that applies the alternate style, and update the template to support that style. The actual style may look the same, but the name needs to be different so it can be handled separately in the TOC template. For example, if you want to add support for the appendix element and have your TOC include both Chapter and Appendix labels, you could do the following:

  1. Copy the default Book EDD (book_1.1.edd.fm) to a new name, perhaps book_1.1_appendix.edd.fm.
  2. Copy the default Book template (book_1.1.template.fm) to a new name, perhaps book_1.1_appendix.template.fm.
  3. Edit the book_1.1_appendix.edd.fm file and change all instances of “title.0” to “title-appendix.0”, then save the EDD.
  4. In the appendix template (book_1.1_appendix.template.fm) rename the “title.0” style to “title-appendix.0” and modify its appearance as needed.
  5. Import the EDD into the appendix template, then save and close both files.
  6. Copy the appendix template to the proper component template name (from book_1.1_appendix.template.fm to tpl~appendix.fm, then copy this file into the appropriate component template folders (defined by the BookTemplatesDir parameter in the ditafmx-bookbuild.ini file).

When a book is generated and this template is applied, this will apply the title-appendix.0 style to the top-level heading in the appendix files.

Add the new paragraph style to the GeneratedFile-toc section

For each new TOC entry type, you’ll need to add that paragraph style to the GeneratedFile-toc section of the ditafmx-bookbuild.ini file. Be sure to update the NumTags parameter to match the number of paragraph tags used to generate the TOC.

Add support for the new TOC styles in the TOC template
In the TOC generated list template (“gentpl~toc.fm”), add support for the “title-appendix.0TOC” style on the TOC reference page (it would look just like the title.0TOC style but use the new style name and prepend “Appendix” instead of “Chapter.” It should also probably use an alpha numbering style instead of Roman.

You can use the method described above to handle as many alternate TOC entry types that you need in your book.