2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3
<!--#############################################################################
4
| $Id: admonition.mod.xsl,v 1.14 2004/01/03 09:48:34 j-devenish Exp $
5
|- #############################################################################
6
| $Author: j-devenish $
7
+ ############################################################################## -->
9
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
11
exclude-result-prefixes="doc" version='1.0'>
13
<doc:reference name="admonition" xmlns="">
15
<releaseinfo role="meta">
16
$Id: admonition.mod.xsl,v 1.14 2004/01/03 09:48:34 j-devenish Exp $
23
<year>2000</year><year>2001</year><year>2002</year><year>2003</year>
24
<holder>Ramon Casellas</holder>
27
<doc:revision rcasver="1.6">&rev_2003_05;</doc:revision>
30
<title>Admonitions <filename>admonition.mod.xsl</filename></title>
34
&DocBook; includes admonitions (<doc:db>warning</doc:db>,
35
<doc:db>tip</doc:db>, <doc:db>important</doc:db>,
36
<doc:db>caution</doc:db>, <doc:db>note</doc:db>), which are set off
37
from the main text. &DB2LaTeX; places these in the normal text flow
38
but surrounds them with a box border.
43
<listitem><simpara><xref linkend="param.latex.use.fancybox"/></simpara></listitem>
44
<listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
45
<listitem><simpara><xref linkend="param.latex.admonition.imagesize"/></simpara></listitem>
46
<listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
54
Declares a new environment to be used for admonitions
59
This &LaTeX; environment is emitted during the preamble. That
60
environment has two mandatory parameters. Instances of the
61
environment are customised for each admonition via those
62
parameters. Instances will be typeset as boxed areas in the
68
The first argument is the filename for graphics (e.g.
69
<filename>$admon.graphics.path/warning</filename>).
70
The second argument is the admonition title or the associated
76
<title>Processing the <doc:db>warning</doc:db> admonition</title>
77
<para> When processing the admonition, the following code is generated: </para>
79
<![CDATA[\begin{admonition}{figures/warning}{My WARNING}
86
<!-- notes about spacing? -->
88
The environment uses graphics by default. This may generate errors or warnings
89
if &LaTeX; cannot find the graphics. If necessary, graphics may be disabled
90
via <xref linkend="param.admon.graphics.path"/>.
96
<listitem><simpara><xref linkend="template.para"/></simpara></listitem>
102
<listitem><simpara><xref linkend="param.latex.use.fancybox"/></simpara></listitem>
103
<listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
104
<listitem><simpara><xref linkend="param.latex.admonition.imagesize"/></simpara></listitem>
109
<xsl:param name="latex.admonition.environment">
110
<xsl:text>% ---------------------------------------------- </xsl:text>
111
<xsl:text>% Define a new LaTeX environment (adminipage) </xsl:text>
112
<xsl:text>% ---------------------------------------------- </xsl:text>
113
<xsl:text>\newenvironment{admminipage}% </xsl:text>
114
<xsl:text>{ % this code corresponds to the \begin{adminipage} command </xsl:text>
115
<xsl:text> \begin{Sbox}% </xsl:text>
116
<xsl:text> \begin{minipage}% </xsl:text>
117
<xsl:text>} %done </xsl:text>
118
<xsl:text>{ % this code corresponds to the \end{adminipage} command </xsl:text>
119
<xsl:text> \end{minipage} </xsl:text>
120
<xsl:text> \end{Sbox} </xsl:text>
121
<xsl:text> \fbox{\TheSbox} </xsl:text>
122
<xsl:text>} %done </xsl:text>
123
<xsl:text>% ---------------------------------------------- </xsl:text>
124
<xsl:text>% Define a new LaTeX length (admlength) </xsl:text>
125
<xsl:text>% ---------------------------------------------- </xsl:text>
126
<xsl:text>\newlength{\admlength} </xsl:text>
127
<xsl:text>% ---------------------------------------------- </xsl:text>
128
<xsl:text>% Define a new LaTeX environment (admonition) </xsl:text>
129
<xsl:text>% With 2 parameters: </xsl:text>
130
<xsl:text>% #1 The file (e.g. note.pdf) </xsl:text>
131
<xsl:text>% #2 The caption </xsl:text>
132
<xsl:text>% ---------------------------------------------- </xsl:text>
133
<xsl:text>\newenvironment{admonition}[2] </xsl:text>
134
<xsl:text>{ % this code corresponds to the \begin{admonition} command </xsl:text>
135
<xsl:text> \hspace{0mm}\newline\hspace*\fill\newline </xsl:text>
136
<xsl:text> \noindent </xsl:text>
137
<xsl:text> \setlength{\fboxsep}{5pt} </xsl:text>
138
<xsl:text> \setlength{\admlength}{\linewidth} </xsl:text>
139
<xsl:text> \addtolength{\admlength}{-10\fboxsep} </xsl:text>
140
<xsl:text> \addtolength{\admlength}{-10\fboxrule} </xsl:text>
141
<xsl:text> \admminipage{\admlength} </xsl:text>
142
<xsl:text> {\bfseries \sc\large{#2}}</xsl:text>
143
<xsl:text> \newline </xsl:text>
144
<xsl:text> \\[1mm] </xsl:text>
145
<xsl:text> \sffamily </xsl:text>
147
If we cannot find the admon.graphics.path;
148
Comment out the next line (\includegraphics).
149
This tactic is to avoid deleting the \includegraphics
150
altogether, as that could confuse a person trying to
151
find the use of parameter #1 in the environment.
153
<xsl:if test="$admon.graphics.path=''">
154
<xsl:text>%</xsl:text>
156
<xsl:text> \includegraphics[</xsl:text> <xsl:value-of select="$latex.admonition.imagesize" /> <xsl:text>]{#1} </xsl:text>
157
<xsl:text> \addtolength{\admlength}{-1cm} </xsl:text>
158
<xsl:text> \addtolength{\admlength}{-20pt} </xsl:text>
159
<xsl:text> \begin{minipage}[lt]{\admlength} </xsl:text>
160
<xsl:text> \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt </xsl:text>
161
<xsl:text>} %done </xsl:text>
162
<xsl:text>{ % this code corresponds to the \end{admonition} command </xsl:text>
163
<xsl:text> \vspace{5mm} </xsl:text>
164
<xsl:text> \end{minipage} </xsl:text>
165
<xsl:text> \endadmminipage </xsl:text>
166
<xsl:text> \vspace{.5em} </xsl:text>
167
<xsl:text> \par </xsl:text>
168
<xsl:text>} </xsl:text>
171
<doc:template xmlns="">
172
<refpurpose> Choose an admonition graphic </refpurpose>
176
For each admonition element
177
(<doc:db>warning</doc:db>, <doc:db>tip</doc:db>, <doc:db>important</doc:db>, <doc:db>caution</doc:db>, <doc:db>note</doc:db>),
178
this template chooses the graphics filename. If the admonition element is
179
not known, the <doc:db>note</doc:db> graphic is used.
190
The name of the adminition. &DB2LaTeX; includes
191
different graphics for different adminitions. By
192
default, <literal>name</literal> defaults to the
194
condition="xslt">local-name</function> of the
204
<xsl:template name="admon.graphic">
205
<xsl:param name="name" select="local-name(.)"/>
207
<xsl:when test="$name='note'">note</xsl:when>
208
<xsl:when test="$name='warning'">warning</xsl:when>
209
<xsl:when test="$name='caution'">caution</xsl:when>
210
<xsl:when test="$name='tip'">tip</xsl:when>
211
<xsl:when test="$name='important'">important</xsl:when>
212
<xsl:otherwise>note</xsl:otherwise>
216
<doc:template xmlns="">
217
<refpurpose> Process admonitions </refpurpose>
221
Invokes the environment provided by <xref
222
linkend="param.latex.admonition.environment"/>
223
and applies templates.
226
<note><para>An admonition will look something like this <doc:db>note</doc:db>.</para></note>
231
There can be <quote>excessive</quote> whitespace between
232
the bottom of the admonition area and a subsequent paragraph.
238
<listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
239
<listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
243
<simplelist type='inline'>
251
<listitem><para>&mapping;</para></listitem>
256
<xsl:template match="note|important|warning|caution|tip">
257
<xsl:call-template name="map.begin">
258
<xsl:with-param name="keyword">admonition</xsl:with-param>
259
<xsl:with-param name="string">
260
<xsl:text>{</xsl:text>
261
<xsl:value-of select="$admon.graphics.path"/><xsl:text>/</xsl:text>
262
<xsl:call-template name="admon.graphic"/>
263
<xsl:text>}{</xsl:text>
265
<xsl:when test="title and $latex.apply.title.templates.admonitions='1'">
266
<xsl:call-template name="extract.object.title">
267
<xsl:with-param name="object" select="."/>
271
<xsl:call-template name="gentext.element.name"/>
274
<xsl:text>}</xsl:text>
277
<xsl:call-template name="content-templates"/>
278
<xsl:call-template name="map.end">
279
<xsl:with-param name="keyword">admonition</xsl:with-param>