Table of Contents
More Resources
Changing the Table of Contents
Table of Contents
Customize the Table of Contents in your PDF output.
Changing the Indent
Adjust the indentation of the Table of Contents.
Modifying the Header
Customize the header for the Table of Contents.
Table of Contents

Customize the Table of Contents in your PDF output.
You can customize the Table of Contents by Changing the Indent or Modifying the Header.
Changing the Indent

Adjust the indentation of the Table of Contents.
You want to edit the custom-attrs.xsl file (located in cfg/fo/attrs/) to modify the indentation of the Table of Contents.
  1. The default pdf2 output looks like this:

    Step Information

  2. The indentation of the Table of Contents (TOC) is set by the following formula:

    Step Information
    $side-col-width + (string($level - 1) * $toc.toc-indent) + $toc.text-indent
    $side-col-width is the width of the margins
    $level is the depth of the topicref

  3. However, due to a type in the pdf2 plugin, we need to edit the “__toc__topic__content” attribute set for these variables to work properly. Insert the following code into your custom-attrs.xsl file:

    Step Information
    < xsl:attribute-set name="__toc__topic__content"> 
      < xsl:attribute name="last-line-end-indent"> -22pt< /xsl:attribute> 
      < xsl:attribute name="end-indent"> 22pt< /xsl:attribute> 
      < xsl:attribute name="text-indent"> 
        < xsl:value-of select="$toc.text-indent"/> 
      < /xsl:attribute> 
      < xsl:attribute name="text-align"> start< /xsl:attribute> 
      < xsl:attribute name="text-align-last"> justify< /xsl:attribute> 
      < xsl:attribute name="font-size"> 
        < xsl:variable name="level" select="count(ancestor-or-self::*[contains(@class, ' topic/topic ')])"/> 
        < xsl:choose> 
          < xsl:when test="$level = 1"> 12pt< /xsl:when> 
          < xsl:otherwise> 
            < xsl:value-of select="$default-font-size"/> 
          < /xsl:otherwise> 
        < /xsl:choose> 
      < /xsl:attribute> 
      < xsl:attribute name="font-weight"> 
        < xsl:variable name="level" select="count(ancestor-or-self::*[contains(@class, ' topic/topic ')])"/> 
        < xsl:choose> 
          < xsl:when test="$level = 1"> bold< /xsl:when> 
          < xsl:otherwise> normal< /xsl:otherwise> 
        < /xsl:choose> 
      < /xsl:attribute> 
    < /xsl:attribute-set> 
    The only part of this code that is different from the default is bolded. The default sets text-indent to the inverse of the $toc.text-indent variable.
    Important:If you’ve already copied over the __toc__topic__content attribute set for another customization, all you have to do is overwrite the “text-indent” attribute with the text in bold above.

  4. Now, by changing $toc.text-indent, we can adjust the absolute indent of the title and by changing $toc.toc-indent, we can adjust the indent of the title relative to its level (or relative to the TOC entry above it).
  5. To change the variables, use the following syntax:

    Step Information
    < xsl:variable name="[variable.name]" select="[variable.value]"/> 

    Example
    To create the following indentation,
    Use the following code:
    < xsl:variable name="toc.toc-indent" select="'0pt'"/> 
    < xsl:variable name="toc.text-indent" select="'0pt'"/> 

    Example
    To create the following indentation,
    Use the following code:
    < xsl:variable name="toc.toc-indent" select="'0pt'"/> 
    < xsl:variable name="toc.text-indent" select="'30pt'"/> 

    Example
    To create the following indentation,
    Use the following code:
    < xsl:variable name="toc.toc-indent" select="'30pt'"/> 
    < xsl:variable name="toc.text-indent" select="'30pt'"/> 

    Example
    To create the following indentation,
    Use the following code:
    < xsl:variable name="toc.toc-indent" select="'30pt'"/> 
    < xsl:variable name="toc.text-indent" select="'0pt'"/> 

You changed the indentation of the Table of Contents.
Modifying the Header

Customize the header for the Table of Contents.
You want to edit the custom-attrs.xsl file (located in cfg/fo/attrs/) to modify the default header for the Table of Contents.
    Changing the Header Text
  1. Open the en.xml file located in cfg/common/vars.

    Step Information

    The default header for the Table of Contents is “Contents”

    It uses the following code:
    < !-- The heading string to put at the top of the Table of Contents --> 
    < variable id="Table of Contents"> Contents< /variable> 
    Note:If you have the default ex.xml copied from pdf2, the “Table of Contents” variable is located on line 124.
  2. To change the header text, modify the elements within the Table of Contents variable:

    Expected Result
    < !-- The heading string to put at the top of the Table of Contents --> 
    < variable id="Table of Contents"> The TOC< /variable> 

  3. Modifying the Header Styling
  4. Open the custom-attrs.xsl.

    Step Information
    The default attribute set used for the Table of Contents header is the following:

  5. To can change the styling of the header, copy and paste the default attribute set for the Table of Conents header into the custom-attrs.xsl file.

    Step Information
    < xsl:attribute-set name="__toc__header" use-attribute-sets="common.title"> 
      < xsl:attribute name="space-before"> 0pt< /xsl:attribute> 
      < xsl:attribute name="space-after"> 16.8pt< /xsl:attribute> 
      < xsl:attribute name="font-size"> 20pt< /xsl:attribute> 
      < xsl:attribute name="font-weight"> bold< /xsl:attribute> 
      < xsl:attribute name="padding-top"> 16.8pt< /xsl:attribute> 
    < /xsl:attribute-set> 

  6. Modify any of the attributes to customize the header styling.

    Example
    The create the following header styling,
    Use the following code:
    < xsl:attribute-set name="__toc__header" use-attribute-sets="common.title"> 
      < xsl:attribute name="space-before"> 0pt< /xsl:attribute> 
      < xsl:attribute name="space-after"> 16.8pt< /xsl:attribute> 
      < xsl:attribute name="font-size"> 20pt< /xsl:attribute> 
      < xsl:attribute name="font-weight"> normal< /xsl:attribute> 
      < xsl:attribute name="padding-top"> 16.8pt< /xsl:attribute> 
      < xsl:attribute name="text-align"> center< /xsl:attribute> 
      < xsl:attribute name="color"> red< /xsl:attribute> 
    < /xsl:attribute-set> 

The Table of Contents header is modified.