1. In the Home tab, you must use Styles to be consistent in the document to create its structure.You should put the cursor at the position where you want to insert word insert table of contents with links, and then click References> Table of Contents> Custom Table of Contents. 2. In ...
7 document.InsertTableOfContents("目录", TableOfContentsSwitches.O | TableOfContentsSwitches.U | TableOfContentsSwitches.Z | TableOfContentsSwitches.H, "Heading2"); 8 var h1 = document.InsertParagraph("Heading 1"); 9 h1.StyleName = "Heading1"; 10 document.InsertParagraph("Some very interes...
使用DocumentBuilder.InsertTableOfContents(“ \\ o \” 1-3 \“ \\ h \\ z \\ u”)方法插入目录。 使用Document.UpdateFields()方法更新字段。 使用Document.Save(String)方法保存Word文档。 下面的代码示例演示如何在C#中的Word文档中添加目录。 // The path to the documents directory. string dataDir ...
A table of contents (Figure 1),abbreviated informally as TOC, is a technique for locating relevant information or content in a document. According to the World Wide Web Consortium (W3C), TOC serves two purposes:●It gives ...
// Load the Word document Document doc = new Document("Word.docx"); // Create a document builder DocumentBuilder builder = new DocumentBuilder(doc); // Insert a table of contents at the beginning of the document. builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u"); ...
When you’ve formatted your document with headers, you’re ready to insert a table of contents. Follow these steps: Click the section of the document where you want to create the table of contents. If you’d like it to appear on its own page, insert a page break (Ctrl+Enter or Shift...
Insert Table of Contents Field To use outline levels to create a table of contents, follow these steps. To insert a TOC field: Start Word, and then open your document. Click an empty paragraph where you want to insert the table of contents. On the Insert menu, point to Reference, an...
If you’re using Styles in your Microsoft Word document, you can insert an automatic Table of Contents with just a few clicks.
// Insert this instead: + if (settings == null ) + { + using (TextReader tr = new StreamReader(settingsPart.GetStream())) + settings = XDocument.Load(tr); + } Use these lines to use the new option: docx.UpdateFieldsOnOpen(); ...
Repeat steps 1 through 7 of this procedure for each table of contents entry in your document. Method 2: How to use the keyboard Select the word or words that you want to include as a table of contents entry. Press ALT+SHIFT+O.