lfs-pagesetup.xsl 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4. version="1.0">
  5. <!-- This stylesheet controls page margins, sections page break,
  6. header content and titles size. -->
  7. <!-- The inner page margin. -->
  8. <xsl:param name="page.margin.inner" select="'0.32in'"/>
  9. <!-- The outer page margin. -->
  10. <xsl:param name="page.margin.outer" select="'0.32in'"/>
  11. <!-- The bottom margin of the page. -->
  12. <xsl:param name="page.margin.bottom" select="'0.35in'"/>
  13. <!-- The top margin of the page. -->
  14. <xsl:param name="page.margin.top" select="'0.35in'"/>
  15. <!-- The bottom margin of the body text. -->
  16. <xsl:param name="body.margin.bottom" select="'0.4in'"/>
  17. <!-- The top margin of the body text. -->
  18. <xsl:param name="body.margin.top" select="'0.4in'"/>
  19. <!-- Specifies the height of the header. -->
  20. <xsl:param name="region.before.extent" select="'0.25in'"/>
  21. <!-- Specifies the height of the footer. -->
  22. <xsl:param name="region.after.extent" select="'0.25in'"/>
  23. <!-- The start-indent for the body text. -->
  24. <xsl:param name="body.start.indent" select="'0pc'"/>
  25. <!-- Adjust the left margin for titles. -->
  26. <xsl:param name="title.margin.left">-0.8pc</xsl:param>
  27. <!-- Properties for component titles -->
  28. <xsl:attribute-set name="component.title.properties">
  29. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  30. <xsl:attribute name="space-before.optimum">
  31. <xsl:value-of select="concat($body.font.master, 'pt')"/>
  32. </xsl:attribute>
  33. <xsl:attribute name="space-before.minimum">
  34. <xsl:value-of select="concat($body.font.master, 'pt * 0.8')"/>
  35. </xsl:attribute>
  36. <xsl:attribute name="space-before.maximum">
  37. <xsl:value-of select="concat($body.font.master, 'pt * 1.2')"/>
  38. </xsl:attribute>
  39. <xsl:attribute name="hyphenate">false</xsl:attribute>
  40. <xsl:attribute name="text-align">
  41. <xsl:choose>
  42. <xsl:when test="((parent::article | parent::articleinfo |
  43. parent::info/parent::article)
  44. and not(ancestor::book) and not(self::bibliography))
  45. or (parent::slides | parent::slidesinfo)
  46. or self::index">center</xsl:when>
  47. <xsl:otherwise>left</xsl:otherwise>
  48. </xsl:choose>
  49. </xsl:attribute>
  50. <xsl:attribute name="start-indent">
  51. <xsl:value-of select="$title.margin.left"/>
  52. </xsl:attribute>
  53. </xsl:attribute-set>
  54. <!-- Rule under headers? 1 =yes, 0 = no -->
  55. <xsl:param name="header.rule" select="0"/>
  56. <!-- Rule over footers? 1 =yes, 0 = no -->
  57. <xsl:param name="footer.rule" select="0"></xsl:param>
  58. <!-- Control depth of sections shown in running headers or footers.
  59. Be sure that no uneeded fo:marker are generated. -->
  60. <xsl:param name="marker.section.level" select="-1"></xsl:param>
  61. <!-- Force sect1 onto a new page -->
  62. <xsl:attribute-set name="section.level1.properties">
  63. <xsl:attribute name="break-before">
  64. <xsl:choose>
  65. <!--<xsl:when test="not(. = //*/sect1[1])">
  66. <xsl:text>page</xsl:text>
  67. </xsl:when>-->
  68. <xsl:when test="preceding-sibling::sect1[position()=1]/sect2/@role='package'
  69. or self::sect1/sect2/@role='package'">page</xsl:when>
  70. <xsl:otherwise>
  71. <xsl:text>auto</xsl:text>
  72. </xsl:otherwise>
  73. </xsl:choose>
  74. </xsl:attribute>
  75. </xsl:attribute-set>
  76. <!-- book title:
  77. Centered the title and removed unused code. -->
  78. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  79. <xsl:template name="book.titlepage">
  80. <fo:block margin-top="3in">
  81. <fo:block>
  82. <xsl:call-template name="book.titlepage.before.recto"/>
  83. <xsl:call-template name="book.titlepage.recto"/>
  84. </fo:block>
  85. <fo:block>
  86. <xsl:call-template name="book.titlepage.before.verso"/>
  87. <xsl:call-template name="book.titlepage.verso"/>
  88. </fo:block>
  89. <xsl:call-template name="book.titlepage.separator"/>
  90. </fo:block>
  91. </xsl:template>
  92. <!-- book title:
  93. Drop a blank page after book title. -->
  94. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  95. <xsl:template name="book.titlepage.separator"/>
  96. <!-- part title:
  97. Centered the title and removed unused code. -->
  98. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  99. <xsl:template name="part.titlepage">
  100. <fo:block>
  101. <fo:block margin-top="3.5in">
  102. <xsl:call-template name="part.titlepage.before.recto"/>
  103. <xsl:call-template name="part.titlepage.recto"/>
  104. </fo:block>
  105. <fo:block>
  106. <xsl:call-template name="part.titlepage.before.verso"/>
  107. <xsl:call-template name="part.titlepage.verso"/>
  108. </fo:block>
  109. <xsl:call-template name="part.titlepage.separator"/>
  110. </fo:block>
  111. </xsl:template>
  112. <!-- chapter title:
  113. Small font size and left alignament. -->
  114. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  115. <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
  116. <fo:block xsl:use-attribute-sets="chapter.titlepage.recto.style"
  117. font-size="21pt" font-weight="bold" text-align="left">
  118. <xsl:call-template name="component.title">
  119. <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
  120. </xsl:call-template>
  121. </fo:block>
  122. </xsl:template>
  123. <!-- sect2 title:
  124. Skip sect2.titlepage run when title is empty.
  125. Removed unused code. -->
  126. <!-- The original template is in {docbook-xsl}/fo/sections.xsl -->
  127. <xsl:template match="sect2">
  128. <xsl:variable name="id">
  129. <xsl:call-template name="object.id"/>
  130. </xsl:variable>
  131. <fo:block xsl:use-attribute-sets="section.level2.properties">
  132. <xsl:attribute name="id">
  133. <xsl:value-of select="$id"/>
  134. </xsl:attribute>
  135. <xsl:if test="not(string-length(title)=0)">
  136. <xsl:call-template name="sect2.titlepage"/>
  137. </xsl:if>
  138. <xsl:apply-templates/>
  139. </fo:block>
  140. </xsl:template>
  141. <!-- header.table:
  142. Re-made template to not generate a fo:table in the header,
  143. allowing a more simple header.content custonization. -->
  144. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  145. <xsl:template name="header.table">
  146. <xsl:param name="sequence" select="''"/>
  147. <xsl:param name="gentext-key" select="''"/>
  148. <xsl:choose>
  149. <xsl:when test="$gentext-key = 'book' or $sequence = 'blank'"/>
  150. <xsl:otherwise>
  151. <xsl:call-template name="header.content">
  152. <xsl:with-param name="sequence" select="$sequence"/>
  153. </xsl:call-template>
  154. </xsl:otherwise>
  155. </xsl:choose>
  156. </xsl:template>
  157. <!-- header.content
  158. Re-made template to show the book title and version on all pages. -->
  159. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  160. <xsl:template name="header.content">
  161. <xsl:param name="sequence" select="''"/>
  162. <fo:block>
  163. <xsl:attribute name="text-align">
  164. <xsl:choose>
  165. <xsl:when test="$sequence = 'first' or $sequence = 'odd'">right</xsl:when>
  166. <xsl:otherwise>left</xsl:otherwise>
  167. </xsl:choose>
  168. </xsl:attribute>
  169. <xsl:value-of select="/book/bookinfo/title"/>
  170. <xsl:text> - </xsl:text>
  171. <xsl:value-of select="/book/bookinfo/subtitle"/>
  172. </fo:block>
  173. </xsl:template>
  174. </xsl:stylesheet>