Heading 3 is not indenting properly

When switching to heading 3 using StyleIdentifier, the table of contents numbers that are generated to the left of the heading no longer indent with the heading, causing it to be truncated in print view. I did not implement any formatting difference other than the heading style. I desire 13.1.1 to match 13.1 and 13’s indentation.

Screenshot 2022-07-07 124252.png (3.7 KB)

I would greatly appreciate any recommendations!

@SethD02 Could you please attach your problematic document here for testing? We will check the issue and provide you more information.

Test Doc.docx (13.7 KB)

@SethD02 Could you please also provide the code you use to switch the heading style and the source document?

The code is actually used to generate a document rather than editing a source doc, the code looks like this

Document.ParagraphFormat.StyleIdentifier = ParagraphFormat.StyleIdentifier.Heading3
Document.Writeln("Heading 3")

@SethD02 Unfortunately it is still not clear how you apply numbering. If you create a document from scratch, you can specify numbering to the styles itself. See the following code for example:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Apply numbering to Heading styles
List lst = doc.Lists.Add(ListTemplate.OutlineLegal);
doc.Styles[StyleIdentifier.Heading1].ListFormat.List = lst;
doc.Styles[StyleIdentifier.Heading1].ListFormat.ListLevelNumber = 0;
doc.Styles[StyleIdentifier.Heading2].ListFormat.List = lst;
doc.Styles[StyleIdentifier.Heading2].ListFormat.ListLevelNumber = 1;
doc.Styles[StyleIdentifier.Heading3].ListFormat.List = lst;
doc.Styles[StyleIdentifier.Heading3].ListFormat.ListLevelNumber = 2;

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
builder.Writeln("Heading 3");
builder.ParagraphFormat.ClearFormatting();
builder.Write("Some normal content");

doc.Save(@"C:\Temp\out.docx");

Hmm I actually never used ListFormat to create this list, hopefully that will help.
How do I use the doc.Styles[StyleIdentifier.Heading1].ListFormat.List in vb.net? Unfortunately, we don’t use C# and it’s very difficult to find visual basic documentation.

@SethD02 Here is the same code in VB:

Dim doc As Document = New Document()
Dim builder As DocumentBuilder = New DocumentBuilder(doc)

' Apply numbering to Heading styles
Dim lst As Aspose.Words.Lists.List = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.OutlineLegal)
doc.Styles(StyleIdentifier.Heading1).ListFormat.List = lst
doc.Styles(StyleIdentifier.Heading1).ListFormat.ListLevelNumber = 0
doc.Styles(StyleIdentifier.Heading2).ListFormat.List = lst
doc.Styles(StyleIdentifier.Heading2).ListFormat.ListLevelNumber = 1
doc.Styles(StyleIdentifier.Heading3).ListFormat.List = lst
doc.Styles(StyleIdentifier.Heading3).ListFormat.ListLevelNumber = 2

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1
builder.Writeln("Heading 1")
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2
builder.Writeln("Heading 2")
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3
builder.Writeln("Heading 3")
builder.ParagraphFormat.ClearFormatting()
builder.Write("Some normal content")

doc.Save("C:\Temp\out.docx")

I apologize in advance that this has proved so difficult and am very grateful for all of your help so far. So I copied your code exactly, but unfortunately all that changed is the indentation of the actual text, and the numbering issue for heading 3 remains the same. My goal is to have none of the headings indented and the numbering formatted the same as heading 1 and 2.
Test Doc2.docx (17.1 KB)

@SethD02 Could you please create a simple console application that will allow us to reproduce the problem? We will check your code an template and provide you more information.