关于问题的第一部分,重要的是要了解有时可以使用不同的 Open XML 标记来实现相同的效果。仅仅因为 Microsoft Word 以某种方式生成标记并不意味着您的方式是错误的,只要您的方式符合标准即可。
增强我原来的答案,这是一个如何在不重复的情况下重新开始编号的示例w:abstractNum
元素,大致使用问题中提供的文本:
Unnumbered text before first list.
1. Item 1
2. Item 2
Unnumbered text before second list.
1. Item 3 (restarted)
2. Item 4
我们看一下对应的主文档部分(document.xml
),注意到我已经简化了 Microsoft Word 创建的标记:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
<w:r>
<w:t>Unnumbered text before first list.</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 1</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 2</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>Unnumbered text before second list.</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="2"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 3 (restarted)</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="2"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 4</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
您会注意到,这两个列表在其列表中引用了两个编号 ID(1 和 2)w:numId
元素。
接下来,这是相应的编号定义部分(numbering.xml
):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="w15">
<!-- This is the only w:abstractNum element in numbering.xml -->
<w:abstractNum w:abstractNumId="0" w15:restartNumberingAfterBreak="0">
<w:nsid w:val="23B5103A"/>
<w:multiLevelType w:val="hybridMultilevel"/>
<w:tmpl w:val="40963B22"/>
<!-- The following w:lvl is referenced by w:ilvl with w:val="0" -->
<w:lvl w:ilvl="0" w:tplc="0409000F">
<w:start w:val="1"/>
<w:numFmt w:val="decimal"/>
<w:lvlText w:val="%1."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="720" w:hanging="360"/>
</w:pPr>
</w:lvl>
<!-- Markup for numbering levels 1-7 removed -->
<w:lvl w:ilvl="8" w:tplc="0409001B" w:tentative="1">
<!-- Child elements removed -->
</w:lvl>
</w:abstractNum>
<!-- The following w:num is referenced by the w:numId with w:val="1" -->
<w:num w:numId="1">
<w:abstractNumId w:val="0"/>
</w:num>
<!-- The following w:num is referenced by the w:numId with w:val="2" -->
<w:num w:numId="2">
<w:abstractNumId w:val="0"/>
<!-- The w:lvlOverride with its w:startOverride child restarts numbering -->
<w:lvlOverride w:ilvl="0">
<w:startOverride w:val="1"/>
</w:lvlOverride>
<!-- You can also override levels 1 to 8 in the same way, if required -->
</w:num>
</w:numbering>
可以看到这里只使用了一个w:abstractNum
由两个“w:num”元素引用,其中之一通过重新开始编号来覆盖至少一层。
关于你问题的第二部分,如果你想模仿 Microsoft Word 的行为,w:nsid
元素(抽象编号定义标识符)只是一个以长十六进制数字表示的唯一数字。该标准没有明确说明应该如何创建它。因此,例如,您几乎可以获取任何尚未被任何人使用的数字w:abstractNum
元素。