跳到主要内容

AddHeadingCrossRef

向当前段落添加标题交叉引用。 💡 请注意,此段落必须在文档中。

语法

expression.AddHeadingCrossRef(sRefType, oParaTo, bLink, bAboveBelow);

expression - 表示 ApiParagraph 类的变量。

参数

名称必需/可选数据类型默认值描述
sRefType必需headingRefTo要插入的标题引用的文本或数值。
oParaTo必需ApiParagraph要引用的标题段落(必须在文档中)。
bLink可选booleantrue指定引用是否作为超链接插入。
bAboveBelow可选booleanfalse指定是否应包含表示引用位置的“上方/下方”字样(不与 “text” 和 “aboveBelow” sRefType 一起使用)。

返回值

boolean

示例

在文档的段落中插入对标题的交叉引用。

// How do I link paragraph text to an existing heading in a document?

// Let readers jump to a titled section by embedding a heading reference inside another paragraph in a document.

let doc = Api.GetDocument();
let newDocumentStyle = doc.GetStyle("Heading 1");
let paragraph = doc.GetElement(0);
paragraph.SetStyle(newDocumentStyle);
paragraph.AddText("Cross-reference method");
let headingParagraphs = doc.GetAllHeadingParagraphs();
paragraph = Api.CreateParagraph();
paragraph.AddText("Heading 1 style is applied to the heading ");
doc.Push(paragraph);
paragraph.AddHeadingCrossRef("text", headingParagraphs[0]);