]> pere.pagekite.me Git - text-madewithcc.git/blob - extra/pdf.xsl
Make sure to generate valid docbook for dedication.
[text-madewithcc.git] / extra / pdf.xsl
1 <?xml version='1.0' encoding="UTF-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
3
4 <xsl:param name="latex.class.book">myclass</xsl:param>
5
6 <!-- Layout for printing on US Letter paper -->
7 <!-- -->
8 <!-- Should be equivalent to next (commented) line, and should match the -->
9 <!-- default behaviour, but it didn't work... -->
10 <!-- -->
11 <!-- <xsl:param name="paper.type">USletter</xsl:param> -->
12 <xsl:param name="page.width">8.5in</xsl:param>
13 <xsl:param name="page.height">11in</xsl:param>
14
15 <xsl:param name="page.margin.inner">1.5in</xsl:param>
16 <xsl:param name="page.margin.outer">1.5in</xsl:param>
17
18 <xsl:param name="page.margin.top">1in</xsl:param>
19 <xsl:param name="page.margin.bottom">1in</xsl:param>
20
21 <xsl:param name="double.sided">1</xsl:param>
22 <xsl:param name="latex.class.options">openright,twoside</xsl:param>
23
24 <xsl:param name="latex.encoding">utf8</xsl:param>
25
26 <xsl:param name="preface.tocdepth">1</xsl:param>
27
28 <xsl:param name="toc.section.depth">0</xsl:param>
29
30 <!-- do not list figures -->
31 <xsl:param name="doc.lot.show">example</xsl:param>
32
33 <xsl:param name="latex.begindocument">
34 <xsl:text>
35 % Trick to avoid many words sticking out of the right margin of the text.
36 % Note, only one latex.begindocument can be active.
37 \sloppy
38
39 \usepackage{titlesec}
40
41 \titleformat{\chapter}[display]
42 {\raggedright\Huge}
43 {}
44 {0pt}
45 {\thechapter.\ }
46
47 \titleformat{name=\chapter,numberless}[display]
48 {\raggedright\Huge}
49 {}
50 {0pt}
51 {}
52
53 \begin{document}
54 </xsl:text>
55 </xsl:param>
56
57 <!--
58 Make final page blank, which is required for PDFs inteneded for
59 extended distribution with LuLu.
60 -->
61
62 <xsl:param name="latex.enddocument">
63 <xsl:text>\pagebreak
64 \thispagestyle{empty}
65 ~
66 \end{document}
67 </xsl:text>
68 </xsl:param>
69
70 <!-- Attributions should be italicized, right-aligned -->
71 <xsl:template match="attribution">
72 <xsl:param name="content">
73 <xsl:apply-templates/>
74 </xsl:param>
75 <xsl:text>\begin{flushright}
76 \textit{ </xsl:text>
77 <xsl:copy-of select="$content"/>
78 <xsl:text>}
79 \end{flushright}</xsl:text>
80 </xsl:template>
81
82 <!-- An attribution's citetitle should be rendered after a line
83 break -->
84 <xsl:template match="citetitle">
85 <xsl:param name="content">
86 <xsl:apply-templates/>
87 </xsl:param>
88 <xsl:text>\\ \quad \hfill </xsl:text>
89 <xsl:copy-of select="$content"/>
90 </xsl:template>
91
92 <!-- Bibliography and acknowledgements are formatted as numberless
93 chapters — And the easiest way to achieve it was abusing the
94 "Appendix" definition. -->
95 <xsl:template match="appendix">
96 <xsl:param name="content">
97 <xsl:apply-templates/>
98 </xsl:param>
99 <xsl:param name="title">
100 <xsl:apply-templates/>
101 </xsl:param>
102 <xsl:text>\chapter*{</xsl:text>
103 <xsl:copy-of select="title"/>
104 <xsl:text>}</xsl:text>
105 <xsl:text>\addcontentsline{toc}{chapter}{</xsl:text>
106 <xsl:copy-of select="title"/>
107 <xsl:text>}</xsl:text>
108 <xsl:copy-of select="$content"/>
109 </xsl:template>
110
111 <!-- Place title verso page behind the title page the hard way: put
112 colophon content in a file loaded by \maketitle -->
113 <xsl:template match="colophon">
114 <xsl:variable name="titlepage.verso">
115 <xsl:text>\begin{colophon}&#10;</xsl:text>
116 <xsl:apply-templates/>
117 <xsl:text>\end{colophon}&#10;</xsl:text>
118 </xsl:variable>
119 <xsl:call-template name="write.text.chunk">
120 <!-- The filename must end with 'input.rtex' to be parsed by dblatex -->
121 <xsl:with-param name="filename">
122 <xsl:text>titlepg.input.rtex</xsl:text>
123 </xsl:with-param>
124 <xsl:with-param name="method" select="'text'"/>
125 <xsl:with-param name="content">
126 <xsl:value-of select="$titlepage.verso"/>
127 </xsl:with-param>
128 <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
129 </xsl:call-template>
130 </xsl:template>
131
132 <xsl:param name="local.l10n.xml" select="document('')"/>
133 <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
134 <l:l10n language="nb">
135 <!-- Fix bugs in default nb locale -->
136 <l:dingbat key="startquote" text="«"/>
137 <l:dingbat key="endquote" text="»"/>
138 <l:dingbat key="nestedstartquote" text="‘"/>
139 <l:dingbat key="nestedendquote" text="’"/>
140 <l:gentext key="Copyright" text=""/>
141 </l:l10n>
142 <l:l10n language="nn">
143 <!-- Fix bugs in default nn locale -->
144 <l:dingbat key="startquote" text="«"/>
145 <l:dingbat key="endquote" text="»"/>
146 <l:dingbat key="nestedstartquote" text="‘"/>
147 <l:dingbat key="nestedendquote" text="’"/>
148 <l:gentext key="Copyright" text=""/>
149 </l:l10n>
150 </l:i18n>
151
152 </xsl:stylesheet>