Next update of VFS modules development guide
[samba.git] / docs / xslt / db2latex-xsl / xsl / preamble.mod.xsl
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3 <!--############################################################################# 
4 |       $Id: preamble.mod.xsl,v 1.82 2004/01/31 12:26:12 j-devenish Exp $               
5 |- #############################################################################
6 |       $Author: j-devenish $
7 |
8 |   PURPOSE: Variables and templates to manage LaTeX preamble.
9 + ############################################################################## -->
10
11 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12         xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
13         exclude-result-prefixes="doc" version='1.0'>
14
15         <doc:reference id="preamble" xmlns="">
16                 <referenceinfo>
17                         <releaseinfo role="meta">
18                                 $Id: preamble.mod.xsl,v 1.82 2004/01/31 12:26:12 j-devenish Exp $
19                         </releaseinfo>
20                         <authorgroup>
21                                 &ramon;
22                                 &james;
23                         </authorgroup>
24                         <copyright>
25                                 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
26                                 <holder>Ramon Casellas</holder>
27                         </copyright>
28                         <revhistory>
29                                 <doc:revision rcasver="1.77">&rev_2003_05;</doc:revision>
30                         </revhistory>
31                 </referenceinfo>
32                 <title>Variables and Templates used in &LaTeX; Preamble Generation</title>
33                 <partintro>
34                         <para>
35                         
36                         This section described the variables and templates that are used in
37                         the generation of the output &LaTeX; preamble. Basically, the
38                         &LaTeX; preamble depends on the <acronym>XML</acronym> document, that is, on whether
39                         it is an <doc:db>article</doc:db> or a <doc:db>book</doc:db>.
40                         
41                         </para>
42                 </partintro>
43         </doc:reference>
44
45         <doc:template name="generate.latex.article.preamble" xmlns="">
46                 <refpurpose>
47
48                         Top level template, called by article template, responsible of
49                         generating the &LaTeX; preamble according to user
50                         <acronym>XSL</acronym> variables and templates.
51
52                 </refpurpose>
53                 <doc:description>
54                         <para>
55
56                         If <xref linkend="param.latex.override"/> is empty, the template
57                         outputs <xref linkend="param.latex.article.preamblestart"/> and
58                         <xref linkend="param.latex.article.preamble.pre"/>, then calls
59                         <xref linkend="template.generate.latex.common.preamble"/> and <xref
60                         linkend="template.generate.latex.essential.preamble"/> followed by
61                         the value of <xref linkend="param.latex.article.preamble.post"/>.
62                         Otherwise, it outputs the value of <xref linkend="param.latex.override"/>
63                         followed by <xref
64                         linkend="template.generate.latex.essential.preamble"/>.
65
66                         </para>
67                 </doc:description>
68         </doc:template>
69         <xsl:template name="generate.latex.article.preamble">
70                 <xsl:choose>
71                         <xsl:when test="$latex.override = ''">
72                                 <xsl:value-of select="$latex.article.preamblestart"/>
73                                 <xsl:value-of select="$latex.article.preamble.pre"/>
74                                 <xsl:call-template name="label.id"/>
75                                 <xsl:call-template name="generate.latex.common.preamble"/>
76                                 <xsl:call-template name="generate.latex.essential.preamble"/>
77                                 <xsl:value-of select="$latex.article.preamble.post"/>
78                         </xsl:when>
79                         <xsl:otherwise>
80                                 <xsl:value-of select="$latex.override"/>
81                                 <xsl:call-template name="generate.latex.essential.preamble"/>
82                         </xsl:otherwise>
83                 </xsl:choose>
84         </xsl:template>
85
86         <doc:template name="generate.latex.book.preamble" xmlns="">
87                 <refpurpose>
88
89                         Top level template, called by book template, responsible of
90                         generating the &LaTeX; preamble according to user
91                         <acronym>XSL</acronym> variables and templates.
92
93                 </refpurpose>
94                 <doc:description>
95                         <para>
96
97                         If <xref linkend="param.latex.override"/> is empty, the template
98                         outputs <xref linkend="param.latex.book.preamblestart"/> and
99                         <xref linkend="param.latex.book.preamble.pre"/>, then calls
100                         <xref linkend="template.generate.latex.common.preamble"/> and <xref
101                         linkend="template.generate.latex.essential.preamble"/> followed by
102                         the value of <xref linkend="param.latex.book.preamble.post"/>.
103                         Otherwise, it outputs the value of <xref linkend="param.latex.override"/>
104                         followed by <xref
105                         linkend="template.generate.latex.essential.preamble"/>.
106
107                         </para>
108                 </doc:description>
109         </doc:template>
110         <xsl:template name="generate.latex.book.preamble">
111                 <xsl:choose>
112                         <xsl:when test="$latex.override = ''">
113                                 <xsl:value-of select="$latex.book.preamblestart"/>
114                                 <xsl:value-of select="$latex.book.preamble.pre"/>
115                                 <xsl:call-template name="label.id"/>
116                                 <xsl:call-template name="generate.latex.common.preamble"/>
117                                 <xsl:call-template name="generate.latex.essential.preamble"/>
118                                 <xsl:value-of select="$latex.book.preamble.post"/>
119                         </xsl:when>
120                         <xsl:otherwise>
121                                 <xsl:value-of select="$latex.override"/>
122                                 <xsl:call-template name="generate.latex.essential.preamble"/>
123                         </xsl:otherwise>
124                 </xsl:choose>
125         </xsl:template>
126
127         <doc:param name="latex.article.preamblestart" xmlns="">
128                 <refpurpose> Generate <function condition="latex">documentclass</function> for <doc:db basename="article">articles</doc:db>  </refpurpose>
129                 <doc:variables>
130                         <itemizedlist>
131                                 <listitem><simpara><xref linkend="param.latex.documentclass.common"/></simpara></listitem>
132                                 <listitem><simpara><xref linkend="param.latex.documentclass.article"/></simpara></listitem>
133                                 <listitem><simpara><xref linkend="param.latex.documentclass.pdftex"/></simpara></listitem>
134                                 <listitem><simpara><xref linkend="param.latex.documentclass.dvips"/></simpara></listitem>
135                                 <listitem><simpara><xref linkend="param.latex.documentclass"/></simpara></listitem>
136                         </itemizedlist>
137                 </doc:variables>
138                 <doc:description>
139                 </doc:description>
140         </doc:param>
141         <xsl:param name="latex.article.preamblestart">
142                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
143                 <xsl:text>% Autogenerated LaTeX file for articles&#10;</xsl:text>
144                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
145                 <xsl:text>\ifx\pdfoutput\undefined&#10;</xsl:text>
146                 <xsl:text>\documentclass[</xsl:text>
147                 <xsl:value-of select='$latex.documentclass.common' />
148                 <xsl:text>,</xsl:text>
149                 <xsl:value-of select='$latex.documentclass.article' />
150                 <xsl:text>,</xsl:text>
151                 <xsl:value-of select='$latex.documentclass.pdftex' />
152                 <xsl:text>]{</xsl:text>
153                 <xsl:choose>
154                         <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
155                         <xsl:otherwise><xsl:text>article</xsl:text></xsl:otherwise>
156                 </xsl:choose>
157                 <xsl:text>}&#10;</xsl:text>
158                 <xsl:text>\else&#10;</xsl:text>
159                 <xsl:text>\documentclass[pdftex,</xsl:text>
160                 <xsl:value-of select='$latex.documentclass.common' />
161                 <xsl:text>,</xsl:text>
162                 <xsl:value-of select='$latex.documentclass.article' />
163                 <xsl:text>,</xsl:text>
164                 <xsl:value-of select='$latex.documentclass.dvips' />
165                 <xsl:text>]{</xsl:text>
166                 <xsl:choose>
167                         <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
168                         <xsl:otherwise><xsl:text>article</xsl:text></xsl:otherwise>
169                 </xsl:choose>
170                 <xsl:text>}&#10;</xsl:text>
171                 <xsl:text>\fi&#10;</xsl:text>
172         </xsl:param>
173
174         <doc:param name="latex.book.preamblestart" xmlns="">
175                 <refpurpose> Generate <function condition="latex">documentclass</function> for <doc:db basename="book">books</doc:db>  </refpurpose>
176                 <doc:variables>
177                         <itemizedlist>
178                                 <listitem><simpara><xref linkend="param.latex.documentclass.common"/></simpara></listitem>
179                                 <listitem><simpara><xref linkend="param.latex.documentclass.book"/></simpara></listitem>
180                                 <listitem><simpara><xref linkend="param.latex.documentclass.pdftex"/></simpara></listitem>
181                                 <listitem><simpara><xref linkend="param.latex.documentclass.dvips"/></simpara></listitem>
182                                 <listitem><simpara><xref linkend="param.latex.documentclass"/></simpara></listitem>
183                         </itemizedlist>
184                 </doc:variables>
185                 <doc:description>
186                 </doc:description>
187         </doc:param>
188         <xsl:param name="latex.book.preamblestart">
189                 <xsl:text>% ------------------------------------------------------------        &#10;</xsl:text>
190                 <xsl:text>% Autogenerated LaTeX file for books  &#10;</xsl:text>
191                 <xsl:text>% ------------------------------------------------------------        &#10;</xsl:text>
192                 <xsl:text>\ifx\pdfoutput\undefined&#10;</xsl:text>
193                 <xsl:text>\documentclass[</xsl:text>
194                 <xsl:value-of select='$latex.documentclass.common' />
195                 <xsl:text>,</xsl:text>
196                 <xsl:value-of select='$latex.documentclass.book' />
197                 <xsl:text>,</xsl:text>
198                 <xsl:value-of select='$latex.documentclass.pdftex' />
199                 <xsl:text>]{</xsl:text>
200                 <xsl:choose>
201                         <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
202                         <xsl:otherwise><xsl:text>report</xsl:text></xsl:otherwise>
203                 </xsl:choose>
204                 <xsl:text>}&#10;</xsl:text>
205                 <xsl:text>\else&#10;</xsl:text>
206                 <xsl:text>\documentclass[pdftex,</xsl:text>
207                 <xsl:value-of select='$latex.documentclass.common' />
208                 <xsl:text>,</xsl:text>
209                 <xsl:value-of select='$latex.documentclass.book' />
210                 <xsl:text>,</xsl:text>
211                 <xsl:value-of select='$latex.documentclass.dvips' />
212                 <xsl:text>]{</xsl:text>
213                 <xsl:choose>
214                         <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
215                         <xsl:otherwise><xsl:text>report</xsl:text></xsl:otherwise>
216                 </xsl:choose>
217                 <xsl:text>}&#10;</xsl:text>
218                 <xsl:text>\fi&#10;</xsl:text>
219         </xsl:param>
220
221         <doc:param xmlns="">
222                 <refpurpose> Select localisation language  </refpurpose>
223                 <doc:description>
224                         <para>
225                                 Chooses the <quote>gentext</quote> language for the document.
226                         </para>
227                 </doc:description>
228                 <doc:variables>
229                         &no_var;
230                 </doc:variables>
231                 <doc:notes>
232                         <para>
233
234                                 Selects the root <doc:db>set</doc:db>, <doc:db>book</doc:db> or
235                                 <doc:db>article</doc:db> element and reads its <sgmltag
236                                 class="attribute">lang</sgmltag> or <sgmltag
237                                 class="attribute">xml:lang</sgmltag> attribute.
238
239                         </para>
240                 </doc:notes>
241         </doc:param>
242         <xsl:param name="document.xml.language">
243                 <xsl:call-template name="l10n.language">
244                         <xsl:with-param name="target" select="(/set|/book|/article)[1]"/>
245                         <!-- now, induce the use of $target rather than the current node: -->
246                         <xsl:with-param name="xref-context" select="true()"/>
247                 </xsl:call-template>
248         </xsl:param>
249
250         <doc:param xmlns="">
251                 <refpurpose> Select <productname>babel</productname> option </refpurpose>
252                 <doc:description>
253                         <para>
254                                 If <xref linkend="param.latex.babel.language"/> is not set, this
255                                 template will select a <productname>babel</productname> option
256                                 based on the <xref linkend="param.document.xml.language"/>.
257                         </para>
258                 </doc:description>
259                 <doc:variables>
260                         <itemizedlist>
261                                 <listitem><simpara><xref linkend="param.latex.babel.language"/></simpara></listitem>
262                                 <listitem><simpara><xref linkend="param.document.xml.language"/></simpara></listitem>
263                         </itemizedlist>
264                 </doc:variables>
265                 <doc:notes>
266                         <para>A special value of <quote><literal>none</literal></quote>
267                         can be used to disable <productname>babel</productname>.</para>
268                 </doc:notes>
269         </doc:param>
270         <xsl:param name="latex.language.option">
271                 <xsl:choose>
272                         <xsl:when test="$latex.babel.language!=''">
273                                 <xsl:value-of select="$latex.babel.language"/>
274                         </xsl:when>
275                         <xsl:when test="starts-with($document.xml.language,'af')">afrikaans</xsl:when>
276                         <xsl:when test="starts-with($document.xml.language,'br')">breton</xsl:when>
277                         <xsl:when test="starts-with($document.xml.language,'ca')">catalan</xsl:when>
278                         <xsl:when test="starts-with($document.xml.language,'cs')">czech</xsl:when>
279                         <xsl:when test="starts-with($document.xml.language,'cy')">welsh</xsl:when>
280                         <xsl:when test="starts-with($document.xml.language,'da')">danish</xsl:when>
281                         <xsl:when test="starts-with($document.xml.language,'de')">ngerman</xsl:when><!-- ngerman, german or germanb? -->
282                         <xsl:when test="starts-with($document.xml.language,'el')">greek</xsl:when>
283                         <xsl:when test="starts-with($document.xml.language,'en')">
284                                 <xsl:choose>
285                                         <xsl:when test="starts-with($document.xml.language,'en-CA')">canadian</xsl:when>
286                                         <xsl:when test="starts-with($document.xml.language,'en-GB')">british</xsl:when>
287                                         <xsl:when test="starts-with($document.xml.language,'en-US')">USenglish</xsl:when>
288                                         <xsl:otherwise>none</xsl:otherwise>
289                                 </xsl:choose>
290                         </xsl:when>
291                         <xsl:when test="starts-with($document.xml.language,'eo')">esperanto</xsl:when>
292                         <xsl:when test="starts-with($document.xml.language,'es')">spanish</xsl:when>
293                         <xsl:when test="starts-with($document.xml.language,'et')">estonian</xsl:when>
294                         <xsl:when test="starts-with($document.xml.language,'fi')">finnish</xsl:when>
295                         <xsl:when test="starts-with($document.xml.language,'fr')">french</xsl:when><!-- francais, french, or frenchb? -->
296                         <xsl:when test="starts-with($document.xml.language,'ga')">irish</xsl:when>
297                         <xsl:when test="starts-with($document.xml.language,'gd')">scottish</xsl:when>
298                         <xsl:when test="starts-with($document.xml.language,'gl')">galician</xsl:when>
299                         <xsl:when test="starts-with($document.xml.language,'he')">hebrew</xsl:when>
300                         <xsl:when test="starts-with($document.xml.language,'hr')">croatian</xsl:when>
301                         <xsl:when test="starts-with($document.xml.language,'hu')">hungarian</xsl:when>
302                         <xsl:when test="starts-with($document.xml.language,'id')">bahasa</xsl:when>
303                         <xsl:when test="starts-with($document.xml.language,'it')">italian</xsl:when>
304                         <xsl:when test="starts-with($document.xml.language,'nl')">dutch</xsl:when>
305                         <xsl:when test="starts-with($document.xml.language,'nn')">norsk</xsl:when>
306                         <xsl:when test="starts-with($document.xml.language,'pl')">polish</xsl:when>
307                         <xsl:when test="starts-with($document.xml.language,'pt')">
308                                 <xsl:choose>
309                                         <xsl:when test="starts-with($document.xml.language,'pt-BR')">brazil</xsl:when>
310                                         <xsl:otherwise>portugese</xsl:otherwise>
311                                 </xsl:choose>
312                         </xsl:when>
313                         <xsl:when test="starts-with($document.xml.language,'ro')">romanian</xsl:when>
314                         <xsl:when test="starts-with($document.xml.language,'ru')">russian</xsl:when>
315                         <xsl:when test="starts-with($document.xml.language,'sk')">slovak</xsl:when>
316                         <xsl:when test="starts-with($document.xml.language,'sl')">slovene</xsl:when>
317                         <xsl:when test="starts-with($document.xml.language,'sv')">swedish</xsl:when>
318                         <xsl:when test="starts-with($document.xml.language,'tr')">turkish</xsl:when>
319                         <xsl:when test="starts-with($document.xml.language,'uk')">ukrainian</xsl:when>
320                 </xsl:choose>
321         </xsl:param>
322
323         <doc:template xmlns="">
324                 <refpurpose>
325
326                         Common &LaTeX; preamble shared by <doc:db>articles</doc:db> and
327                         <doc:db>books</doc:db>, and other document classes. Most of the
328                         packages and package options are managed here.
329
330                 </refpurpose>
331                 <doc:description>
332                         <para>
333
334                         The &LaTeX; preamble, after the <function
335                         condition="latex">documentclass</function> command but before the
336                         <function condition="env">document</function> environment.
337
338                         </para>
339                 </doc:description>
340                 <doc:variables>
341                         <itemizedlist>
342                                 <listitem><simpara><xref linkend="param.latex.pdf.support"/></simpara></listitem>
343                                 <listitem><simpara><xref linkend="param.latex.pdf.preamble"/></simpara></listitem>
344                                 <listitem><simpara><xref linkend="param.latex.article.varsets"/></simpara></listitem>
345                                 <listitem><simpara><xref linkend="param.latex.book.varsets"/></simpara></listitem>
346                                 <listitem><simpara><xref linkend="param.latex.bridgehead.in.lot"/></simpara></listitem>
347                                 <listitem><simpara><xref linkend="param.latex.use.fancyhdr"/></simpara></listitem>
348                                 <listitem><simpara><xref linkend="param.latex.fancyhdr.style"/></simpara></listitem>
349                                 <listitem><simpara><xref linkend="param.latex.fancyhdr.truncation.partition"/></simpara></listitem>
350                                 <listitem><simpara><xref linkend="param.latex.fancyhdr.truncation.style"/></simpara></listitem>
351                                 <listitem><simpara><xref linkend="param.latex.use.varioref"/></simpara></listitem>
352                                 <listitem><simpara><xref linkend="param.latex.varioref.options"/></simpara></listitem>
353                                 <listitem><simpara><xref linkend="param.latex.use.dcolumn"/></simpara></listitem>
354                                 <listitem><simpara><xref linkend="param.latex.decimal.point"/></simpara></listitem>
355                                 <listitem><simpara><xref linkend="param.latex.use.fancybox"/></simpara></listitem>
356                                 <listitem><simpara><xref linkend="param.latex.use.fancyvrb"/></simpara></listitem>
357                                 <listitem><simpara><xref linkend="param.latex.fancyvrb.tabsize"/></simpara></listitem>
358                                 <listitem><simpara><xref linkend="param.latex.use.isolatin1"/></simpara></listitem>
359                                 <listitem><simpara><xref linkend="param.latex.use.parskip"/></simpara></listitem>
360                                 <listitem><simpara><xref linkend="param.latex.use.rotating"/></simpara></listitem>
361                                 <listitem><simpara><xref linkend="param.latex.use.subfigure"/></simpara></listitem>
362                                 <listitem><simpara><xref linkend="param.latex.use.tabularx"/></simpara></listitem>
363                                 <listitem><simpara><xref linkend="param.latex.use.umoline"/></simpara></listitem>
364                                 <listitem><simpara><xref linkend="param.latex.use.url"/></simpara></listitem>
365                                 <listitem><simpara><xref linkend="param.latex.math.support"/></simpara></listitem>
366                                 <listitem><simpara><xref linkend="param.latex.math.preamble"/></simpara></listitem>
367                                 <listitem><simpara><xref linkend="param.latex.document.font"/></simpara></listitem>
368                                 <listitem><simpara><xref linkend="param.latex.use.hyperref"/></simpara></listitem>
369                                 <listitem><simpara><xref linkend="param.latex.admonition.environment"/></simpara></listitem>
370                                 <listitem><simpara><xref linkend="param.latex.caption.swapskip"/></simpara></listitem>
371                                 <listitem><simpara><xref linkend="param.latex.hyphenation.tttricks"/></simpara></listitem>
372                                 <listitem><simpara><xref linkend="param.latex.language.option"/></simpara></listitem>
373                                 <listitem><simpara><xref linkend="param.latex.is.draft"/></simpara></listitem>
374                         </itemizedlist>
375                 </doc:variables>
376                 <doc:seealso>
377                         <itemizedlist>
378                                 <listitem><simpara><xref linkend="template.generate.latex.pagestyle"/></simpara></listitem>
379                                 <listitem><simpara><xref linkend="template.gentext.dingbat"/></simpara></listitem>
380                                 <listitem><simpara><xref linkend="template.latex.hyperref.preamble"/></simpara></listitem>
381                                 <listitem><simpara><xref linkend="template.float.preamble"/></simpara></listitem>
382                                 <listitem><simpara><xref linkend="template.latex.graphicext"/></simpara></listitem>
383                                 <listitem><simpara><xref linkend="template.generate.latex.draft.preamble"/></simpara></listitem>
384                         </itemizedlist>
385                 </doc:seealso>
386         </doc:template>
387         <xsl:template name="generate.latex.common.preamble">
388                 <xsl:choose>
389                         <xsl:when test="$latex.pdf.support=1"><xsl:value-of select="$latex.pdf.preamble"/></xsl:when>
390                         <xsl:otherwise><xsl:text>\usepackage{graphicx}&#10;</xsl:text></xsl:otherwise>
391                 </xsl:choose>
392                 <xsl:if test="local-name(.)='article'">
393                         <xsl:value-of select="$latex.article.varsets"/>
394                 </xsl:if>
395                 <xsl:if test="local-name(.)='book'">
396                         <xsl:value-of select="$latex.book.varsets"/>
397                 </xsl:if>
398                 <xsl:if test="$latex.bridgehead.in.lot=1">
399                         <xsl:text><![CDATA[
400 \makeatletter
401 % redefine the listoffigures and listoftables so that the name of the chapter
402 % is printed whenever there are figures or tables from that chapter. encourage
403 % pagebreak prior to the name of the chapter (discourage orphans).
404 \let\save@@chapter\@chapter
405 \let\save@@l@figure\l@figure
406 \let\the@l@figure@leader\relax
407 \def\@chapter[#1]#2{\save@@chapter[{#1}]{#2}%
408 \addtocontents{lof}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}%
409 \addtocontents{lot}{\protect\def\the@l@figure@leader{\protect\pagebreak[0]\protect\contentsline{chapter}{\protect\numberline{\thechapter}#1}{}{\thepage}}}%
410 }
411 \renewcommand*\l@figure{\the@l@figure@leader\let\the@l@figure@leader\relax\save@@l@figure}
412 \let\l@table\l@figure
413 \makeatother
414 ]]></xsl:text>
415                 </xsl:if>
416                 <xsl:if test="$latex.use.fancyhdr=1">
417                         <xsl:text>\usepackage{fancyhdr}&#10;</xsl:text>
418                         <xsl:text>\renewcommand{\headrulewidth}{0.4pt}&#10;</xsl:text>
419                         <xsl:text>\renewcommand{\footrulewidth}{0.4pt}&#10;</xsl:text>
420                         <xsl:if test="$latex.fancyhdr.truncation.partition!=''">
421                                 <xsl:variable name="partition">
422                                         <xsl:value-of select="round(number($latex.fancyhdr.truncation.partition))"/>
423                                 </xsl:variable>
424                                 <xsl:variable name="left.fraction">
425                                         <xsl:choose>
426                                                 <xsl:when test="$partition&lt;1">
427                                                         <xsl:text>0</xsl:text>
428                                                 </xsl:when>
429                                                 <xsl:when test="$partition>97">
430                                                         <xsl:text>.98</xsl:text>
431                                                 </xsl:when>
432                                                 <xsl:otherwise>
433                                                         <!-- example: 60 becomes .59 -->
434                                                         <xsl:value-of select="($partition - 1) div 100"/>
435                                                 </xsl:otherwise>
436                                         </xsl:choose>
437                                 </xsl:variable>
438                                 <xsl:variable name="right.fraction" select="0.98 - number($left.fraction)"/>
439                                 <xsl:text>% Safeguard against long headers.&#10;</xsl:text>
440                                 <xsl:text>\IfFileExists{truncate.sty}{&#10;</xsl:text>
441                                 <xsl:text>\usepackage{truncate}&#10;</xsl:text>
442                                 <xsl:text>% Use an ellipsis when text would be larger than x% of the text width.&#10;</xsl:text>
443                                 <xsl:text>% Preserve left/right text alignment using \hfill (works for English).&#10;</xsl:text>
444                                 <xsl:choose>
445                                         <xsl:when test="$latex.fancyhdr.truncation.style='lr'">
446                                                 <!-- left vs. right -->
447                                                 <xsl:choose>
448                                                         <xsl:when test="$left.fraction &gt; 0.02">
449                                                                 <xsl:text>\fancyhead[ol]{\truncate{</xsl:text><xsl:value-of select="$left.fraction"/><xsl:text>\textwidth}{\sl\leftmark}}&#10;</xsl:text>
450                                                                 <xsl:text>\fancyhead[el]{\truncate{</xsl:text><xsl:value-of select="$left.fraction"/><xsl:text>\textwidth}{\sl\leftmark}}&#10;</xsl:text>
451                                                         </xsl:when>
452                                                         <xsl:otherwise>
453                                                                 <xsl:text>\fancyhead[ol]{}&#10;</xsl:text>
454                                                                 <xsl:text>\fancyhead[el]{}&#10;</xsl:text>
455                                                         </xsl:otherwise>
456                                                 </xsl:choose>
457                                                 <xsl:choose>
458                                                         <xsl:when test="$right.fraction &gt; 0.02">
459                                                                 <xsl:text>\fancyhead[or]{\truncate{</xsl:text><xsl:value-of select="$right.fraction"/><xsl:text>\textwidth}{\hfill\sl\rightmark}}&#10;</xsl:text>
460                                                                 <xsl:text>\fancyhead[er]{\truncate{</xsl:text><xsl:value-of select="$right.fraction"/><xsl:text>\textwidth}{\hfill\sl\rightmark}}&#10;</xsl:text>
461                                                         </xsl:when>
462                                                         <xsl:otherwise>
463                                                                 <xsl:text>\fancyhead[or]{}&#10;</xsl:text>
464                                                                 <xsl:text>\fancyhead[er]{}&#10;</xsl:text>
465                                                         </xsl:otherwise>
466                                                 </xsl:choose>
467                                         </xsl:when>
468                                         <xsl:otherwise>
469                                                 <!-- inside vs. outside -->
470                                                 <xsl:choose>
471                                                         <xsl:when test="$left.fraction &gt; 0.02">
472                                                                 <xsl:text>\fancyhead[ol]{\truncate{</xsl:text><xsl:value-of select="$left.fraction"/><xsl:text>\textwidth}{\sl\leftmark}}&#10;</xsl:text>
473                                                                 <xsl:text>\fancyhead[er]{\truncate{</xsl:text><xsl:value-of select="$left.fraction"/><xsl:text>\textwidth}{\hfill\sl\rightmark}}&#10;</xsl:text>
474                                                         </xsl:when>
475                                                         <xsl:otherwise>
476                                                                 <xsl:text>\fancyhead[ol]{}&#10;</xsl:text>
477                                                                 <xsl:text>\fancyhead[er]{}&#10;</xsl:text>
478                                                         </xsl:otherwise>
479                                                 </xsl:choose>
480                                                 <xsl:choose>
481                                                         <xsl:when test="$right.fraction &gt; 0.02">
482                                                                 <xsl:text>\fancyhead[el]{\truncate{</xsl:text><xsl:value-of select="$right.fraction"/><xsl:text>\textwidth}{\sl\leftmark}}&#10;</xsl:text>
483                                                                 <xsl:text>\fancyhead[or]{\truncate{</xsl:text><xsl:value-of select="$right.fraction"/><xsl:text>\textwidth}{\hfill\sl\rightmark}}&#10;</xsl:text>
484                                                         </xsl:when>
485                                                         <xsl:otherwise>
486                                                                 <xsl:text>\fancyhead[el]{}&#10;</xsl:text>
487                                                                 <xsl:text>\fancyhead[or]{}&#10;</xsl:text>
488                                                         </xsl:otherwise>
489                                                 </xsl:choose>
490                                         </xsl:otherwise>
491                                 </xsl:choose>
492                                 <xsl:text>}{\typeout{WARNING: truncate.sty wasn't available and functionality was skipped.}}&#10;</xsl:text>
493                         </xsl:if>
494                         <xsl:choose>
495                                 <xsl:when test="$latex.fancyhdr.style='natural'">
496                                         <xsl:text><![CDATA[
497 \makeatletter
498 % Override the default from fancyhdr (which would be to have all-caps headings).
499 \newcommand{\dblatex@chaptermark}[1]{\markboth{{\ifnum \c@secnumdepth>\m@ne \@chapapp\ \thechapter. \ \fi #1}}{}}
500 \def\dblatex@chaptersmark#1{\markboth{{#1}}{}}
501 \newcommand{\dblatex@sectionmark}[1]{\markright{{\ifnum \c@secnumdepth >\z@ \thesection. \ \fi #1}}}
502 \let\dblatex@ps@fancy\ps@fancy
503 \def\ps@fancy{
504         \dblatex@ps@fancy
505         \let\chaptermark\dblatex@chaptermark
506         \let\sectionmark\dblatex@sectionmark
507 }
508 \makeatother
509 ]]></xsl:text>
510                                 </xsl:when>
511                         </xsl:choose>
512                         <xsl:call-template name="generate.latex.pagestyle"/>
513                         <!-- 
514                         Add dollar...
515                         <xsl:if test="latex.fancyhdr.lh !=''"><xsl:text>\lhead{</xsl:text><xsl:value-of select="$latex.fancyhdr.lh"/><xsl:text>}&#10;</xsl:text></xsl:if>
516                         <xsl:if test="latex.fancyhdr.ch !=''"><xsl:text>\chead{</xsl:text><xsl:value-of select="$latex.fancyhdr.ch"/><xsl:text>}&#10;</xsl:text></xsl:if>
517                         <xsl:if test="latex.fancyhdr.rh !=''"><xsl:text>\rhead{</xsl:text><xsl:value-of select="$latex.fancyhdr.rh"/><xsl:text>}&#10;</xsl:text></xsl:if>
518                         <xsl:if test="latex.fancyhdr.lf !=''"><xsl:text>\lfoot{</xsl:text><xsl:value-of select="$latex.fancyhdr.lf"/><xsl:text>}&#10;</xsl:text></xsl:if>
519                         <xsl:if test="latex.fancyhdr.cf !=''"><xsl:text>\cfoot{</xsl:text><xsl:value-of select="$latex.fancyhdr.cf"/><xsl:text>}&#10;</xsl:text></xsl:if>
520                         <xsl:if test="latex.fancyhdr.rf !=''"><xsl:text>\rfoot{</xsl:text><xsl:value-of select="$latex.fancyhdr.rf"/><xsl:text>}&#10;</xsl:text></xsl:if> 
521                         -->
522                 </xsl:if>
523                 <xsl:text>% ---------------------- &#10;</xsl:text>
524                 <xsl:text>% Most Common Packages   &#10;</xsl:text>
525                 <xsl:text>% ---------------------- &#10;</xsl:text>
526                 <xsl:if test="$latex.use.varioref=1">
527                         <xsl:text>\usepackage[</xsl:text>
528                         <xsl:value-of select="$latex.varioref.options"/>
529                         <xsl:text>]{varioref} &#10;</xsl:text>
530                 </xsl:if>
531                 <xsl:text>\usepackage{latexsym}         &#10;</xsl:text>
532                 <xsl:if test="$latex.use.dcolumn=1">
533                         <xsl:text>\usepackage{dcolumn}      &#10;</xsl:text>
534                         <xsl:text>% Default decimal point-style column&#10;</xsl:text>
535                         <xsl:text>\newcolumntype{d}{D{</xsl:text>
536                         <xsl:call-template name="gentext.dingbat">
537                                 <xsl:with-param name="dingbat">decimalpoint</xsl:with-param>
538                         </xsl:call-template>
539                         <xsl:text>}{</xsl:text>
540                         <xsl:choose>
541                                 <xsl:when test="$latex.decimal.point!=''">
542                                         <xsl:value-of select="$latex.decimal.point"/>
543                                 </xsl:when>
544                                 <xsl:otherwise>
545                                         <xsl:call-template name="gentext.dingbat">
546                                                 <xsl:with-param name="dingbat">latexdecimal</xsl:with-param>
547                                         </xsl:call-template>
548                                  </xsl:otherwise>
549                         </xsl:choose>
550                         <xsl:text>}{-1}}&#10;</xsl:text>
551                 </xsl:if>
552                 <xsl:text>\usepackage{enumerate}         &#10;</xsl:text>
553                 <xsl:if test="$latex.use.fancybox=1">
554                         <!-- must be before \usepackage{fancyvrb} -->
555                         <xsl:text>\usepackage{fancybox}      &#10;</xsl:text>
556                 </xsl:if>
557                 <xsl:text>\usepackage{float}       &#10;</xsl:text>
558                 <xsl:text>\usepackage{ragged2e}       &#10;</xsl:text>
559                 <xsl:if test="$latex.use.fancyvrb=1">
560                         <!-- must be after \usepackage{fancybox} -->
561                         <xsl:text>\usepackage{fancyvrb}         &#10;</xsl:text>
562                         <xsl:text>\makeatletter\@namedef{FV@fontfamily@default}{\def\FV@FontScanPrep{}\def\FV@FontFamily{}}\makeatother&#10;</xsl:text>
563                         <xsl:if test="$latex.fancyvrb.tabsize!=''">
564                                 <xsl:text>\fvset{obeytabs=true,tabsize=</xsl:text>
565                                 <xsl:value-of select="$latex.fancyvrb.tabsize"/>
566                                 <xsl:text>}&#10;</xsl:text>
567                         </xsl:if>
568                 </xsl:if>
569                 <xsl:if test="$latex.use.isolatin1=1">
570                         <xsl:message>Please use $latex.inputenc='latin1' instead of $latex.use.isolatin1='1'.</xsl:message>
571                         <xsl:text>\usepackage{isolatin1}         &#10;</xsl:text>
572                 </xsl:if>
573                 <xsl:choose>
574                         <xsl:when test="$latex.use.parskip=1">
575                                 <xsl:text>\usepackage{parskip}         &#10;</xsl:text>
576                         </xsl:when>
577                         <xsl:otherwise>
578                                 <!-- hack from parksip to stop excess whitespace after figure captions -->
579                                 <xsl:text><![CDATA[\makeatletter
580 \let\dblatex@center\center\let\dblatex@endcenter\endcenter
581 \def\dblatex@nolistI{\leftmargin\leftmargini\topsep\z@ \parsep\parskip \itemsep\z@}
582 \def\center{\let\@listi\dblatex@nolistI\@listi\dblatex@center\let\@listi\@listI\@listi}
583 \def\endcenter{\dblatex@endcenter}
584 \makeatother
585 ]]></xsl:text>
586                         </xsl:otherwise>
587                 </xsl:choose>
588                 <xsl:if test="$latex.use.rotating=1"><xsl:text>\usepackage{rotating}         &#10;</xsl:text></xsl:if>
589                 <xsl:if test="$latex.use.subfigure=1"><xsl:text>\usepackage{subfigure}         &#10;</xsl:text></xsl:if>
590                 <xsl:if test="$latex.use.tabularx=1"><xsl:text>\usepackage{tabularx}         &#10;</xsl:text></xsl:if>
591                 <xsl:if test="$latex.use.ltxtable=1 or $latex.use.longtable=1"><xsl:text>\usepackage{longtable}         &#10;</xsl:text></xsl:if>
592                 <xsl:if test="$latex.use.umoline=1"><xsl:text>\usepackage{umoline}         &#10;</xsl:text></xsl:if>
593                 <xsl:if test="$latex.use.url=1"><xsl:text>\usepackage{url}         &#10;</xsl:text></xsl:if>
594                 <xsl:if test="$latex.math.support=1"><xsl:value-of select="$latex.math.preamble"/></xsl:if>
595
596                 <!-- Configure document font. -->
597                 <xsl:if test="$latex.document.font != 'default'">
598                         <xsl:text>% ---------------&#10;</xsl:text>
599                         <xsl:text>% Document Font  &#10;</xsl:text>
600                         <xsl:text>% ---------------&#10;</xsl:text>
601                         <xsl:text>\usepackage{</xsl:text><xsl:value-of select="$latex.document.font"/><xsl:text>}&#10;</xsl:text>
602                 </xsl:if>
603
604                 <xsl:if test="$latex.use.hyperref=1">
605                         <xsl:call-template name="latex.hyperref.preamble"/>
606                 </xsl:if>
607                 <xsl:value-of select="$latex.admonition.environment"/>
608                 <xsl:call-template name="latex.float.preamble"/>
609                 <xsl:call-template name="latex.graphicext"/>
610                 <xsl:choose>
611                         <xsl:when test='$latex.caption.swapskip=1'>
612                                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
613                                 <xsl:text>% $latex.caption.swapskip enabled for $formal.title.placement support&#10;</xsl:text>
614                                 <xsl:text>\newlength{\docbooktolatextempskip}&#10;</xsl:text>
615                                 <xsl:text>\newcommand{\captionswapskip}{\setlength{\docbooktolatextempskip}{\abovecaptionskip}</xsl:text>
616                                 <xsl:text>\setlength{\abovecaptionskip}{\belowcaptionskip}</xsl:text>
617                                 <xsl:text>\setlength{\belowcaptionskip}{\docbooktolatextempskip}}&#10;</xsl:text>
618                         </xsl:when>
619                         <xsl:otherwise>
620                                 <xsl:text>\newcommand{\captionswapskip}{}&#10;</xsl:text>
621                         </xsl:otherwise>
622                 </xsl:choose>
623                 <xsl:if test='$latex.hyphenation.tttricks=1'>
624                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
625                         <xsl:text>% Better linebreaks&#10;</xsl:text>
626                         <xsl:text>\newcommand{\docbookhyphenatedot}[1]{{\hyphenchar\font=`\.\relax #1\hyphenchar\font=`\-}}&#10;</xsl:text>
627                         <xsl:text>\newcommand{\docbookhyphenatefilename}[1]{{\hyphenchar\font=`\.\relax #1\hyphenchar\font=`\-}}&#10;</xsl:text>
628                         <xsl:text>\newcommand{\docbookhyphenateurl}[1]{{\hyphenchar\font=`\/\relax #1\hyphenchar\font=`\-}}&#10;</xsl:text>
629                 </xsl:if>
630                 <!--
631                 <xsl:message>$document.xml.language: '<xsl:value-of select="$document.xml.language"/>'</xsl:message>
632                 <xsl:message>$latex.language.option: '<xsl:value-of select="$latex.language.option"/>'</xsl:message>
633                 -->
634                 <xsl:if test="$latex.language.option!='none'">
635                         <xsl:text>\usepackage[</xsl:text><xsl:value-of select="$latex.language.option" /><xsl:text>]{babel} &#10;</xsl:text>
636                 </xsl:if>
637                 <xsl:if test="$latex.use.hyperref='1'">
638                         <xsl:text>% Guard against a problem with old package versions.&#10;</xsl:text>
639                         <xsl:text>\makeatletter&#10;</xsl:text>
640                         <xsl:text>\AtBeginDocument{&#10;</xsl:text>
641                         <xsl:text>\DeclareRobustCommand\ref{\@refstar}&#10;</xsl:text>
642                         <xsl:text>\DeclareRobustCommand\pageref{\@pagerefstar}&#10;</xsl:text>
643                         <xsl:text>}&#10;</xsl:text>
644                         <xsl:text>\makeatother&#10;</xsl:text>
645                 </xsl:if>
646                 <xsl:choose>
647                         <xsl:when test="$latex.is.draft!=''">
648                                 <xsl:if test="$latex.is.draft=1">
649                                         <xsl:call-template name="generate.latex.draft.preamble"/>
650                                 </xsl:if>
651                         </xsl:when>
652                         <xsl:otherwise>
653                                 <xsl:if test="(/set|/book|/article)[1]/@status='draft'">
654                                         <xsl:call-template name="generate.latex.draft.preamble"/>
655                                 </xsl:if>
656                         </xsl:otherwise>
657                 </xsl:choose>
658         </xsl:template>
659
660         <doc:template xmlns="">
661                 <refpurpose>
662
663                         Common &LaTeX; preamble shared by <doc:db basename="article">article</doc:db> and
664                         <doc:db basename="book">book</doc:db> when their <sgmltag
665                         class="attribute">status</sgmltag> is <quote>draft</quote>.
666
667                 </refpurpose>
668                 <doc:description>
669                         <para>
670
671                         
672
673                         </para>
674                 </doc:description>
675                 <doc:variables>
676                         <itemizedlist>
677                                 <listitem><simpara><xref linkend="param.latex.is.draft"/></simpara></listitem>
678                                 <listitem><simpara><xref linkend="param.latex.use.varioref"/></simpara></listitem>
679                         </itemizedlist>
680                 </doc:variables>
681                 <doc:samples>
682                         <simplelist type='inline'>
683                                 &test_index_draft;
684                                 &test_draft;
685                         </simplelist>
686                 </doc:samples>
687         </doc:template>
688         <xsl:template name="generate.latex.draft.preamble">
689                 <xsl:choose>
690                         <xsl:when test="$latex.use.varioref='1'">
691                                 <xsl:message>Combining varioref with showkeys (and hyperref?) is not supported.</xsl:message>
692                         </xsl:when>
693                         <xsl:otherwise>
694                                 <xsl:text>\usepackage[color]{showkeys}&#10;</xsl:text>
695                                 <xsl:text>\definecolor{refkey}{gray}{0.5}&#10;</xsl:text>
696                                 <xsl:text>\definecolor{labelkey}{gray}{0.5}&#10;</xsl:text>
697                                 <xsl:text>% Rip off things from showkeys to highlight index references&#10;</xsl:text>
698                                 <xsl:text>\definecolor{indexkey}{gray}{.5}%&#10;</xsl:text>
699                                 <xsl:text>\makeatletter&#10;</xsl:text>
700                                 <xsl:text>\def\SK@indexcolor{\color{indexkey}}&#10;</xsl:text>
701                                 <xsl:text>\def\SK@@@index#1{\@bsphack\SK@\SK@@index{#1}\begingroup\SK@index{#1}\endgroup\@esphack}&#10;</xsl:text>
702                                 <xsl:text>\def\SK@@index#1>#2\SK@{\leavevmode\vbox to\z@{\vss \SK@indexcolor \rlap{\vrule\raise .75em\hbox{}{\circle*{5}}}}}&#10;</xsl:text>
703                                 <xsl:text>\AtBeginDocument{\let\SK@index\index&#10;\let\index\SK@@@index}&#10;</xsl:text>
704                                 <xsl:text>\makeatother&#10;</xsl:text>
705                         </xsl:otherwise>
706                 </xsl:choose>
707         </xsl:template>
708
709         <doc:template xmlns="">
710                 <refpurpose> Unavoidable &LaTeX; preamble shared by <doc:db
711                 basename="article">articles</doc:db> and <doc:db
712                 basename="book">books</doc:db>  </refpurpose>
713                 <doc:description>
714                         <para>Contains custom commands <emphasis>that you just can't get rid of!</emphasis></para>
715                 </doc:description>
716                 <doc:variables>
717                         <itemizedlist>
718                                 <listitem><simpara><xref linkend="param.latex.use.hyperref"/></simpara></listitem>
719                                 <listitem><simpara><xref linkend="param.latex.suppress.blank.page.headers"/></simpara></listitem>
720                                 <listitem><simpara><xref linkend="param.latex.use.ucs"/></simpara></listitem>
721                                 <listitem><simpara><xref linkend="param.latex.entities"/></simpara></listitem>
722                                 <listitem><simpara><xref linkend="param.latex.ucs.options"/></simpara></listitem>
723                                 <listitem><simpara><xref linkend="param.latex.inputenc"/></simpara></listitem>
724                                 <listitem><simpara><xref linkend="param.latex.fontenc"/></simpara></listitem>
725                         </itemizedlist>
726                 </doc:variables>
727                 <doc:seealso>
728                         <itemizedlist>
729                                 <listitem><simpara><xref linkend="template.latex.preamble.essential.biblio"/></simpara></listitem>
730                                 <listitem><simpara><xref linkend="template.latex.preamble.essential.callout"/></simpara></listitem>
731                                 <listitem><simpara><xref linkend="template.latex.preamble.essential.citation"/></simpara></listitem>
732                                 <listitem><simpara><xref linkend="template.latex.preamble.essential.footnote"/></simpara></listitem>
733                                 <listitem><simpara><xref linkend="template.latex.preamble.essential.glossary"/></simpara></listitem>
734                                 <listitem><simpara><xref linkend="template.latex.preamble.essential.index"/></simpara></listitem>
735                         </itemizedlist>
736                 </doc:seealso>
737         </doc:template>
738         <xsl:template name="generate.latex.essential.preamble">
739                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
740                 <xsl:text>\makeatletter&#10;</xsl:text>
741                 <xsl:text>\newcommand{\dbz}{\penalty \z@}&#10;</xsl:text>
742                 <xsl:text>\newcommand{\docbooktolatexpipe}{\ensuremath{|}\dbz}&#10;</xsl:text>
743                 <xsl:text>\newskip\docbooktolatexoldparskip&#10;</xsl:text>
744                 <xsl:text>\newcommand{\docbooktolatexnoparskip}{\docbooktolatexoldparskip=\parskip\parskip=0pt plus 1pt}&#10;</xsl:text>
745                 <xsl:text>\newcommand{\docbooktolatexrestoreparskip}{\parskip=\docbooktolatexoldparskip}&#10;</xsl:text>
746                 <xsl:if test="$latex.use.hyperref!='1'">
747                         <xsl:text>\newcommand{\href}[1]{{}}&#10;</xsl:text>
748                         <xsl:text>\newcommand{\hyperlink}[1]{{}}&#10;</xsl:text>
749                         <xsl:text>\newcommand{\hypertarget}[2]{#2}&#10;</xsl:text>
750                 </xsl:if>
751                 <!-- don't print headings on blank pages -->
752                 <xsl:if test="$latex.suppress.blank.page.headers=1">
753                         <xsl:text>\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else\hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}&#10;</xsl:text>
754                 </xsl:if>
755                 <xsl:if test="$latex.use.ucs='1'">
756                         <xsl:text>\usepackage[</xsl:text>
757                         <xsl:value-of select="$latex.ucs.options"/>
758                         <xsl:text>]{ucs}&#10;</xsl:text>
759                 </xsl:if>
760                 <xsl:if test="$latex.entities='catcode'">
761                         <xsl:text>\catcode`\&amp;=\active\def&amp;{\@ifnextchar##{\begingroup\@sanitize\@docbooktolatexunicode\@gobble}{\&amp;}}&#10;</xsl:text>
762                         <xsl:if test="$latex.use.ucs!='1'">
763                                 <xsl:text><![CDATA[
764 % A few example Unicode characters.
765 % For full support, use the unicode pacakge from Dominique Unruh/CTAN.
766 %       \else\ifnum#1=8216{\textquoteleft}%
767 %       \else\ifnum#1=8217{\textquoteright}%
768 \newcommand{\unichar}[1]{%
769         \ifnum#1=8211{--}%
770         \else\ifnum#1=8212{---}%
771         \else\ifnum#1=8216{`}%
772         \else\ifnum#1=8217{'}%
773         \else\ifnum#1=8218{\glq}%
774         \else\ifnum#1=8220{``}%
775         \else\ifnum#1=8221{''}%
776         \else\ifnum#1=8222{\glqq}%
777         \else\&\##1;\fi%
778         \fi\fi\fi\fi\fi%
779         \fi\fi%
780 }
781 ]]></xsl:text>
782                         </xsl:if>
783                         <xsl:text>\def\@docbooktolatexunicode#1;{\endgroup\edef\@dbtemp{#1}\unichar{\@dbtemp}}&#10;</xsl:text>
784                 </xsl:if>
785                 <xsl:if test="$latex.inputenc!=''">
786                         <xsl:text>\usepackage[</xsl:text>
787                         <xsl:value-of select="$latex.inputenc"/>
788                         <xsl:text>]{inputenc}&#10;</xsl:text>
789                 </xsl:if>
790                 <xsl:if test="$latex.fontenc!=''">
791                         <xsl:text>\usepackage[</xsl:text>
792                         <xsl:value-of select="$latex.fontenc"/>
793                         <xsl:text>]{fontenc}&#10;</xsl:text>
794                 </xsl:if>
795                 <!-- make proper headers for unnumbered chapter-level components -->
796                 <!-- TODO make proper headers for unnumbered section-level components -->
797                 <xsl:text><![CDATA[
798 \ifx\dblatex@chaptersmark\@undefined\def\dblatex@chaptersmark#1{\markboth{\MakeUppercase{#1}}{}}\fi
799 \let\save@makeschapterhead\@makeschapterhead
800 \def\dblatex@makeschapterhead#1{\vspace*{-80pt}\save@makeschapterhead{#1}}
801 \def\@makeschapterhead#1{\dblatex@makeschapterhead{#1}\dblatex@chaptersmark{#1}}
802 ]]></xsl:text>
803                 <xsl:call-template name="latex.preamble.essential.biblio"/>
804                 <xsl:call-template name="latex.preamble.essential.callout"/>
805                 <xsl:call-template name="latex.preamble.essential.citation"/>
806                 <xsl:call-template name="latex.preamble.essential.footnote"/>
807                 <xsl:call-template name="latex.preamble.essential.glossary"/>
808                 <xsl:call-template name="latex.preamble.essential.index"/>
809                 <xsl:text><![CDATA[
810 \def\docbooktolatexgobble{\expandafter\@gobble}
811 % Prevent multiple openings of the same aux file
812 % (happens when backref is used with multiple bibliography environments)
813 \ifx\AfterBeginDocument\undefined\let\AfterBeginDocument\AtBeginDocument\fi
814 \AfterBeginDocument{
815    \let\latex@@starttoc\@starttoc
816    \def\@starttoc#1{%
817       \@ifundefined{docbooktolatex@aux#1}{%
818          \global\@namedef{docbooktolatex@aux#1}{}%
819          \latex@@starttoc{#1}%
820       }{}
821    }
822 }
823 % --------------------------------------------
824 % Hacks for honouring row/entry/@align
825 % (\hspace not effective when in paragraph mode)
826 % Naming convention for these macros is:
827 % 'docbooktolatex' 'align' {alignment-type} {position-within-entry}
828 % where r = right, l = left, c = centre
829 \newcommand{\docbooktolatex@align}[2]{\protect\ifvmode#1\else\ifx\LT@@tabarray\@undefined#2\else#1\fi\fi}
830 \newcommand{\docbooktolatexalignll}{\docbooktolatex@align{\raggedright}{}}
831 \newcommand{\docbooktolatexalignlr}{\docbooktolatex@align{}{\hspace*\fill}}
832 \newcommand{\docbooktolatexaligncl}{\docbooktolatex@align{\centering}{\hfill}}
833 \newcommand{\docbooktolatexaligncr}{\docbooktolatex@align{}{\hspace*\fill}}
834 \newcommand{\docbooktolatexalignrl}{\protect\ifvmode\raggedleft\else\hfill\fi}
835 \newcommand{\docbooktolatexalignrr}{}
836 \ifx\captionswapskip\@undefined\newcommand{\captionswapskip}{}\fi
837 ]]></xsl:text>
838                 <xsl:text>\makeatother&#10;</xsl:text>
839         </xsl:template>
840
841         <doc:template>
842                 <refpurpose> Preamble for certain floats </refpurpose>
843         </doc:template>
844         <xsl:template name="latex.float.preamble">
845                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
846                 <xsl:text>% Commands to manage/style/create floats      &#10;</xsl:text>
847                 <xsl:text>% figures, tables, algorithms, examples, eqn  &#10;</xsl:text>
848                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
849                 <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
850                 <xsl:text> \restylefloat{figure}&#10;</xsl:text>
851                 <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
852                 <xsl:text> \restylefloat{table}&#10;</xsl:text>
853                 <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
854                 <xsl:text> \newfloat{program}{ht}{lop}[section]&#10;</xsl:text>
855                 <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
856                 <xsl:text> \newfloat{example}{ht}{loe}[section]&#10;</xsl:text>
857                 <xsl:text> \floatname{example}{</xsl:text>
858                 <xsl:call-template name="gentext.element.name">
859                         <xsl:with-param name="element.name">example</xsl:with-param>
860                 </xsl:call-template>
861                 <xsl:text>}&#10;</xsl:text>
862                 <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
863                 <xsl:text> \newfloat{dbequation}{ht}{loe}[section]&#10;</xsl:text>
864                 <xsl:text> \makeatletter\def\toclevel@dbequation{0}\makeatother&#10;</xsl:text>
865                 <xsl:text> \floatname{dbequation}{</xsl:text>
866                 <xsl:call-template name="gentext.element.name">
867                         <xsl:with-param name="element.name">equation</xsl:with-param>
868                 </xsl:call-template>
869                 <xsl:text>}&#10;</xsl:text>
870                 <xsl:text> \floatstyle{boxed}&#10;</xsl:text>
871                 <xsl:text> \newfloat{algorithm}{ht}{loa}[section]&#10;</xsl:text>
872                 <xsl:text> \floatname{algorithm}{Algorithm}&#10;</xsl:text>
873         </xsl:template>
874
875         <doc:param name="latex.pdf.preamble" xmlns="">
876                 <doc:description>
877                         <screen>
878                                 \usepackage{ifthen}
879                                 % --------------------------------------------
880                                 % Check for PDFLaTeX/LaTeX 
881                                 % --------------------------------------------
882                                 \newif\ifpdf
883                                 \ifx\pdfoutput\undefined
884                                 \pdffalse % we are not running PDFLaTeX
885                                 \else
886                                 \pdfoutput=1 % we are running PDFLaTeX
887                                 \pdftrue
888                                 \fi
889                                 % --------------------------------------------
890                                 % Load graphicx package with pdf if needed 
891                                 % --------------------------------------------
892                                 \ifpdf
893                                 \usepackage[pdftex]{graphicx}
894                                 \pdfcompresslevel=9
895                                 \else
896                                 \usepackage{graphicx}
897                                 \fi
898                         </screen>
899                 </doc:description>
900         </doc:param>
901         <xsl:param name="latex.pdf.preamble">
902                 <xsl:text>\usepackage{ifthen}&#10;</xsl:text>
903                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
904                 <xsl:text>% Check for PDFLaTeX/LaTeX &#10;</xsl:text>
905                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
906                 <xsl:text>\newif\ifpdf&#10;</xsl:text>
907                 <xsl:text>\ifx\pdfoutput\undefined&#10;</xsl:text>
908                 <xsl:text>\pdffalse % we are not running PDFLaTeX&#10;</xsl:text>
909                 <xsl:text>\else&#10;</xsl:text>
910                 <xsl:text>\pdfoutput=1 % we are running PDFLaTeX&#10;</xsl:text>
911                 <xsl:text>\pdftrue&#10;</xsl:text>
912                 <xsl:text>\fi&#10;</xsl:text>
913                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
914                 <xsl:text>% Load graphicx package with pdf if needed &#10;</xsl:text>
915                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
916                 <xsl:text>\ifpdf&#10;</xsl:text>
917                 <xsl:text>\usepackage[pdftex]{graphicx}&#10;</xsl:text>
918                 <xsl:text>\pdfcompresslevel=9&#10;</xsl:text>
919                 <xsl:text>\else&#10;</xsl:text>
920                 <xsl:text>\usepackage{graphicx}&#10;</xsl:text>
921                 <xsl:text>\fi&#10;</xsl:text>
922         </xsl:param>
923
924         <doc:template name="latex.hyperref.preamble" xmlns="">
925                 <refpurpose> Manage the part of the preamble that handles the hyperref package.</refpurpose>
926                 <doc:description>
927                         <para> This template outputs the LaTeX code <literal>\usepackage[...]{hyperref}</literal>
928                         in order to use hyperlinks, backrefs and other goodies. If PDF support is activated, 
929                         outputs laTeX code to detect whether the document is being compiled with 
930                         <filename>pdflatex</filename> or <filename>latex</filename> to supply the
931                         right parameters (pdftex, dvips, etc).
932                         <doc:todo> The package options should be optained
933                         from XSL variables.</doc:todo>
934                         </para>
935                         <para>Default Value with PDF support:
936                         <screen>
937                                 % --------------------------------------------
938                                 % Load hyperref package with pdf if needed 
939                                 % --------------------------------------------
940                                 \ifpdf
941                                 \usepackage[pdftex,bookmarksnumbered,colorlinks,backref, bookmarks, breaklinks, linktocpage]{hyperref}
942                                 \else
943                                 \usepackage[bookmarksnumbered,colorlinks,backref, bookmarks, breaklinks, linktocpage]{hyperref}
944                                 \fi
945                                 % --------------------------------------------
946                         </screen>
947                         </para>
948                         <para>Default Value without PDF support:
949                         <screen>
950                                 % --------------------------------------------
951                                 % Load hyperref package 
952                                 % --------------------------------------------
953                                 \usepackage[bookmarksnumbered,colorlinks,backref, bookmarks, breaklinks, linktocpage]{hyperref}
954                         </screen>
955                         </para>
956                 </doc:description>
957                 <doc:variables>
958                         <itemizedlist>
959                                 <listitem><simpara><xref linkend="param.latex.pdf.support"/></simpara></listitem>
960                                 <listitem><simpara><xref linkend="param.latex.hyperref.param.common"/></simpara></listitem>
961                                 <listitem><simpara><xref linkend="param.latex.hyperref.param.pdftex"/></simpara></listitem>
962                                 <listitem><simpara><xref linkend="param.latex.hyperref.param.dvips"/></simpara></listitem>
963                         </itemizedlist>
964                 </doc:variables>
965         </doc:template>
966         <xsl:template name="latex.hyperref.preamble">
967                 <xsl:choose>
968                 <xsl:when test="$latex.pdf.support=1">
969                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
970                         <xsl:text>% Load hyperref package with pdf if needed &#10;</xsl:text>
971                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
972                         <xsl:text>\ifpdf&#10;</xsl:text>
973                         <xsl:text>\usepackage[pdftex,</xsl:text>
974                         <xsl:value-of select="$latex.hyperref.param.common" />
975                         <xsl:text>,</xsl:text>
976                         <xsl:value-of select="$latex.hyperref.param.pdftex" />
977                         <xsl:text>]{hyperref}&#10;</xsl:text>
978                         <xsl:text>\else&#10;</xsl:text>
979                         <xsl:text>\usepackage[</xsl:text>
980                         <xsl:value-of select="$latex.hyperref.param.common" />
981                         <xsl:text>,</xsl:text>
982                         <xsl:value-of select="$latex.hyperref.param.dvips" />
983                         <xsl:text>]{hyperref}&#10;</xsl:text>
984                         <!--
985                         <xsl:text>\makeatletter\def\pdfmark@[#1]#2{}\makeatother&#10;</xsl:text>
986                         -->
987                         <xsl:text>\fi&#10;</xsl:text>
988                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
989                 </xsl:when>
990                 <xsl:otherwise>
991                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
992                         <xsl:text>% Load hyperref package &#10;</xsl:text>
993                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
994                         <xsl:text>\usepackage[</xsl:text>
995                         <xsl:value-of select="$latex.hyperref.param.common" />
996                         <xsl:text>,</xsl:text>
997                         <xsl:value-of select="$latex.hyperref.param.dvips" />
998                         <xsl:text>]{hyperref}&#10;</xsl:text>
999                         <!--
1000                         <xsl:text>\makeatletter\def\pdfmark@[#1]#2{}\makeatother&#10;</xsl:text>
1001                         -->
1002                 </xsl:otherwise>
1003                 </xsl:choose>
1004         </xsl:template>
1005
1006         <doc:param xmlns="">
1007                 <refpurpose> &LaTeX; mathematics support  </refpurpose>
1008         </doc:param>
1009         <xsl:param name="latex.math.preamble">
1010                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
1011                 <xsl:text>% Math support                                &#10;</xsl:text>
1012                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
1013                 <xsl:text>\usepackage{amsmath,amsthm, amsfonts, amssymb, amsxtra,amsopn}&#10;</xsl:text>
1014                 <xsl:text>%\newtheorem{thm}{Theorem}[section]&#10;</xsl:text>
1015                 <xsl:text>%\newtheorem{cor}[section]{Corollary}&#10;</xsl:text>
1016                 <xsl:text>%\newtheorem{lem}[section]{Lemma}&#10;</xsl:text>
1017                 <xsl:text>%\newtheorem{defn}[section]{Definition}&#10;</xsl:text>
1018                 <xsl:text>%\newtheorem{prop}[section]{Proposition}&#10;</xsl:text>
1019                 <xsl:text>%\newtheorem{ax}{Axiom}&#10;</xsl:text>
1020                 <xsl:text>%\newtheorem{theorem}[section]{Theorem}&#10;</xsl:text>
1021                 <xsl:text>%\newtheorem{corollary}{Corollary}&#10;</xsl:text>
1022                 <xsl:text>%\newtheorem{lemma}{Lemma}&#10;</xsl:text>
1023                 <xsl:text>%\newtheorem{proposition}{Proposition}&#10;</xsl:text>
1024                 <xsl:text>%\theoremstyle{definition}&#10;</xsl:text>
1025                 <xsl:text>%\newtheorem{definition}{Definition}&#10;</xsl:text>
1026                 <xsl:text>%\theoremstyle{remark}&#10;</xsl:text>
1027                 <xsl:text>%\newtheorem{rem}{Remark}&#10;</xsl:text>
1028                 <xsl:text>%\newtheorem*{notation}{Notation}&#10;</xsl:text>
1029                 <xsl:text>%\newcommand{\ntt}{\normalfont\ttfamily}&#10;</xsl:text>
1030                 <xsl:text>%\newcommand{\thmref}[1]{Theorem~\ref{#1}}&#10;</xsl:text>
1031                 <xsl:text>%\newcommand{\secref}[1]{\S\ref{#1}}&#10;</xsl:text>
1032                 <xsl:text>%\newcommand{\lemref}[1]{Lemma~\ref{#1}}&#10;</xsl:text>
1033                 <xsl:text> \newcommand{\bysame}{\mbox{\rule{3em}{.4pt}}\,}&#10;</xsl:text>
1034                 <xsl:text> \newcommand{\A}{\mathcal{A}}&#10;</xsl:text>
1035                 <xsl:text> \newcommand{\B}{\mathcal{B}}&#10;</xsl:text>
1036                 <xsl:text> \newcommand{\XcY}{{(X,Y)}}&#10;</xsl:text>
1037                 <xsl:text> \newcommand{\SX}{{S_X}}&#10;</xsl:text>
1038                 <xsl:text> \newcommand{\SY}{{S_Y}}&#10;</xsl:text>
1039                 <xsl:text> \newcommand{\SXY}{{S_{X,Y}}}&#10;</xsl:text>
1040                 <xsl:text> \newcommand{\SXgYy}{{S_{X|Y}(y)}}&#10;</xsl:text>
1041                 <xsl:text> \newcommand{\Cw}[1]{{\hat C_#1(X|Y)}}&#10;</xsl:text>
1042                 <xsl:text> \newcommand{\G}{{G(X|Y)}}&#10;</xsl:text>
1043                 <xsl:text> \newcommand{\PY}{{P_{\mathcal{Y}}}}&#10;</xsl:text>
1044                 <xsl:text> \newcommand{\X}{\mathcal{X}}&#10;</xsl:text>
1045                 <xsl:text> \newcommand{\wt}{\widetilde}&#10;</xsl:text>
1046                 <xsl:text> \newcommand{\wh}{\widehat}&#10;</xsl:text>
1047                 <xsl:text> % --------------------------------------------&#10;</xsl:text>
1048                 <xsl:text> %\DeclareMathOperator{\per}{per}&#10;</xsl:text>
1049                 <xsl:text> \DeclareMathOperator{\cov}{cov}&#10;</xsl:text>
1050                 <xsl:text> \DeclareMathOperator{\non}{non}&#10;</xsl:text>
1051                 <xsl:text> \DeclareMathOperator{\cf}{cf}&#10;</xsl:text>
1052                 <xsl:text> \DeclareMathOperator{\add}{add}&#10;</xsl:text>
1053                 <xsl:text> \DeclareMathOperator{\Cham}{Cham}&#10;</xsl:text>
1054                 <xsl:text> \DeclareMathOperator{\IM}{Im}&#10;</xsl:text>
1055                 <xsl:text> \DeclareMathOperator{\esssup}{ess\,sup}&#10;</xsl:text>
1056                 <xsl:text> \DeclareMathOperator{\meas}{meas}&#10;</xsl:text>
1057                 <xsl:text> \DeclareMathOperator{\seg}{seg}&#10;</xsl:text>
1058                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
1059         </xsl:param>
1060
1061         <doc:template xmlns="">
1062                 <refpurpose> Declared graphic extensions </refpurpose>
1063                 <doc:description>
1064                 <para>
1065                 This template checks whether the user has overridden <command>grafic.default.extension</command>
1066                 Otherwise, declares .pdf, .png, .jpg if using pdflatex and .eps if using latex.
1067                 </para>
1068                 <programlisting><![CDATA[
1069 <xsl:template name="latex.graphicext">
1070 <xsl:choose>
1071 <xsl:when test="$graphic.default.extension !=''">
1072         <xsl:text>\DeclareGraphicsExtensions{</xsl:text>
1073         <xsl:if test="not(contains($graphic.default.extension,'.'))">
1074                 <xsl:text>.</xsl:text>
1075         </xsl:if>
1076         <xsl:value-of select="$graphic.default.extension"/>
1077         <xsl:text>}&#10;</xsl:text>
1078 </xsl:when>
1079 <xsl:otherwise>
1080         <xsl:choose>
1081         <xsl:when test="$latex.pdf.support=1">
1082                 <xsl:text>\ifpdf&#10;</xsl:text>
1083                 <xsl:text>\DeclareGraphicsExtensions{.pdf,.png,.jpg}&#10;</xsl:text>
1084                 <xsl:text>\else&#10;</xsl:text>
1085                 <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
1086                 <xsl:text>\fi&#10;</xsl:text>
1087         </xsl:when>
1088         <xsl:otherwise>
1089                 <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
1090         </xsl:otherwise>
1091         </xsl:choose>
1092 </xsl:otherwise>
1093 </xsl:choose>
1094 </xsl:template>
1095 ]]></programlisting>
1096                 </doc:description>
1097                 <doc:variables>
1098                         <itemizedlist>
1099                                 <listitem><simpara><xref linkend="param.graphic.default.extension"/></simpara></listitem>
1100                                 <listitem><simpara><xref linkend="param.latex.pdf.support"/></simpara></listitem>
1101                         </itemizedlist>
1102                 </doc:variables>
1103         </doc:template>
1104         <xsl:template name="latex.graphicext">
1105                 <xsl:choose>
1106                         <xsl:when test="$graphic.default.extension !=''">
1107                                 <xsl:text>\DeclareGraphicsExtensions{</xsl:text>
1108                                 <xsl:if test="not(contains($graphic.default.extension,'.'))">
1109                                         <xsl:text>.</xsl:text>
1110                                 </xsl:if>
1111                                 <xsl:value-of select="$graphic.default.extension"/>
1112                                 <xsl:text>}&#10;</xsl:text>
1113                         </xsl:when>
1114                         <xsl:otherwise>
1115                                 <xsl:choose>
1116                                 <xsl:when test="$latex.pdf.support=1">
1117                                         <xsl:text>\ifpdf&#10;</xsl:text>
1118                                         <xsl:text>\DeclareGraphicsExtensions{.pdf,.png,.jpg}&#10;</xsl:text>
1119                                         <xsl:text>\else&#10;</xsl:text>
1120                                         <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
1121                                         <xsl:text>\fi&#10;</xsl:text>
1122                                 </xsl:when>
1123                                 <xsl:otherwise>
1124                                         <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
1125                                 </xsl:otherwise>
1126                                 </xsl:choose>
1127                         </xsl:otherwise>
1128                 </xsl:choose>
1129         </xsl:template>
1130 </xsl:stylesheet>
1131