创建与 Microsoft Word 兼容的 RTF 标题

Creating RTF headings compatible with Microsoft Word

我正在制作一个脚本来创建 RTF 文档并想要添加 table 的内容。我选择了这个:

{\field\flddirty\fldedit{\*\fldinst TOC}{\fldrslt \i Use this page to add the table of contents, right click to update field \i0}}

用户将在 Microsoft Word 中打开 RTF 并更新字段。但是,我不确定如何格式化我的 RTF 代码中的部分以创建标题,以便当我在 Word 中更新我的目录时它会显示这些部分。现在,当我 "update field" 时,我只会得到 "No tables of contents entries found"

我已经尝试过 {\tc My heading here},但没有成功。

是否有一些代码可以插入到我的 RTF 中,将我的文本格式设置为 headers,以便在 Word 中进行 TOC 格式设置?

我已经找到解决问题的方法了。在 Microsoft Word 中,为了让 {\tc Heading here } 出现在您的 table 内容中,您必须包含 Table 输入字段。要将其合并到您的 RTF 代码中,请使用 {\*\fldinst TOC \o \h \f} 而不是 {\*\fldinst TOC} \h 启用 HTML 链接,并使用 \f 启用 table 输入字段。现在,当您更新该字段时,您的 {\tc Heading here } 将出现在 table 的内容中。

这篇文章帮助了我:https://support.office.com/en-ca/article/Table-of-Contents-III-Use-fields-to-create-a-TOC-and-create-multiple-TOCs-f1509cfe-b48f-4ac5-8241-89a6619d7d6f