We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Too many items in TOC based on styles

Hi there!

I’m having a problem with my Table Of Content based on Styles.

In TOC properties, I’ve set a custom style (HeadingTOC) as the first level (photo as attachment).

Here’s the document field:

{ TOC \h \z \t

In documents after the toc, some titles are set to “Heading 1” some are set to “Heading TOC” (see toc.jpg attachment). I only want “HeadingTOC” Items to appear in the table of content.

The problem is that Heading 1 items are also added to the toc (until I manually update it).
Is there a way to avoid having heading 1 items in the toc?

NOTE: the “heading 1” items are in “IF” field. If I don’t use IF field, everything seems to be OK.

I’ve attached a sample project (TOC.zip).
Thank you once again and have a nice day,


Hi JSr,

Thanks for your inquiry. In your case, I suggest you please update the TOC field code as shown below:

{ TOC \h \z \t “HeadingTOC,1” }

If you edit TOC field by using MS Word, the print preview is not for HeadingTOC. Please see the attached image (TOC-Field.png). I have modified TOC field for both Heading 1 and HeadingTOC in TOC.docx. Please see the attached image (modified-TOC.png). You can only use HeadingTOC in your TOC field by changing TOC field to { TOC \h \z \t “HeadingTOC,1” }.

I would suggest you please upgrade to latest version of Aspose.Words for .NET 13.1.0 from here:

Hope this answers your query. Please let us know if you have any more queries.