4.2. Designing a Title Page
Prev Chapter 4. Print Customizations Next

4.2. Designing a Title Page

Problem

You want to design a title page of your book or article.

Solution

To design your title page there are two ways to do it, regardless if it is a book or an article:

  1. Indirectly.  Write a title page template which contains the wanted elements in their respective order.

  2. Directly.  Customize the specific named templates.

Both methods are shown below. Although the following descriptions focus on a book title page, the same procedure can be applied for an article title page as well.

For this example, we use the following requisites:

Recto (Right) Page

This is the “main page” and the content appears in the following order:

  • the book title, from /book/title or /book/info/title

  • the book subtitle, from /book/subtitle or /book/info/subtitle

  • the book's author, from /book/info/author

  • the edition, from /book/info/edition

Verso (Left) Page

This usually holds the imprint and the content appears in the following order:

  • the book's title and subtitle in a smaller font size

  • the author, from /book/info/author

  • the edition, from /book/info/edition

  • some legal text (copyright), from /book/info/legalnotice

  • the ISBN, from /book/info/biblioid with class and the value isbn

Using Title Page Templates

To create a title page using a title page template proceed as follows:

  1. Prepare the title page template:

    1. Copy the file fo/titlepage.templates.xml from the DocBook XSL stylesheet distribution to a directory where all your FO customization is stored. Use the filename booktitlepage.xml so we know, it contains only a title page for a book.

    2. Open the file booktitlepage.xml and remove anything except the root and t:titlepage elements with the attribute t:element="book". Your title page template should look like this:

      <!DOCTYPE t:templates [
      <!ENTITY hsize0 "10pt">
      <!ENTITY hsize1 "12pt">
      <!ENTITY hsize2 "14.4pt">
      <!ENTITY hsize3 "17.28pt">
      <!ENTITY hsize4 "20.736pt">
      <!ENTITY hsize5 "24.8832pt">
      <!ENTITY hsize0space "7.5pt"> <!-- 0.75 * hsize0 -->
      <!ENTITY hsize1space "9pt"> <!-- 0.75 * hsize1 -->
      <!ENTITY hsize2space "10.8pt"> <!-- 0.75 * hsize2 -->
      <!ENTITY hsize3space "12.96pt"> <!-- 0.75 * hsize3 -->
      <!ENTITY hsize4space "15.552pt"> <!-- 0.75 * hsize4 -->
      <!ENTITY hsize5space "18.6624pt"> <!-- 0.75 * hsize5 -->
      ]>
      <t:templates xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0"
                   xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param"
                   xmlns:fo="http://www.w3.org/1999/XSL/Format"
                   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <t:titlepage t:element="book" t:wrapper="fo:block">
           <!-- Content disabled for better legibility -->
         </t:titlepage>
      </t:templates>
  2. Customize the content of your titlepage and save your changes into the booktitlepage.xml file.

    1. Change the recto page and locate the t:titlepage-content element with its attribute t:side="recto". As definied in Recto (Right) Page, we remove everything what is not needed. Additionally we have to output edition, which we get from an empty <edition/> tag. The content of the t:titlepage-content should look like this:

      <t:titlepage-content t:side="recto">
        <title     t:named-template="division.title"
                   param:node="ancestor-or-self::book[1]"
                   text-align="center"
                   font-size="&hsize5;"
                   space-before="&hsize5space;"
                   font-weight="bold"
                   font-family="{$title.fontset}"/>
        <subtitle  text-align="center"
                   font-size="&hsize4;"
                   space-before="&hsize4space;"
                   font-family="{$title.fontset}"/>
        <author    font-size="&hsize3;"
                   space-before="&hsize2space;"
                   keep-with-next.within-column="always"/>
        <edition   font-size="&hsize3;"/>
      </t:titlepage-content>
    2. Change the verso page and locate the t:titlepage-content element with its attribute t:side="verso". As definied in Verso (Left) Page, again, we remove everything what is not needed. The content of the t:titlepage-content should look like this:

      <t:titlepage-content t:side="verso">
        <title     t:named-template="book.verso.title"
                   font-size="&hsize2;"
                   font-weight="bold"
                   font-family="{$title.fontset}"/>
        <subtitle  t:named-template="book.verso.title"
                   font-size="&hsize2;"
                   font-weight="bold"
                   font-family="{$title.fontset}"/>
        <author/>
        <edition/>
        <legalnotice/>
        <biblioid  t:predicate="[@class = 'isbn']"/>
      </t:titlepage-content>
    3. Leave the other elements (t:titlepage-separator and t:titlepage-before) as they are.

  3. Use the template/titlepage.xsl stylesheet from the DocBook XSL distribution to transform your booktitlepage.xml title page definition to create the booktitlepage.xsl output:

    xsltproc --output booktitlepage.xsl template/titlepage.xsl booktitlepage.xml
  4. Insert the constructed booktitlepage.xsl into your customization layer mybooktitlepage.xsl:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
      xmlns:fo="http://www.w3.org/1999/XSL/Format"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      
      <xsl:import href="http://docbook.sourceforge.net/release/xsl-ns/current/fo/docbook.xsl"/>
      <xsl:include href="booktitlepage.xsl"/>
      <!-- More customizations hidden -->
    </xsl:stylesheet>
  5. Build your book as usual with your customization layer.

Customizing Title Pages Directly

The DocBook XSL stylesheets use named templates to generate a title page. For a book title page, the named templates are called in the following order, starting with book.titlepage:

book.titlepage
  book.titlepage.before.recto
  book.titlepage.recto
  book.titlepage.before.verso
  book.titlepage.verso
  book.titlepage.separator

This partitioning makes it easy to just only the affected named template. As we only need the default, we do not change book.titlepage.before.recto, book.titlepage.separator, and book.titlepage.before.verso.

Discussion

There are several reasons to customize the title page of your book:

  • You want a different order of the default elements

  • You want to show or hide elements

  • You want to insert corporate logos, links, or other graphical illustrations

  • You want to distinguish between a document in draft or in final state.

See Also

http://www.sagehill.net/docbookxsl/HTMLTitlePage.html