How do I suppress the table of contents?

1015 views
Skip to first unread message

lindelof

unread,
Jun 9, 2009, 8:41:28 AM6/9/09
to asciidoc
I would like to write a very short document with asciidoc, published
as PDF via FOP.

My problem is that the resulting PDF always has a table of contents
under the title, which doen't look good on such a short document (2
pages max). How can I avoid the generation of this table of contents?

Thanks in advance,

David

Henrik

unread,
Jun 10, 2009, 7:42:02 PM6/10/09
to asciidoc
This can be done with some customization of the XSL stylesheets. The
generation of the TOC is not a function of AsciiDoc but the DocBook
processor.

The docbook-XSL parameter generate.toc controls what gets a toc and
what not. Here is the documentation and some examples:
http://www.sagehill.net/docbookxsl/TOCcontrol.html

To turn it of for articles include this to your stylesheet:

<xsl:param name="generate.toc" select="'article nop'"/>

As an example I added some customation to my XSL stylesheets to
include a TOC in articles only if the macro :toc: is present in the
AsciiDoc document.

How can this be done? Here is the recipe:

1) Add this to your XSL stylesheet:

<xsl:param name="generate.toc">
<xsl:choose>
<xsl:when test="/article/articleinfo/processing-instruction
('inserttoc')">
/article toc,title
</xsl:when>
<xsl:otherwise>
/article nop
</xsl:otherwise>
</xsl:choose>
</xsl:param>

2) Add this to the [header] section of asciidoc.conf after the
<copyright>...</copyright> tags:

{toc#}<?inserttoc?>

What 2) does is it inserts a custom processing instruction if the toc
macro is defined. The stylesheet in 1) checks for the presence of the
inserttoc processing instruction and inserts a toc or not.

Stuart Rackham

unread,
Jun 13, 2009, 7:29:48 PM6/13/09
to asci...@googlegroups.com
Thanks Henrik, I've patched the trunk with your code:
http://hg.sharesource.org/asciidoc/rev/2763dc053e6a

If you have a moment could you review the changes.

Cheers, Stuart
Reply all
Reply to author
Forward
0 new messages