Multi-column pages

XSL-FO allows us to define a page which has multiple columns. This can only be done for whole pages, not for partial pages. However if we are in a region which has multiple columns we can treat it as a single-column region and place output across the whole width of the multi-column page by setting span="all" on block-level elements which appear immediately below the fo:flow element. Columns are defined by setting the column-count attribute of a body region element to a value greater than 1, and optionally setting the column-gap attribute to define a gap between the columns. The page master for this is similar to the one shown in Figure 18-1.

<fo:simple-page-master  master-name="chapter-2col-odd">
	<fo:region-start extent='2.5cm'/>
		<fo:region-end extent='2.5cm'/>
		<fo:region-body column-count='2' region-name="body" margin='2.5cm'/>
		<fo:region-after region-name="footer-odd" extent="2.5cm"/>
	<fo:region-before region-name="header-odd" extent="2.5cm"/>
</fo:simple-page-master>

Figure 18-1: The page master for a multi-column page

This picture shows a multi-column page:

All the blocks above the horizontal line in the middle of the page have the property span="all" so they go across the entire width of the page.

The blocks below the horizontal line do not have span="all" so they will be placed in the first column in the page. Text will flow to the bottom of this column and then start at the top of the next column.

If there are blocks above this one on the page which have span="all" (as there are) then they will remain in place and the text which is in only one column will be placed in the next column, below the span="all" blocks.