Table of Contents
More Resources
Changing the Indent

Adjust the indentation of the Table of Contents.
context

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'"/> 

result

You changed the indentation of the Table of Contents.