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

Free Support Forum - aspose.com

Insert LineBreaks in TOC fields

hi,
how can i use linebreaks (with additional fontchanges) in toc-fields so that it looks like this (also see attachment)
Heading1
Heading2.0
2nd line of Heading2.0…2
Heading2.1
2nd line of Heading2.1…3

Hi
Thanks for your inquiry. As I can see you have edited TOC manually in the attached document. Unfortunately Aspose.Words does not evaluate TOC fields. So you can’t edit TOC using Aspose.Words. Also if you update you TOC additional line breaks and formatting will disappear.
If you need change formatting of TOC you should change TOC style. For example see the following code:

// Change formating of TOC
doc.Styles[StyleIdentifier.Toc1].Font.Bold = true;
doc.Styles[StyleIdentifier.Toc2].Font.Italic = true;
// etc...

After creating TOC using Aspose.Words you should update fields inside the document manually (ctrl+A and F9). Also you can use macro to update fields. See the following link to learn more.
https://support.microsoft.com/en-us/topic/the-filename-field-does-not-automatically-update-when-you-open-a-document-in-word-de2bfb95-d990-1ced-a618-5ac0a2ec1be4
Best regards.