SpacingBetweenLines class

Office 2013 and later

Defines the SpacingBetweenLines Class. When the object is serialized out as xml, its qualified name is w:spacing.

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlLeafElement
      DocumentFormat.OpenXml.Wordprocessing.SpacingBetweenLines

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

public class SpacingBetweenLines : OpenXmlLeafElement

[ISO/IEC 29500-1 1st Edition]

spacing (Spacing Between Lines and Above/Below Paragraph)

This element specifies the inter-line and inter-paragraph spacing which shall be applied to the contents of this paragraph when it is displayed by a consumer.

If this element is omitted on a given paragraph, each of its values is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then the paragraph shall have no spacing applied to its lines, or above and below its contents.

[Example: Consider the following WordprocessingML paragraph:

<w:pPr>
  <w:spacing w:after="200" w:line="276" w:lineRule="auto" /> 
</w:pPr>

This paragraph specifies that it must have at least 200 twentieths of a point after the last line in each paragraph, and that the spacing in each line should be automatically calculated based on a 1.15 times (276 divided by 240) the normal single spacing calculation. end example]

When determining the spacing between any two paragraphs, a consumer shall use the maximum of the inter-line spacing in each paragraph, the spacing after the first paragraph and the spacing before the second paragraph to determine the net spacing between the paragraphs.

[Example: Consider two consecutive single-spaced paragraphs in a document, the first of which specifies spacing below of 12 points, the second of which specifies spacing above of 4 points. These constraints are expressed using the following WordprocessingML:

<w:p>
  <w:pPr>
    <w:spacing w:after="240" /> 
  </w:pPr>
  …
</w:p>
<w:p>
  <w:pPr>
    <w:spacing w:before="80" /> 
  </w:pPr>
  …
</w:p>

The resulting spacing between the first and second paragraph is 12 points, since that is the largest spacing requested between the two paragraphs. end example]

Parent Elements

pPr (§17.3.1.26); pPr (§17.3.1.25); pPr (§17.7.5.2); pPr (§17.7.6.1); pPr (§17.9.23); pPr (§17.7.8.2)

Attributes

Description

after (Spacing Below Paragraph)

Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then the paragraph shall have no spacing applied below its contents.

If the afterLines attribute or the afterAutoSpacing attribute is also specified, then this attribute value is ignored.

