Paragraphs

Paragraphs are depicted with the <w:p> element. The optional <w:pPr> child element assigns a style to the paragraph by referencing. If no <w:pPr> element is applied, Word 2003 uses the standard style Normal.

<w:styles>
 ...
<w:style w:type="paragraph" w:styleId="berschrift1">               (1)
   <w:name w:val="heading 1"/>
   <wx:uiName wx:val="Überschrift 1"/>
   <w:basedOn w:val="Standard"/>
   <w:next w:val="Standard"/>
   <w:rsid w:val="008D1824"/>
   <w:pPr>
      <w:pStyle w:val="berschrift1"/>
      <w:keepNext/>
      <w:spacing w:before="240" w:after="60"/>
      <w:outlineLvl w:val="0"/>
   </w:pPr>
   <w:rPr>
      <w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/>
      <wx:font wx:val="Arial"/>
      <w:b/>
      <w:b-cs/>
      <w:kern w:val="32"/>
      <w:sz w:val="32"/>
      <w:sz-cs w:val="32"/>
   </w:rPr>
</w:style>
 ...
<w:p>
   <w:pPr>
      <w:pStyle w:val="berschrift1"/>                            (2)
   </w:pPr>
   <w:r>
      <w:t>Das ist eine Überschrift der ersten Ebene</w:t> 
           <!-- en: This is a headline of the first level -->
   </w:r>
</w:p>
<w:p>
   <w:r>
      <w:t>Dieser Absatz hat die Formatvorlage Standard</w:t>    (3)
           <!-- en: This paragraph has the Standard style -->          
   </w:r>
</w:p>

(1) The w:styleId attribute has as value an ID for the respective style. <wx:uiName> corresponds to the name of the style indicated in Word. This name often does not comply with the value of the ID because no umlauts, space characters and special characters are indicated. In our example, "Überschrift 1" (headline 1) becomes the ID value "berschrift1". The w:type attribute declares the type of the style whose paragraph value declares it as a paragraph style.

(2) The <w:pStyle> element is a child element of <w:pPr> and assigns a style to the paragraph via the attribute value of w:val.

(3) Paragraphs without an assigned style and without any further information on their properties by means of <w:pPr> are formatted with the Standard style.

image - paragraphs

Figure: paragraphs

Paragraph properties

The <w:pPr> element has a number of optional child elements which determine the paragraph properties in detail. In practice, these should not be used when generating stylesheets for the visualisation. It is easier and more manageable to assign the paragraph properties, if possible, by using styles.

Here, you can find all child elements of <w:pPr> in the DTD spelling:

(pStyle?, (keepNext | keepLines | pageBreakBefore | framePr | widowControl | 
  listPr | supressLineNumbers | pBdr | shd | tabs | suppressAutoHyphens | 
  kinsoku | wordWrap | overflowPunct | topLinePunct | autoSpaceDE | 
  autoSpaceDN | bidi | adjustRightInd | snapToGrid | spacing | ind | 
  contextualSpacing | suppressOverlap | jc | textDirection | 
  textAlignment | outlineLvl | divId | cnfStyle | rPr | sectPr |  
  aml:annotation)*)

Most of the permitted properties can be controlled via the "Absatzformular" (paragraph form). It  can be found under Format -> Absatz.

image - the controlling of the paragraph properties

Figure: the controlling of the paragraph properties

<w:p>
   <w:pPr>
      <w:keepNext/>                                 (1)
      <w:keepLines/>                                (2)
      <w:pageBreakBefore/>                          (3)
      <w:supressLineNumbers/>                       (4)
      <w:suppressAutoHyphens/>                      (5)
      <w:spacing w:before="360" w:after="240" w:line="600" w:line-rule="auto"/> (6)
      <w:ind w:left="624" w:right="340" w:first-line="709"/> (7)
      <w:jc w:val="left"/>                          (8) 
   </w:pPr>
   <w:r>
      <w:t>Beispielabsatz mit sehr vielen veränderten Absatzeigenschaften, 
           die nicht in der Formatvorlage vorgegeben sind.</w:t> 
           <!-- en: Example paragraph with a large number of modified paragraph properties
            being not predefined in the style. -->
   </w:r>
