You are here: CTSPedia>System Web>Macros>VarTOC (09 Jan 2009, ProjectContributor?)EditAttach
create new tag
, view all tags, tagging instructions

TOC{"Topic"} -- table of contents

  • Table of Contents. Shows a TOC that is generated automatically based on headings of a topic. Headings in WikiSyntax ("---++ text") and HTML ("<h2>text</h2>") are taken into account. Any heading text after "!!" is excluded from the TOC; for example, write "---+!! text" if you do not want to list a header in the TOC
  • Syntax: %TOC% OR %TOC{"SomeTopic" ...}%
  • Supported parameters:
    Parameter: Description: Default:
    "TopicName" topic name Current topic
    web="Name" Name of web Current web
    depth="2" Limit depth of headings shown in TOC 6
    title="Some text" Title to appear at top of TOC none
  • Example: %TOC{depth="2"}%
  • Example: %TOC{"CompleteDocumentation" web="System" title="Contents:"}%
  • Example: see Foswiki:Sandbox.TestTopicInclude
  • TIP TOC will generate links to the headings, so when a reader clicks on a heading it will jump straight where that heading is anchored in the text. If you have two headings with exactly the same text, then their anchors will also be identical and they won't be able to jump to them. To make the anchors unique, you can add an invisible HTML comment to the text of the heading. This will be hidden in normal view, but will force the anchors to be different. For example, ---+ Heading <!--5-->.
  • TIP TOC will add an HTML anchor called foswikiTOC just before the table of contents. This enables adding a link from within a topic back to the table of contents to ease navigation. Example [[#foswikiTOC][Back to TOC]] creates Back to TOC.
  • TIP If multiple headers have the exact same text, the anchors for the 2nd, 3rd etc will be suffixed by _AN1, _AN2 etc so the anchors become unique.
Topic revision: r1 - 09 Jan 2009 - 06:00:00 - ProjectContributor?
This site is powered by FoswikiCopyright & by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding CTSPedia? Send feedback