[Example: Consider the following WordprocessingML paragraph:

<w:p>
  <w:pPr>
    <w:spacing w:after="240" /> 
  </w:pPr>
  …
</w:p>

This paragraph must have a minimum spacing below its final lines of 240 twentieths of a point, although the actual spacing can be determined by the inter-line spacing or the spacing above the following paragraph, if either are greater. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

afterAutospacing (Automatically Determine Spacing Below Paragraph)

Specifies whether a consumer shall automatically determine the spacing after this paragraph based on its contents.

This automatic spacing shall match the spacing which would be applied to the paragraph in an HTML document where no explicit spacing before/after is specified.

If this attribute is specified, then any value in after or afterLines is ignored, and the spacing is automatically determined by the consumer.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then automatic spacing is turned off (not applied).

[Example: Consider a paragraph in a document whose spacing below must automatically be determined by the consumer based on the paragraph's contents. This constraint would be specified by the following WordprocessingML:

<w:pPr>
  <w:spacing … w:afterAutospacing="on" />
</w:pPr>

The resulting paragraph must have the spacing below its last line determined automatically by the consumer to match an HTML document as specified. end example]

The possible values for this attribute are defined by the ST_OnOff simple type (§22.9.2.7).

afterLines (Spacing Below Paragraph in Line Units)

Specifies the spacing that should be added after the last line in this paragraph in the document in line units.

The value of this attribute is specified in one hundredths of a line.

If the afterAutoSpacing attribute is also specified, then this attribute value is ignored. If this setting is never specified in the style hierarchy, then its value shall be zero (if needed).

[Example: Consider the following WordprocessingML paragraph:

<w:p>
  <w:pPr>
    <w:spacing w:afterLines="300" /> 
  </w:pPr>
  …
</w:p>

This paragraph must have a minimum spacing below its final lines of 3 lines, although the actual spacing can be determined by the inter-line spacing or the spacing above the following paragraph, if either are greater. end example]

The possible values for this attribute are defined by the ST_DecimalNumber simple type (§17.18.10).

before (Spacing Above Paragraph)

Specifies the spacing that should be added above the first line in this paragraph in the document in absolute units.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then the paragraph shall have no spacing applied above its contents.

If the beforeLines attribute or the beforeAutoSpacing attribute is also specified, then this attribute value is ignored.

[Example: Consider the following WordprocessingML paragraph:

<w:p>
  <w:pPr>
    <w:spacing w:before="80" /> 
  </w:pPr>
  …
</w:p>

This paragraph must have a minimum spacing above its first line of 80 twentieths of a point, although the actual spacing can be determined by the inter-line spacing or the spacing below the last line in the preceding paragraph, if either are greater. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

beforeAutospacing (Automatically Determine Spacing Above Paragraph)

Specifies whether a consumer shall automatically determine the spacing before this paragraph based on its contents.

This automatic spacing shall match the spacing which would be applied to the paragraph in an HTML document where no explicit spacing before/after is specified.

If this attribute is specified, then any value in before or beforeLines is ignored, and the spacing is automatically determined by the consumer.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then automatic spacing is turned off (not applied).

[Example: Consider a paragraph in a document whose spacing above must automatically be determined by the consumer based on the paragraph's contents. This constraint would be specified by the following WordprocessingML:

<w:pPr>
  <w:spacing … w:beforeAutospacing="on" />
</w:pPr>

The resulting paragraph must have the spacing above its first line determined automatically by the consumer to match an HTML document as specified. end example]

The possible values for this attribute are defined by the ST_OnOff simple type (§22.9.2.7).

beforeLines (Spacing Above Paragraph IN Line Units)

Specifies the spacing that should be added before the first line in this paragraph in the document in line units.

The value of this attribute is specified in one hundredths of a line.

If the beforeAutoSpacing attribute is also specified, then this attribute value is ignored. If this setting is never specified in the style hierarchy, then its value shall be zero (if needed).

[Example: Consider the following WordprocessingML paragraph:

<w:p>
  <w:pPr>
    <w:spacing w:beforeLines="100" /> 
  </w:pPr>
  …
</w:p>

This paragraph must have a minimum spacing above its first line of 1 line, although the actual spacing can be determined by the inter-line spacing or the spacing below the preceding paragraph, if either are greater. end example]

The possible values for this attribute are defined by the ST_DecimalNumber simple type (§17.18.10).

line (Spacing Between Lines in Paragraph)

This attribute specifies the amount of vertical spacing between lines of text within this paragraph.

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then no line spacing shall be applied to lines within this paragraph.

If the value of the lineRule attribute is either atLeast or exactly, then the value of this attribute shall be interpreted as twentieths of a point. When the value of the lineRule attribute is either exactly, the text shall be positioned as follows within that line height:

  • When the line height is too small, the text shall be positioned at the bottom of the line (i.e. clipped from the top down)

  • When the line height is too large, the text shall be centered in the available space.

If the value of the lineRule attribute is auto, then the value of the line attribute shall be interpreted as 240ths of a line, in the manner described by the simple type's values.

[Example: Consider the following WordprocessingML paragraph which should have an inter-line spacing of 1.15 times the line height. This constraint would be specified using the following WordprocessingML:

<w:pPr>
  <w:spacing w:line="276" w:lineRule="auto" />
</w:pPr>

The lineRule attribute value of auto specifies that the value of the line attribute is to be interpreted in 240ths of a single line height, which means that the net spacing is 276/240ths of a line or 1.15 lines tall. end example]

The possible values for this attribute are defined by the ST_SignedTwipsMeasure simple type (§17.18.81).

lineRule (Spacing Between Lines)

Specifies how the spacing between lines is calculated as stored in the line attribute.

If this attribute is omitted, then it shall be assumed to be of a value auto if a line attribute value is present.

If the value of this attribute is either atLeast or exactly, then the value of the line attribute shall be interpreted as twentieths of a point, in the manner described by the simple type's values.

If the value of this attribute is auto, then the value of the line attribute shall be interpreted as 240ths of a line, in the manner described by the simple type's values.

[Example: Consider the following WordprocessingML paragraph which should have an inter-line spacing of 1.15 times the line height. This constraint would be specified using the following WordprocessingML:

<w:pPr>
  <w:spacing w:line="276" w:lineRule="auto" />
</w:pPr>

The lineRule attribute value of auto specifies that the value of the line attribute is to be interpreted in 240ths of a single line height. end example]

The possible values for this attribute are defined by the ST_LineSpacingRule simple type (§17.18.48).

[Note: The W3C XML Schema definition of this element’s content model (CT_Spacing) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: