Skip to main content
A newer version of this page is available. .

How to: Create TOC for Special Cases

  • 3 minutes to read

A table of contents (TOC) in a document is represented by a special TOC field. RichEditControl provides a set of TOC field switches that you can combine to create TOCs of different types. This document describes how to create the following TOCs.

TOC for the Specified Portion of a Document

To generate a TOC collecting titles (marked with built-in heading styles) from the specified portion of a document only, follow the steps below.

  1. Mark entries to be included in the TOC by using built-in heading styles (Heading 1, Heading 2, etc.).
  2. Mark a portion of a document whose headings you want to include in the TOC with the “Chapter1” bookmark.
  3. Insert a TOC field and use the \b switch with the bookmark name: {TOC \b Chapter1}.

TOC Including Paragraphs with Specified Outline Levels Only

To generate a TOC from Heading 1, Heading 2 and Heading 3 entries only (or paragraphs with outline levels 1 through 3), use the \o switch in the TOC field code.

{TOC} {TOC \o “1-3”}
DXRichEdit_TOC_Field_Default DXRichEdit_TOC_O_Switch

Table of Figures (Tables, Equations)

The following step-by-step instruction describes how to create a TOC from items numbered by a SEQ field (for example, table of figures), add sequence numbers (figure numbers) before page numbers in the table of contents and specify the separator between sequence and page numbers.

  1. Specify captions for figures that you want to include in the table of figures. To do this, click the Insert Caption button in the Captions ribbon page group on the References tab (Ribbon UI) or Captions toolbar (Bar UI) and select Figures Caption

    DXRichEdit_InsertFigureCaptions

    … or add the {SEQ Figure} field code in one of the available ways -using CTRL+F9, CreateFieldCommand, InsertFieldCommand, or FieldCollection.Create (for details, refer to How to: Insert a Field to a Document).

  2. Click where you want to insert the table of figures.
  3. In the Captions ribbon page group on the References tab (Ribbon UI) or Captions toolbar (Bar UI), click Insert Table of Figures and select Table of Figures.

    If you right-click the newly created table of figures and select Toggle Field Codes from the context menu or click the Show All Field Codes button on the Preview Results ribbon page group or toolbar, you will see the TOC field code - { TOC \h \c “Figure” }. The \c switch is used to build a TOC from items that are numbered by a SEQ field.

  4. To add figure numbers before page numbers in the table of figures and insert the => separator between figure and page numbers, use the s and d switches of the TOC field - { TOC \h \c “Figure” \s Figure \d => }.
  5. Resulting table of figures will look like the following.

    DXRichEdit_TableOfFigures_Result

In the same way you can sequentially number tables and equations in a document, and built a table of tables or equations.

Note

If you add, remove or modify captions, you can quickly update the table of figures by using the Update Table button in the Captions ribbon page group on the References tab (Ribbon UI) or Captions toolbar, by selecting the Update Field from the context menu, or clicking the TOC and pressing F9.

See Also