A section is a stretch of a document with its own page setup, headers and footers. Its
properties are in a w:sectPr. Every section but the last ends with a paragraph
that has w:sectPr in its w:pPr; the properties of the last section
are the last child of w:body.
Section properties: w:sectPr
<w:sectPr>
<w:headerReference w:type="default" r:id="rId7"/>
<w:footerReference w:type="default" r:id="rId8"/>
<w:pgSz w:w="11906" w:h="16838"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"
w:header="708" w:footer="708" w:gutter="0"/>
<w:cols w:space="708"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
| Element | Meaning |
|---|---|
w:headerReference, w:footerReference | A header or footer part, by relationship ID, with w:type default, first or even. |
w:type | How the section starts: nextPage (the default), continuous, evenPage, oddPage or nextColumn. |
w:pgSz | Page size in twips: w:w, w:h, and w:orient for landscape. |
w:pgMar | Margins, and the distance of the header and footer from the page edge. |
w:cols | Newspaper columns: w:num, w:space, or one w:col each. |
w:pgNumType | Page numbering: format and starting number. |
w:titlePg | The first page of the section has its own header and footer (the first type). |
w:footnotePr, w:endnotePr | Note properties for the section. |
w:lnNumType | Line numbering. |
w:docGrid | The document grid. |
w:sectPrChange | The previous properties, under tracked changes. |
Header and footer parts
Each header is a part with the root w:hdr, and each footer one with the root
w:ftr, usually named word/header1.xml,
word/footer1.xml and so on. The root holds block-level content, as the body
does. It can use its own relationships for pictures and links.
<w:hdr xmlns:w="…">
<w:p>
<w:pPr><w:pStyle w:val="Header"/></w:pPr>
<w:r><w:t>Annual report</w:t></w:r>
</w:p>
</w:hdr>
Which header is used
In each section:
- The
defaultheader applies to ordinary pages. - With
w:titlePg, the first page uses thefirstheader. - With
w:evenAndOddHeadersinword/settings.xml, even-numbered pages use theevenheader and odd pages thedefaultone.
A section with no reference of a type continues the header of that type from the section before.