Even and Odd pages sequences

1. How to generate odd-even page sequences

1.

How to generate odd-even page sequences

Kelly Campbell

You need to use a repeatable-page-master-alternatives with different names for the even and odd page masters' region-before.

The following example has a page without headers as the first page of a chapter, and following pages alternate between the book title and the chapter title, with a page number centered at the bottom on all pages.

    <fo:layout-master-set>
	<!-- master set for chapter pages, first page is the title page -->
	<fo:page-sequence-master master-name="chapter-master">
	  <fo:repeatable-page-master-alternatives>
	    <fo:conditional-page-master-reference page-position="first" 
	      odd-or-even="odd"
	      master-name="chapter-first-odd"/>
	    <fo:conditional-page-master-reference page-position="first" 
	      odd-or-even="even"
	      master-name="chapter-first-even"/>
	    <fo:conditional-page-master-reference page-position="rest" 
	      odd-or-even="odd"
	      master-name="chapter-rest-odd"/>
	    <fo:conditional-page-master-reference page-position="rest" 
	      odd-or-even="even"
	      master-name="chapter-rest-even"/>
	  </fo:repeatable-page-master-alternatives>
	</fo:page-sequence-master>

	<!-- simple page masters -->
	<fo:simple-page-master master-name="chapter-first-odd"
	  margin-top="75pt" margin-bottom="50pt" 
	  margin-left="75pt" margin-right="50pt">
	  <fo:region-body margin-bottom="40pt"/>
	  <fo:region-after extent="25pt"/>
	</fo:simple-page-master>

	<fo:simple-page-master master-name="chapter-first-even"
	  margin-top="75pt" margin-bottom="50pt" 
	  margin-left="50pt" margin-right="75pt">
	  <fo:region-body margin-bottom="40pt"/>
	  <fo:region-after extent="25pt"/>
	</fo:simple-page-master>

	<fo:simple-page-master master-name="chapter-rest-odd"
	  margin-top="25pt" margin-bottom="50pt" 
	  margin-left="75pt" margin-right="50pt">
	  <fo:region-body margin-top="50pt" margin-bottom="40pt"/>
	  <fo:region-before extent="50pt"
	  region-name="rest-region-before-odd"/>
	  <fo:region-after extent="25pt"/>
	</fo:simple-page-master>

	<fo:simple-page-master master-name="chapter-rest-even"
	  margin-top="25pt" margin-bottom="50pt" 
	  margin-left="50pt" margin-right="75pt">
	  <fo:region-body margin-top="50pt" margin-bottom="40pt"/>
	  <fo:region-before extent="50pt"
	  region-name="rest-region-before-even"/>
	  <fo:region-after extent="25pt"/>
	</fo:simple-page-master>

      </fo:layout-master-set>
    
   <fo:page-sequence master-name="chapter-master">
      <fo:static-content flow-name="rest-region-before-odd">
	<fo:block text-align="end" font-weight="bold">
	  <!-- book title here -->
	</fo:block>
	<fo:block>
	  <fo:leader leader-pattern="rule" space-after.optimum="12pt"/>
	</fo:block>
      </fo:static-content>
      <fo:static-content flow-name="rest-region-before-even">
	<fo:block text-align="start" font-weight="bold">
	  <!-- chapter title here -->
	</fo:block>
	<fo:block>
	  <fo:leader leader-pattern="rule" space-after.optimum="12pt"/>
	</fo:block>
      </fo:static-content>
      <fo:static-content flow-name="xsl-region-after">
	<fo:block text-align="center">
	  <fo:page-number/>
	</fo:block>
      </fo:static-content>

	<fo:flow flow-name="xsl-region-body">
	 <!-- chapter body content here -->
      </fo:flow>

    </fo:page-sequence>