</w:p>
<w:p>
   <w:pPr>
      <w:spacing w:before="600" w:after="600"/>     (6)
   </w:pPr>
   <w:r>
      <w:t>Ein Folgeabsatz mit einem größeren Abstand zu den Nachbarabsätzen.</w:t>
           <!-- en: A subsequent paragraph with a greater distance to the neighboring paragraphs. -->
   </w:r>
</w:p>
<w:p>
   <w:pPr>
      <w:ind w:left="1701"/>                        (7)
   </w:pPr>
   <w:r>
      <w:t>Ein eingezogener Absatz.</w:t> 
           <!-- en: An indented paragraph. -->
   </w:r>
</w:p>
<w:p>
   <w:pPr>
      <w:shd w:val="clear" w:color="auto" w:fill="8C8C8C"/> (9)
   </w:pPr>
   <w:r>
      <w:t>Ein Absatz mit einer Hintergrundschattierung</w:t> 
           <!-- en: A paragraph with a background shading -->
   </w:r>
</w:p>

image - paragraph properties

Figure: paragraph properties

(1) The <w:keepNext> element prevents a page break between this and the following paragraph or object. It also may contain the w:val attribute which may be on or off and switches the connection with the next object on or off.

(2) <w:keepLines> prevents a page break within the paragraph. It may, as well as <w:keepNext>, contain the w:val attribute which may be on and off so that a possible page break for the respective paragraph can be allowed or prevented.

(3) <w:pageBreakBefore> enforces a page break before the paragraph. Here, also a w:val attribute which may be on and off is allowed so that a page break before the respective paragraph can be enforced or, where applicable, approved.

(4) <w:suppressLineNumbers> can deactivate the preset line numbering in a document. If the document has no line numbering, it will be ignored. It may contain the w:val attribute which may be on and off and so activates or deactivates the line numbering.

(5) <w:suppressAutoHyphens> deactivates the automatic hyphenation in a paragraph. It may contain the w:val attribute which may be on and off and so activates or deactivates the hyphenation function.

(6) <w:spacing> deals with the spaces before and after the paragraphs as well as between the lines of a paragraph. The w:before attribute defines the space before a paragraph in twips (twentieths of a point). Consequently, the 360 twips given in this example correspond to 18pt. The w:after attribute indicates the space after a paragraph in twips. The w:line attribute defines the line spacing in twips. The 600 twips indicated in this example are a conversion of the font size (12pt) multiplied by the line spacing (2.5-fold) by 20 (twips). Regarding the auto value, the w:line-rule attribute converts the spaces depending on the font sizes. If the exact value is used, the dimensions indicated in w:line would be, in each case, maintained.

(7) <w:ind> determines the indents of a paragraph. With the help of the w:left attribute, a left indent can be determined in twips; with the w:right attribute, a right and with the w:first-line attribute, a hanging indent can be created.

(8) With the help of the <w:jc> element, the alignment of a paragraph can be determined. The permitted values are: left, center (centered), right and both (justification).

(9) The <w:shd> element permits a background colour, the w:fill attribute determines this colour as a RGB hexadecimal value. The w:val attribute generates dotted backgrounds depending on the value. This feature is deactivated by the "clear" value. The background colour settings used in this example can be changed via the Formular Formate (format form) -> Rahmen und Schattierung (borders and shading).

image - borders and shading of paragraphs

Figure: borders and shading of paragraphs

A further possibility for the formatting of paragraphs is the assignment of inline formatting properties for the entire paragraph. In the following example, an actual inline formatting is assigned to a paragraph with the <w:rPr> element and later this is partially reversed. These and other inline formattings will be further discussed in the following chapter.

<w:p>
   <w:pPr>
      <w:rPr>
         <w:b />
      </w:rPr>
   </w:pPr>
   <w:r>
      <w:t>Absatz mit </w:t> 
          <!-- en: Paragraph with -->
   </w:r>
   <w:r>
      <w:rPr>
         <w:b w:val="off"/>
         <w:i/>
      </w:rPr>
      <w:t>inzeiligen</w:t> 
         <!-- inline -->
   </w:r>
   <w:r>
      <w:rPr>
         <w:b w:val="off"/>
      </w:rPr>
      <w:t> Eigenschaften </w:t>
           <!-- properties -->
   </w:r>
</w:p>

 

image - paragraph with inline properties

Figure: inline markup in the paragraph

<< back next >>

 


Copyright © dpunkt.verlag GmbH 2007
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "Professionelle XML-Verarbeitung mit Word" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo(at)dpunkt.de