This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[sfrench/samba-autobuild/.git] / docs / docbook / xslt / db2latex / preamble.mod.xsl
1 <?xml version='1.0'?>
2 <!--############################################################################# 
3 |       $Id: preamble.mod.xsl,v 1.1.2.1 2003/05/01 14:06:15 jelmer Exp $                
4 |- #############################################################################
5 |       $Author: jelmer $
6 |
7 |   PURPOSE: Variables and templates to manage LaTeX preamble. 
8 + ############################################################################## -->
9
10 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
11     xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
12     exclude-result-prefixes="doc" version='1.0'>
13
14
15     <doc:reference id="preamble" xmlns="">
16         <referenceinfo>
17             <releaseinfo role="meta">
18                 $Id: preamble.mod.xsl,v 1.1.2.1 2003/05/01 14:06:15 jelmer Exp $
19             </releaseinfo>
20         <authorgroup>
21             <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
22             <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
23         </authorgroup>
24             <copyright><year>2000</year><year>2001</year><year>2002</year><year>2003</year>
25                 <holder>Ramon Casellas</holder>
26             </copyright>
27         </referenceinfo>
28
29         <title>Variables and Templates used in LaTeX Preamble Generation</title>
30
31         <partintro>
32             <section><title>Introduction</title>
33                 <para> This section described the variables and templates that are used in the generation of
34                     the outtput LaTeX preamble. Basically, the LaTeX preamble depends on the XML document, that is,
35                     on whether it is an article or a book.</para>
36             </section>
37
38             <section><title>Flow</title>
39                 <section><title>Articles</title>
40                     <para></para>
41                 </section>
42                 <section><title>Books</title>
43                     <para></para>
44                 </section>
45             </section>
46         </partintro>
47     </doc:reference>
48
49
50
51     <!--#############################################################################
52     |   generate.latex.article.preamble and generate.latex.book.preamble        
53     |- #############################################################################
54     |   Top-level named templates.
55     |   LaTeX Preamble.
56     |
57     + ############################################################################## -->
58
59     <!-- DOCUMENTATION -->
60     <doc:template name="generate.latex.article.preamble" xmlns="">
61         <refpurpose> Top level template, called by article template, 
62             responsible of generating the LaTeX preamble according to user 
63             XSL variables and templates.
64         </refpurpose>
65         <refdescription>
66             <formalpara><title>Overview</title>
67                 If the xsl:variable <literal>latex.override</literal>
68                 is empty, the template outputs <literal>latex.article.preamblestart</literal> 
69                 and calls <literal>generate.latex.common.preamble</literal>. Otherwise,
70                 it outputs the value of <literal>latex.override</literal> and
71                 exists.
72             </formalpara>
73         </refdescription>
74         <refauthor>Ramon Casellas <email>casellas@aist.enst.fr</email></refauthor>
75     </doc:template>
76
77     <!-- TEMPLATE -->
78     <xsl:template name="generate.latex.article.preamble">
79         <xsl:choose>
80             <xsl:when test="$latex.override = ''">
81                 <xsl:value-of select="$latex.article.preamblestart"/>
82                 <xsl:value-of select="$latex.article.preamble.pre"/>
83                 <xsl:call-template name="label.id"/>
84                 <xsl:call-template name="generate.latex.common.preamble"/>
85                 <xsl:call-template name="generate.latex.essential.preamble"/>
86                 <xsl:value-of select="$latex.article.preamble.post"/>
87             </xsl:when>
88             <xsl:otherwise>
89                 <xsl:value-of select="$latex.override"/>
90                 <xsl:call-template name="generate.latex.essential.preamble"/>
91             </xsl:otherwise>
92         </xsl:choose>
93     </xsl:template>
94
95     <!-- DOCUMENTATION -->
96     <doc:template name="generate.latex.book.preamble" xmlns="">
97         <refpurpose> Top level template, called by book template, 
98             responsible of generating the LaTeX preamble according to user 
99             XSL variables and templates.
100         </refpurpose>
101         <refdescription>
102             <formalpara><title>Overview</title>
103                 If the xsl:variable <literal>latex.override</literal>
104                 is empty, the template outputs <literal>latex.book.preamblestart</literal> 
105                 and calls <literal>generate.latex.common.preamble</literal>. Otherwise,
106                 it outputs the value of <literal>latex.override</literal> and
107                 exists.
108             </formalpara>
109         </refdescription>
110         <refauthor>Ramon Casellas <email>casellas@aist.enst.fr</email></refauthor>
111     </doc:template>
112
113     <!-- TEMPLATE -->
114     <xsl:template name="generate.latex.book.preamble">
115         <xsl:choose>
116             <xsl:when test="$latex.override = ''">
117                 <xsl:value-of select="$latex.book.preamblestart"/>
118                 <xsl:value-of select="$latex.book.preamble.pre"/>
119                 <xsl:call-template name="label.id"/>
120                 <xsl:call-template name="generate.latex.common.preamble"/>
121                 <xsl:call-template name="generate.latex.essential.preamble"/>
122                 <xsl:value-of select="$latex.book.preamble.post"/>
123             </xsl:when>
124             <xsl:otherwise>
125                 <xsl:value-of select="$latex.override"/>
126                 <xsl:call-template name="generate.latex.essential.preamble"/>
127             </xsl:otherwise>
128         </xsl:choose>
129     </xsl:template>
130
131
132
133
134
135
136     <!--#############################################################################
137     |   latex.article.preamblestart and latex.book.preamblestart        
138     |- #############################################################################
139     |
140     + ############################################################################## -->
141
142     <doc:variable name="latex.article.preamblestart" xmlns="">
143         <refpurpose> Generated Document class for articles.  </refpurpose>
144         <refdescription>
145         </refdescription>
146         <refreturn>
147             <screen>
148                 % --------------------------------------------  
149                 % Autogenerated LaTeX file for articles         
150                 % --------------------------------------------  
151                 \ifx\pdfoutput\undefined
152                 \documentclass[spanish,french,english,a4paper,10pt,twoside,twocolumn]{article}
153                 \else
154                 \documentclass[pdftex,spanish,french,english,a4paper,10pt,twoside,twocolumn]{article}
155                 \fi
156             </screen>
157         </refreturn>
158     </doc:variable>
159
160     <xsl:variable name="latex.article.preamblestart">
161         <xsl:text>% --------------------------------------------        &#10;</xsl:text>
162         <xsl:text>% Autogenerated LaTeX file for articles                       &#10;</xsl:text>
163         <xsl:text>% --------------------------------------------        &#10;</xsl:text>
164         <xsl:text>\ifx\pdfoutput\undefined&#10;</xsl:text>
165         <xsl:text>\documentclass[</xsl:text>
166         <xsl:value-of select='$latex.documentclass.common' />
167         <xsl:text>,</xsl:text>
168         <xsl:value-of select='$latex.documentclass.article' />
169         <xsl:text>,</xsl:text>
170         <xsl:value-of select='$latex.documentclass.pdftex' />
171         <xsl:text>]{</xsl:text>
172         <xsl:choose>
173                 <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
174                 <xsl:otherwise><xsl:text>article</xsl:text></xsl:otherwise>
175         </xsl:choose>
176         <xsl:text>}&#10;</xsl:text>
177         <xsl:text>\else&#10;</xsl:text>
178         <xsl:text>\documentclass[pdftex,</xsl:text>
179         <xsl:value-of select='$latex.documentclass.common' />
180         <xsl:text>,</xsl:text>
181         <xsl:value-of select='$latex.documentclass.article' />
182         <xsl:text>,</xsl:text>
183         <xsl:value-of select='$latex.documentclass.dvips' />
184         <xsl:text>]{</xsl:text>
185         <xsl:choose>
186                 <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
187                 <xsl:otherwise><xsl:text>article</xsl:text></xsl:otherwise>
188         </xsl:choose>
189         <xsl:text>}&#10;</xsl:text>
190         <xsl:text>\fi&#10;</xsl:text>
191     </xsl:variable>
192         
193     <doc:variable name="latex.book.preamblestart" xmlns="">
194         <refpurpose>Generated Document class for books. </refpurpose>
195         <refdescription>
196         </refdescription>
197         <refreturn>
198             <screen>
199                 % ------------------------------------------------------------
200                 % Autogenerated LaTeX file for books    
201                 % ------------------------------------------------------------  
202                 \ifx\pdfoutput\undefined
203                 \documentclass[spanish,french,english,a4paper,twoside,openright,10pt,final]{report}     
204                 \else
205                 \documentclass[pdftex,spanish,french,english,a4paper,twoside,openright,10pt,final]{report}
206                 \fi
207             </screen>
208         </refreturn>
209     </doc:variable>
210
211     <xsl:variable name="latex.book.preamblestart">
212         <xsl:text>% ------------------------------------------------------------        &#10;</xsl:text>
213         <xsl:text>% Autogenerated LaTeX file for books  &#10;</xsl:text>
214         <xsl:text>% ------------------------------------------------------------        &#10;</xsl:text>
215         <xsl:text>\ifx\pdfoutput\undefined&#10;</xsl:text>
216         <xsl:text>\documentclass[</xsl:text>
217         <xsl:value-of select='$latex.documentclass.common' />
218         <xsl:text>,</xsl:text>
219         <xsl:value-of select='$latex.documentclass.book' />
220         <xsl:text>,</xsl:text>
221         <xsl:value-of select='$latex.documentclass.pdftex' />
222         <xsl:text>]{</xsl:text>
223         <xsl:choose>
224                 <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
225                 <xsl:otherwise><xsl:text>report</xsl:text></xsl:otherwise>
226         </xsl:choose>
227         <xsl:text>}&#10;</xsl:text>
228         <xsl:text>\else&#10;</xsl:text>
229         <xsl:text>\documentclass[pdftex,</xsl:text>
230         <xsl:value-of select='$latex.documentclass.common' />
231         <xsl:text>,</xsl:text>
232         <xsl:value-of select='$latex.documentclass.book' />
233         <xsl:text>,</xsl:text>
234         <xsl:value-of select='$latex.documentclass.dvips' />
235         <xsl:text>]{</xsl:text>
236         <xsl:choose>
237                 <xsl:when test="$latex.documentclass!=''"><xsl:value-of select="$latex.documentclass" /></xsl:when>
238                 <xsl:otherwise><xsl:text>report</xsl:text></xsl:otherwise>
239         </xsl:choose>
240         <xsl:text>}&#10;</xsl:text>
241         <xsl:text>\fi&#10;</xsl:text>
242     </xsl:variable>
243
244     <!--#############################################################################
245     |   generate.latex.common.preamble 
246     |- #############################################################################
247     |
248     + ############################################################################## -->
249
250     <doc:variable name="generate.latex.common.preamble" xmlns="">
251         <refpurpose> Common LaTeX preamble shared by articles and books, and other
252             document classes. Most of the packages and package options are managed here </refpurpose>
253         <refdescription>
254         </refdescription>
255         <refreturn>
256             The LaTeX preamble, after the document class and before the <literal>\begin{document}</literal>
257             command.
258         </refreturn>
259     </doc:variable>
260
261
262
263         <xsl:template name="generate.latex.common.preamble">
264         <xsl:choose>
265                 <xsl:when test="$latex.pdf.support=1"><xsl:value-of select="$latex.pdf.preamble"/></xsl:when>
266                 <xsl:otherwise><xsl:text>\usepackage{graphicx}&#10;</xsl:text></xsl:otherwise>
267         </xsl:choose>
268         <xsl:if test="local-name(.)='article'">
269             <xsl:value-of select="$latex.article.varsets"/>
270         </xsl:if>
271         <xsl:if test="local-name(.)='book'">
272             <xsl:value-of select="$latex.book.varsets"/>
273         </xsl:if>
274         <xsl:if test="$latex.use.fancyhdr=1">
275             <xsl:text>\usepackage{fancyhdr}&#10;</xsl:text>
276             <xsl:call-template name="generate.latex.pagestyle"/>
277             <!-- 
278             Add dollar...
279             <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>
280             <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>
281             <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>
282             <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>
283             <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>
284             <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> 
285             -->
286
287             <xsl:text>\renewcommand{\headrulewidth}{0.4pt}&#10;</xsl:text>
288             <xsl:text>\renewcommand{\footrulewidth}{0.4pt}&#10;</xsl:text>
289         </xsl:if>
290
291         <xsl:text>% ---------------------- &#10;</xsl:text>
292         <xsl:text>% Most Common Packages   &#10;</xsl:text>
293         <xsl:text>% ---------------------- &#10;</xsl:text>
294         <xsl:if test="$latex.use.makeidx=1"><xsl:text>\usepackage{makeidx} &#10;</xsl:text></xsl:if>
295         <xsl:text>\usepackage{varioref}         &#10;</xsl:text>
296         <xsl:text>\usepackage{latexsym}         &#10;</xsl:text>
297         <xsl:text>\usepackage{enumerate}         &#10;</xsl:text>
298         <xsl:if test="$latex.use.fancybox=1">
299                 <!-- must be before \usepackage{fancyvrb} -->
300                 <xsl:text>\usepackage{fancybox}      &#10;</xsl:text>
301         </xsl:if>
302         <xsl:text>\usepackage{float}       &#10;</xsl:text>
303         <xsl:text>\usepackage{ragged2e}       &#10;</xsl:text>
304         <xsl:if test="$latex.babel.language!=''">
305                 <xsl:text>\usepackage[</xsl:text><xsl:value-of select="$latex.babel.language" /><xsl:text>]{babel} &#10;</xsl:text>
306         </xsl:if>
307         <xsl:if test="$latex.use.fancyvrb=1">
308                 <!-- must be after \usepackage{fancybox} -->
309                 <xsl:text>\usepackage{fancyvrb}         &#10;</xsl:text>
310                 <xsl:text>\makeatletter\@namedef{FV@fontfamily@default}{\def\FV@FontScanPrep{}\def\FV@FontFamily{}}\makeatother&#10;</xsl:text>
311                 <xsl:if test="$latex.fancyvrb.tabsize!=''">
312                         <xsl:text>\fvset{obeytabs=true,tabsize=</xsl:text>
313                         <xsl:value-of select="$latex.fancyvrb.tabsize"/>
314                         <xsl:text>}&#10;</xsl:text>
315                 </xsl:if>
316         </xsl:if>
317         <xsl:if test="$latex.use.isolatin1=1"><xsl:text>\usepackage{isolatin1}         &#10;</xsl:text></xsl:if>
318         <xsl:if test="$latex.use.parskip=1"><xsl:text>\usepackage{parskip}         &#10;</xsl:text></xsl:if>
319         <xsl:if test="$latex.use.rotating=1"><xsl:text>\usepackage{rotating}         &#10;</xsl:text></xsl:if>
320         <xsl:if test="$latex.use.subfigure=1"><xsl:text>\usepackage{subfigure}         &#10;</xsl:text></xsl:if>
321         <xsl:if test="$latex.use.tabularx=1"><xsl:text>\usepackage{tabularx}         &#10;</xsl:text></xsl:if>
322         <xsl:if test="$latex.use.umoline=1"><xsl:text>\usepackage{umoline}         &#10;</xsl:text></xsl:if>
323         <xsl:if test="$latex.use.url=1"><xsl:text>\usepackage{url}         &#10;</xsl:text></xsl:if>
324
325         <!-- Configure document font. -->
326         <xsl:if test="$latex.document.font != 'default'">
327             <xsl:text>% ---------------&#10;</xsl:text>
328             <xsl:text>% Document Font  &#10;</xsl:text>
329             <xsl:text>% ---------------&#10;</xsl:text>
330             <xsl:text>\usepackage{</xsl:text><xsl:value-of select="$latex.document.font"/><xsl:text>}&#10;</xsl:text>
331         </xsl:if>
332         <!-- Support for keywords. -->
333         <xsl:text> \def\keywords{\vspace{-.3em}&#10;</xsl:text>
334         <xsl:text> \if@twocolumn&#10;</xsl:text>
335         <xsl:text> \small{\itshape &#10;</xsl:text>
336         <xsl:call-template name="gentext">
337         <xsl:with-param name="key">keywords</xsl:with-param>
338     </xsl:call-template>
339         <xsl:text> }\/\bfseries---$\!$%&#10;</xsl:text>
340         <xsl:text> \else&#10;</xsl:text>
341         <xsl:text> \begin{center}\small\bfseries &#10;</xsl:text>
342         <xsl:call-template name="gentext">
343         <xsl:with-param name="key">keywords</xsl:with-param>
344     </xsl:call-template>
345         <xsl:text> \end{center}\quotation\small&#10;</xsl:text>
346         <xsl:text> \fi}&#10;</xsl:text>
347         <xsl:text> \def\endkeywords{\vspace{0.6em}\par\if@twocolumn\else\endquotation\fi&#10;</xsl:text>
348         <xsl:text> \normalsize\rmfamily}&#10;</xsl:text>
349
350         <xsl:if test="$latex.math.support=1"><xsl:value-of select="$latex.math.preamble"/></xsl:if>
351         <xsl:if test="$latex.use.hyperref=1">
352                 <xsl:call-template name="latex.hyperref.preamble"/>
353         </xsl:if>
354         <xsl:value-of select="$latex.admonition.environment"/>
355         <xsl:call-template name="latex.float.preamble"/>
356         <xsl:call-template name="latex.graphicext"/>
357         <xsl:choose>
358                 <xsl:when test='$latex.caption.swapskip=1'>
359                         <xsl:text>% --------------------------------------------&#10;</xsl:text>
360                         <xsl:text>% $latex.caption.swapskip enabled for $formal.title.placement support&#10;</xsl:text>
361                         <xsl:text>\newlength{\docbooktolatextempskip}&#10;</xsl:text>
362                         <xsl:text>\newcommand{\captionswapskip}{\setlength{\docbooktolatextempskip}{\abovecaptionskip}</xsl:text>
363                         <xsl:text>\setlength{\abovecaptionskip}{\belowcaptionskip}</xsl:text>
364                         <xsl:text>\setlength{\belowcaptionskip}{\docbooktolatextempskip}}&#10;</xsl:text>
365                 </xsl:when>
366                 <xsl:otherwise>
367                         <xsl:text>\newcommand{\captionswapskip}{}&#10;</xsl:text>
368                 </xsl:otherwise>
369         </xsl:choose>
370         <xsl:if test='$latex.hyphenation.tttricks=1'>
371                 <xsl:text>% --------------------------------------------&#10;</xsl:text>
372                 <xsl:text>% Better linebreaks&#10;</xsl:text>
373                 <xsl:text>\newcommand{\docbookhyphenatedot}[1]{{\hyphenchar\font=`\.\relax #1\hyphenchar\font=`\-}}&#10;</xsl:text>
374                 <xsl:text>\newcommand{\docbookhyphenatefilename}[1]{{\hyphenchar\font=`\.\relax #1\hyphenchar\font=`\-}}&#10;</xsl:text>
375                 <xsl:text>\newcommand{\docbookhyphenateurl}[1]{{\hyphenchar\font=`\/\relax #1\hyphenchar\font=`\-}}&#10;</xsl:text>
376         </xsl:if>
377     </xsl:template>
378
379     <doc:variable name="generate.latex.essential.preamble" xmlns="">
380         <refpurpose> Unavoidable LaTeX preamble shared by articles and books </refpurpose>
381         <refdescription>
382             <para>Contains custom commands <emphasis>that you just can't get rid of!</emphasis></para>
383         </refdescription>
384     </doc:variable>
385         <xsl:template name="generate.latex.essential.preamble">
386         <xsl:text>% --------------------------------------------&#10;</xsl:text>
387         <xsl:text>\makeatletter&#10;</xsl:text>
388         <xsl:if test="$latex.use.hyperref!='1'">
389                 <xsl:text>\newcommand{\href}[1]{{}}&#10;</xsl:text>
390                 <xsl:text>\newcommand{\hyperlink}[1]{{}}&#10;</xsl:text>
391                 <xsl:text>\newcommand{\hypertarget}[2]{#2}&#10;</xsl:text>
392         </xsl:if>
393         <xsl:if test="$latex.use.ucs='1'">
394                 <xsl:text>\usepackage[</xsl:text>
395                 <xsl:value-of select="$latex.ucs.options"/>
396                 <xsl:text>]{ucs}&#10;</xsl:text>
397         </xsl:if>
398         <xsl:if test="$latex.entities='catcode'">
399                 <xsl:text>\catcode`\&amp;=\active\def&amp;{\@ifnextchar##{\@docbooktolatexunicode\@gobble}{\&amp;}}&#10;</xsl:text>
400                 <xsl:if test="$latex.use.ucs!='1'">
401                         <xsl:text><![CDATA[
402 % A few example Unicode characters.
403 % For full support, use the unicode pacakge from Dominique Unruh/CTAN.
404 \newcommand{\unichar}[1]{%
405         \ifnum#1=8212---%
406         \else\&\##1;\fi%
407 }
408 ]]></xsl:text>
409                 </xsl:if>
410                 <xsl:text>\def\@docbooktolatexunicode#1;{\edef\@dbtemp{#1}\unichar{\@dbtemp}}&#10;</xsl:text>
411         </xsl:if>
412         <xsl:if test="$latex.entities='unicode'">
413       <xsl:text>\usepackage[utf8]{inputenc}&#10;</xsl:text>
414         </xsl:if>
415         <xsl:text><![CDATA[
416 \def\docbooktolatexgobble{\expandafter\@gobble}
417 % Facilitate use of \cite with \label
418 \newcommand{\docbooktolatexbibaux}[2]{%
419   \protected@write\@auxout{}{\string\global\string\@namedef{docbooktolatexcite@#1}{#2}}
420 }
421 \newcommand{\docbooktolatexcite}[2]{%
422   \@ifundefined{docbooktolatexcite@#1}%
423   {\cite{#1}}%
424   {\def\@docbooktolatextemp{#2}\ifx\@docbooktolatextemp\@empty%
425    \cite{\@nameuse{docbooktolatexcite@#1}}%
426    \else\cite[#2]{\@nameuse{docbooktolatexcite@#1}}%
427    \fi%
428   }%
429 }
430 \newcommand{\docbooktolatexbackcite}[1]{%
431   \ifx\Hy@backout\@undefined\else%
432     \@ifundefined{docbooktolatexcite@#1}{%
433       % emit warning?
434     }{%
435       \ifBR@verbose%
436         \PackageInfo{backref}{back cite \string`#1\string' as \string`\@nameuse{docbooktolatexcite@#1}\string'}%
437       \fi%
438       \Hy@backout{\@nameuse{docbooktolatexcite@#1}}%
439     }%
440   \fi%
441 }
442 % --------------------------------------------
443 % A way to honour <footnoteref>s
444 % Blame j-devenish (at) users.sourceforge.net
445 % In any other LaTeX context, this would probably go into a style file.
446 \newcommand{\docbooktolatexusefootnoteref}[1]{\@ifundefined{@fn@label@#1}%
447   {\hbox{\@textsuperscript{\normalfont ?}}%
448     \@latex@warning{Footnote label `#1' was not defined}}%
449   {\@nameuse{@fn@label@#1}}}
450 \newcommand{\docbooktolatexmakefootnoteref}[1]{%
451   \protected@write\@auxout{}%
452     {\global\string\@namedef{@fn@label@#1}{\@makefnmark}}%
453   \@namedef{@fn@label@#1}{\hbox{\@textsuperscript{\normalfont ?}}}%
454   }
455 % --------------------------------------------
456 % Hacks for honouring row/entry/@align
457 % (\hspace not effective when in paragraph mode)
458 % Naming convention for these macros is:
459 % 'docbooktolatex' 'align' {alignment-type} {position-within-entry}
460 % where r = right, l = left, c = centre
461 \newcommand{\docbooktolatexalignrl}{\protect\ifvmode\raggedleft\else\hfill\fi}
462 \newcommand{\docbooktolatexalignrr}{\protect}
463 \newcommand{\docbooktolatexalignll}{\protect\ifvmode\raggedright\else\fi}
464 \newcommand{\docbooktolatexalignlr}{\protect\ifvmode\else\hspace*\fill\fi}
465 \newcommand{\docbooktolatexaligncl}{\protect\ifvmode\centering\else\hfill\fi}
466 \newcommand{\docbooktolatexaligncr}{\protect\ifvmode\else\hspace*\fill\fi}
467 \ifx\captionswapskip\@undefined\newcommand{\captionswapskip}{}\fi
468 \makeatother
469 ]]></xsl:text>
470         </xsl:template>
471
472
473
474     <!--#############################################################################
475     |   Auxiliary templates and variables 
476     |- #############################################################################
477     |
478     + ############################################################################## -->
479
480     <doc:template name="latex.float.preamble" xmlns="">
481         <refpurpose> 
482         </refpurpose>
483         <refdescription>
484         </refdescription>
485     </doc:template>
486     <xsl:template name="latex.float.preamble">
487         <xsl:text>% --------------------------------------------&#10;</xsl:text>
488         <xsl:text>% Commands to manage/style/create floats      &#10;</xsl:text>
489         <xsl:text>% figures, tables, algorithms, examples, eqn  &#10;</xsl:text>
490         <xsl:text>% --------------------------------------------&#10;</xsl:text>
491         <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
492         <xsl:text> \restylefloat{figure}&#10;</xsl:text>
493         <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
494         <xsl:text> \restylefloat{table}&#10;</xsl:text>
495         <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
496         <xsl:text> \newfloat{program}{ht}{lop}[section]&#10;</xsl:text>
497         <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
498         <xsl:text> \newfloat{example}{ht}{loe}[section]&#10;</xsl:text>
499         <xsl:text> \floatname{example}{</xsl:text>
500         <xsl:call-template name="gentext.element.name">
501             <xsl:with-param name="element.name">example</xsl:with-param>
502         </xsl:call-template>
503         <xsl:text>}&#10;</xsl:text>
504         <xsl:text> \floatstyle{ruled}&#10;</xsl:text>
505         <xsl:text> \newfloat{dbequation}{ht}{loe}[section]&#10;</xsl:text>
506         <xsl:text> \floatname{dbequation}{</xsl:text>
507         <xsl:call-template name="gentext.element.name">
508             <xsl:with-param name="element.name">equation</xsl:with-param>
509         </xsl:call-template>
510         <xsl:text>}&#10;</xsl:text>
511         <xsl:text> \floatstyle{boxed}&#10;</xsl:text>
512         <xsl:text> \newfloat{algorithm}{ht}{loa}[section]&#10;</xsl:text>
513         <xsl:text> \floatname{algorithm}{Algorithm}&#10;</xsl:text>
514     </xsl:template>
515
516
517
518
519     <!-- DOCUMENTATION -->
520     <doc:variable name="latex.pdf.preamble" xmlns="">
521         <refpurpose> 
522         </refpurpose>
523         <refdescription>
524             <formalpara><title>Default Value:</title>
525                 <screen>
526                     \usepackage{ifthen}
527                     % --------------------------------------------
528                     % Check for PDFLaTeX/LaTeX 
529                     % --------------------------------------------
530                     \newif\ifpdf
531                     \ifx\pdfoutput\undefined
532                     \pdffalse % we are not running PDFLaTeX
533                     \else
534                     \pdfoutput=1 % we are running PDFLaTeX
535                     \pdftrue
536                     \fi
537                     % --------------------------------------------
538                     % Load graphicx package with pdf if needed 
539                     % --------------------------------------------
540                     \ifpdf
541                     \usepackage[pdftex]{graphicx}
542                     \pdfcompresslevel=9
543                     \else
544                     \usepackage{graphicx}
545                     \fi
546                 </screen>
547             </formalpara>
548         </refdescription>
549         <refauthor>Ramon Casellas <email>casellas@aist.enst.fr</email></refauthor>
550     </doc:variable>
551
552     <!-- VARIABLE -->
553     <xsl:variable name="latex.pdf.preamble">
554         <xsl:text>\usepackage{ifthen}&#10;</xsl:text>
555         <xsl:text>% --------------------------------------------&#10;</xsl:text>
556         <xsl:text>% Check for PDFLaTeX/LaTeX &#10;</xsl:text>
557         <xsl:text>% --------------------------------------------&#10;</xsl:text>
558         <xsl:text>\newif\ifpdf&#10;</xsl:text>
559         <xsl:text>\ifx\pdfoutput\undefined&#10;</xsl:text>
560         <xsl:text>\pdffalse % we are not running PDFLaTeX&#10;</xsl:text>
561         <xsl:text>\else&#10;</xsl:text>
562         <xsl:text>\pdfoutput=1 % we are running PDFLaTeX&#10;</xsl:text>
563         <xsl:text>\pdftrue&#10;</xsl:text>
564         <xsl:text>\fi&#10;</xsl:text>
565         <xsl:text>% --------------------------------------------&#10;</xsl:text>
566         <xsl:text>% Load graphicx package with pdf if needed &#10;</xsl:text>
567         <xsl:text>% --------------------------------------------&#10;</xsl:text>
568         <xsl:text>\ifpdf&#10;</xsl:text>
569         <xsl:text>\usepackage[pdftex]{graphicx}&#10;</xsl:text>
570         <xsl:text>\pdfcompresslevel=9&#10;</xsl:text>
571         <xsl:text>\else&#10;</xsl:text>
572         <xsl:text>\usepackage{graphicx}&#10;</xsl:text>
573         <xsl:text>\fi&#10;</xsl:text>
574     </xsl:variable>
575
576
577
578     <!-- DOCUMENTATION -->
579     <doc:template name="latex.hyperref.preamble" xmlns="">
580         <refpurpose> Manage the part of the preamble that handles the hyperref package.</refpurpose>
581         <refdescription>
582             <para> This template outputs the LaTeX code <literal>\usepackage[...]{hyperref}</literal>
583                 in order to use hyperlinks, backrefs and other goodies. If PDF support is activated, 
584                 outputs laTeX code to detect whether the document is being compiled with 
585                 <filename>pdflatex</filename> or <filename>latex</filename> to supply the
586                 right parameters (pdftex, dvips, etc). </para>
587             <formalpara><title>To Do</title> The package options should be optained
588                 from XSL variables.</formalpara>
589             <formalpara><title>Default Value with PDF support</title>
590                 <screen>
591                     % --------------------------------------------
592                     % Load hyperref package with pdf if needed 
593                     % --------------------------------------------
594                     \ifpdf
595                     \usepackage[pdftex,bookmarksnumbered,colorlinks,backref, bookmarks, breaklinks, linktocpage]{hyperref}
596                     \else
597                     \usepackage[dvips,bookmarksnumbered,colorlinks,backref, bookmarks, breaklinks, linktocpage]{hyperref}
598                     \fi
599                     % --------------------------------------------
600                 </screen>
601             </formalpara>
602             <formalpara><title>Default Value without PDF support</title>
603                 <screen>
604                     % --------------------------------------------
605                     % Load hyperref package 
606                     % --------------------------------------------
607                     \usepackage[dvips,bookmarksnumbered,colorlinks,backref, bookmarks, breaklinks, linktocpage]{hyperref}
608                 </screen>
609             </formalpara>
610         </refdescription>
611     </doc:template>
612     <!-- TEMPLATE -->
613     <xsl:template name="latex.hyperref.preamble">
614         <xsl:choose>
615         <xsl:when test="$latex.pdf.support=1">
616             <xsl:text>% --------------------------------------------&#10;</xsl:text>
617             <xsl:text>% Load hyperref package with pdf if needed &#10;</xsl:text>
618             <xsl:text>% --------------------------------------------&#10;</xsl:text>
619             <xsl:text>\ifpdf&#10;</xsl:text>
620             <xsl:text>\usepackage[pdftex,</xsl:text>
621                 <xsl:value-of select="$latex.hyperref.param.common" />
622                 <xsl:text>,</xsl:text>
623                 <xsl:value-of select="$latex.hyperref.param.pdftex" />
624                 <xsl:text>]{hyperref}&#10;</xsl:text>
625             <xsl:text>\else&#10;</xsl:text>
626             <xsl:text>\usepackage[dvips,</xsl:text>
627                 <xsl:value-of select="$latex.hyperref.param.common" />
628                 <xsl:text>,</xsl:text>
629                 <xsl:value-of select="$latex.hyperref.param.dvips" />
630                 <xsl:text>]{hyperref}&#10;</xsl:text>
631             <xsl:text>\fi&#10;</xsl:text>
632             <xsl:text>% --------------------------------------------&#10;</xsl:text>
633         </xsl:when>
634         <xsl:otherwise>
635             <xsl:text>% --------------------------------------------&#10;</xsl:text>
636             <xsl:text>% Load hyperref package &#10;</xsl:text>
637             <xsl:text>% --------------------------------------------&#10;</xsl:text>
638             <xsl:text>\usepackage[dvips,</xsl:text>
639                 <xsl:value-of select="$latex.hyperref.param.common" />
640                 <xsl:text>,</xsl:text>
641                 <xsl:value-of select="$latex.hyperref.param.dvips" />
642                 <xsl:text>]{hyperref}&#10;</xsl:text>
643         </xsl:otherwise>
644         </xsl:choose>
645     </xsl:template>
646
647
648
649
650
651
652
653
654
655
656
657
658
659     <!--#############################################################################
660     |   latex.math.preamble     
661     |-  #############################################################################
662     |   This "preamble chunk" declares usage of most common AMS packages.
663         |   Defines new useful commands. 
664     +   ############################################################################## -->
665
666     <!-- DOCUMENTATION -->
667     <doc:variable name="latex.math.preamble" xmlns="">
668         <refpurpose> Manage the math related preamble</refpurpose>
669         <refdescription>
670         </refdescription>
671     </doc:variable>
672
673     <!-- VARIABLE -->
674     <xsl:variable name="latex.math.preamble">
675         <xsl:text>% --------------------------------------------&#10;</xsl:text>
676         <xsl:text>% Math support                                &#10;</xsl:text>
677         <xsl:text>% --------------------------------------------&#10;</xsl:text>
678         <xsl:text>\usepackage{amsmath,amsthm, amsfonts, amssymb, amsxtra,amsopn}&#10;</xsl:text>
679         <xsl:text>%\newtheorem{thm}{Theorem}[section]&#10;</xsl:text>
680         <xsl:text>%\newtheorem{cor}[section]{Corollary}&#10;</xsl:text>
681         <xsl:text>%\newtheorem{lem}[section]{Lemma}&#10;</xsl:text>
682         <xsl:text>%\newtheorem{defn}[section]{Definition}&#10;</xsl:text>
683         <xsl:text>%\newtheorem{prop}[section]{Proposition}&#10;</xsl:text>
684         <xsl:text>%\newtheorem{ax}{Axiom}&#10;</xsl:text>
685         <xsl:text>%\newtheorem{theorem}[section]{Theorem}&#10;</xsl:text>
686         <xsl:text>%\newtheorem{corollary}{Corollary}&#10;</xsl:text>
687         <xsl:text>%\newtheorem{lemma}{Lemma}&#10;</xsl:text>
688         <xsl:text>%\newtheorem{proposition}{Proposition}&#10;</xsl:text>
689         <xsl:text>%\theoremstyle{definition}&#10;</xsl:text>
690         <xsl:text>%\newtheorem{definition}{Definition}&#10;</xsl:text>
691         <xsl:text>%\theoremstyle{remark}&#10;</xsl:text>
692         <xsl:text>%\newtheorem{rem}{Remark}&#10;</xsl:text>
693         <xsl:text>%\newtheorem*{notation}{Notation}&#10;</xsl:text>
694         <xsl:text>%\newcommand{\ntt}{\normalfont\ttfamily}&#10;</xsl:text>
695         <xsl:text>%\newcommand{\thmref}[1]{Theorem~\ref{#1}}&#10;</xsl:text>
696         <xsl:text>%\newcommand{\secref}[1]{\S\ref{#1}}&#10;</xsl:text>
697         <xsl:text>%\newcommand{\lemref}[1]{Lemma~\ref{#1}}&#10;</xsl:text>
698         <xsl:text> \newcommand{\bysame}{\mbox{\rule{3em}{.4pt}}\,}&#10;</xsl:text>
699         <xsl:text> \newcommand{\A}{\mathcal{A}}&#10;</xsl:text>
700         <xsl:text> \newcommand{\B}{\mathcal{B}}&#10;</xsl:text>
701         <xsl:text> \newcommand{\XcY}{{(X,Y)}}&#10;</xsl:text>
702         <xsl:text> \newcommand{\SX}{{S_X}}&#10;</xsl:text>
703         <xsl:text> \newcommand{\SY}{{S_Y}}&#10;</xsl:text>
704         <xsl:text> \newcommand{\SXY}{{S_{X,Y}}}&#10;</xsl:text>
705         <xsl:text> \newcommand{\SXgYy}{{S_{X|Y}(y)}}&#10;</xsl:text>
706         <xsl:text> \newcommand{\Cw}[1]{{\hat C_#1(X|Y)}}&#10;</xsl:text>
707         <xsl:text> \newcommand{\G}{{G(X|Y)}}&#10;</xsl:text>
708         <xsl:text> \newcommand{\PY}{{P_{\mathcal{Y}}}}&#10;</xsl:text>
709         <xsl:text> \newcommand{\X}{\mathcal{X}}&#10;</xsl:text>
710         <xsl:text> \newcommand{\wt}{\widetilde}&#10;</xsl:text>
711         <xsl:text> \newcommand{\wh}{\widehat}&#10;</xsl:text>
712         <xsl:text> % --------------------------------------------&#10;</xsl:text>
713         <xsl:text> %\DeclareMathOperator{\per}{per}&#10;</xsl:text>
714         <xsl:text> \DeclareMathOperator{\cov}{cov}&#10;</xsl:text>
715         <xsl:text> \DeclareMathOperator{\non}{non}&#10;</xsl:text>
716         <xsl:text> \DeclareMathOperator{\cf}{cf}&#10;</xsl:text>
717         <xsl:text> \DeclareMathOperator{\add}{add}&#10;</xsl:text>
718         <xsl:text> \DeclareMathOperator{\Cham}{Cham}&#10;</xsl:text>
719         <xsl:text> \DeclareMathOperator{\IM}{Im}&#10;</xsl:text>
720         <xsl:text> \DeclareMathOperator{\esssup}{ess\,sup}&#10;</xsl:text>
721         <xsl:text> \DeclareMathOperator{\meas}{meas}&#10;</xsl:text>
722         <xsl:text> \DeclareMathOperator{\seg}{seg}&#10;</xsl:text>
723         <xsl:text>% --------------------------------------------&#10;</xsl:text>
724     </xsl:variable>
725
726
727
728
729 <!--#############################################################################
730 |       latex.graphicext 
731 |- #############################################################################
732 |
733 + ############################################################################## -->
734
735 <doc:template name="latex.graphicext" xmlns="">
736 <refpurpose> Declared graphic extensions </refpurpose>
737 <refdescription>
738 This template checks whether the user has overriden <command>grafic.default.extension</command>
739 Otherwise, declares .pdf, .png, .jpg if using pdflatex and .eps if using latex.
740 <programlisting><![CDATA[
741 <xsl:template name="latex.graphicext">
742 <xsl:choose>
743 <xsl:when test="$graphic.default.extension !=''">
744         <xsl:text>\DeclareGraphicsExtensions{</xsl:text>
745         <xsl:if test="not(contains($graphic.default.extension,'.'))">
746                 <xsl:text>.</xsl:text>
747         </xsl:if>
748         <xsl:value-of select="$graphic.default.extension"/>
749         <xsl:text>}&#10;</xsl:text>
750 </xsl:when>
751 <xsl:otherwise>
752         <xsl:choose>
753         <xsl:when test="$latex.pdf.support=1">
754                 <xsl:text>\ifpdf&#10;</xsl:text>
755                 <xsl:text>\DeclareGraphicsExtensions{.pdf,.png,.jpg}&#10;</xsl:text>
756                 <xsl:text>\else&#10;</xsl:text>
757                 <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
758                 <xsl:text>\fi&#10;</xsl:text>
759         </xsl:when>
760         <xsl:otherwise>
761                 <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
762         </xsl:otherwise>
763         </xsl:choose>
764 </xsl:otherwise>
765 </xsl:choose>
766 </xsl:template>
767
768
769 ]]></programlisting>
770 </refdescription>
771 <refreturn>
772 </refreturn>
773 </doc:template>
774
775 <xsl:template name="latex.graphicext">
776 <xsl:choose>
777 <xsl:when test="$graphic.default.extension !=''">
778         <xsl:text>\DeclareGraphicsExtensions{</xsl:text>
779         <xsl:if test="not(contains($graphic.default.extension,'.'))">
780                 <xsl:text>.</xsl:text>
781         </xsl:if>
782         <xsl:value-of select="$graphic.default.extension"/>
783         <xsl:text>}&#10;</xsl:text>
784 </xsl:when>
785 <xsl:otherwise>
786         <xsl:choose>
787         <xsl:when test="$latex.pdf.support=1">
788                 <xsl:text>\ifpdf&#10;</xsl:text>
789                 <xsl:text>\DeclareGraphicsExtensions{.pdf,.png,.jpg}&#10;</xsl:text>
790                 <xsl:text>\else&#10;</xsl:text>
791                 <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
792                 <xsl:text>\fi&#10;</xsl:text>
793         </xsl:when>
794         <xsl:otherwise>
795                 <xsl:text>\DeclareGraphicsExtensions{.eps}&#10;</xsl:text>
796         </xsl:otherwise>
797         </xsl:choose>
798 </xsl:otherwise>
799 </xsl:choose>
800 </xsl:template>
801
802         <xsl:template name="generate.latex.cell.separator">
803                 <xsl:choose>
804                         <xsl:when test="$latex.entities='catcode'">
805                                 <xsl:text> \catcode`\&amp;=4 &amp;\catcode`\&amp;=\active </xsl:text>
806                         </xsl:when>
807                         <xsl:otherwise>
808                                 <xsl:text> &amp; </xsl:text>
809                         </xsl:otherwise>
810                 </xsl:choose>
811         </xsl:template>
812 </xsl:stylesheet>
813