Many thanks to Jialiang Ge at Microsoft for this.
First, to get the final state of any property (including indents), we need to follow the style hierarchy rules in §2.7.2 of the specification
- There, it correctly states that the direct formatting (the pPr under the p element) supersedes the version in the list definition
- Since tab stops are additive, we just gather them all up and we have the full set of tab stops
- If there is a <w:tab val="clear" ...=""> then that tab is cleared and not only does not count as a tab, but clears out any parent tabs (style, list) that are at the same position.</w:tab>
Now, we display the list as follows:
- First, check the numFmt element §2.9.18 to see the format of any numbers in the list definition.
- Next, place the text in the lvlText element §2.9.12 at the location of the final left indent.
- If the numFmt isn't "bullet", we need to replace the %[1-9] syntax appropriately.
Now, look at the suff element §2.9.30 to see what separates the bullet from the text.
- If it's space or nothing, add a space or nothing.
- If it's tab, add a tab. (Note: this is the default if suff is not set!)
- Then we just need to know what the next tab stop is.
- For that, any tab stop after the end of the displayed level text is valid:
- Tabs set with the tab element
- Any hanging indent (as long as the doNotUseIndentAsNumberingTabStop element §18.104.22.168 is not set)
- Default tab stops at the distances set by the defaultTabStop element §22.214.171.124
Finally, we justify the result – from start of the level text to end of the line. You justify now so that it's always relative to the same tab stops.
One more thing - the use hanging tab only occurs in Word 2007+ (ie 2007, 2010 & later) - and it's the default in 2007+ which makes it sort of weird:
- For Word xml file, the default behavior of Word 2003 and 2007+ is to omit the virtual hanging tab (If Word 2007+, we have an option to make Word enable the hanging tab)
- For normal Word 2003 doc files opened in Word 2003, the virtual hanging tab is always omitted.
- For normal Word 2003 doc files opened in Word 2007+, Word 2007+ will automatically set the option "Don't use hanging indent as tab stop for bullets and numbering" selected, and omit the hanging indention.
- For normal Word 2007+ docx files opened in Word 2007+, Word 2007+ will use hanging indent as tab top for bullets and numbering by default.
- For normal Word 2007+ docx files opened in Word 2003, Word 2003 will omit the virtual hanging tab, and therefore, may misaligned the document. (see KB http://support.microsoft.com/kb/937936)
But there is another caveat on the virtual hanging indent - in RTF/DOC/WordML (note this rule does not apply to DOCX) the virtual hanging indent tab stop is used - if and only if - there are no tab stops set in the list, paragraph, or styles (list/paragraph style) after the virtual position.
If you've just discovered us, we're excited. Know more about Windward and get your 14-day free trial and start creating documents in quick time with our low/no code solutions.