2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3
<!--#############################################################################
4
| $Id: admonition.mod.xsl,v 1.15 2004/08/12 05:33:43 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.15 2004/08/12 05:33:43 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>
105
<listitem><simpara><xref linkend="param.latex.admonition.title.style"/></simpara></listitem>
110
<xsl:param name="latex.admonition.environment">
111
<xsl:text>% ---------------------------------------------- </xsl:text>
112
<xsl:text>% Define a new LaTeX environment (adminipage) </xsl:text>
113
<xsl:text>% ---------------------------------------------- </xsl:text>
114
<xsl:text>\newenvironment{admminipage}% </xsl:text>
115
<xsl:text>{ % this code corresponds to the \begin{adminipage} command </xsl:text>
116
<xsl:text> \begin{Sbox}% </xsl:text>
117
<xsl:text> \begin{minipage}% </xsl:text>
118
<xsl:text>} %done </xsl:text>
119
<xsl:text>{ % this code corresponds to the \end{adminipage} command </xsl:text>
120
<xsl:text> \end{minipage} </xsl:text>
121
<xsl:text> \end{Sbox} </xsl:text>
122
<xsl:text> \fbox{\TheSbox} </xsl:text>
123
<xsl:text>} %done </xsl:text>
124
<xsl:text>% ---------------------------------------------- </xsl:text>
125
<xsl:text>% Define a new LaTeX length (admlength) </xsl:text>
126
<xsl:text>% ---------------------------------------------- </xsl:text>
127
<xsl:text>\newlength{\admlength} </xsl:text>
128
<xsl:text>% ---------------------------------------------- </xsl:text>
129
<xsl:text>% Define a new LaTeX environment (admonition) </xsl:text>
130
<xsl:text>% With 2 parameters: </xsl:text>
131
<xsl:text>% #1 The file (e.g. note.pdf) </xsl:text>
132
<xsl:text>% #2 The caption </xsl:text>
133
<xsl:text>% ---------------------------------------------- </xsl:text>
134
<xsl:text>\newenvironment{admonition}[2] </xsl:text>
135
<xsl:text>{ % this code corresponds to the \begin{admonition} command </xsl:text>
136
<xsl:text> \hspace{0mm}\newline\hspace*\fill\newline </xsl:text>
137
<xsl:text> \noindent </xsl:text>
138
<xsl:text> \setlength{\fboxsep}{5pt} </xsl:text>
139
<xsl:text> \setlength{\admlength}{\linewidth} </xsl:text>
140
<xsl:text> \addtolength{\admlength}{-10\fboxsep} </xsl:text>
141
<xsl:text> \addtolength{\admlength}{-10\fboxrule} </xsl:text>
142
<xsl:text> \admminipage{\admlength} </xsl:text>
143
<xsl:text> {</xsl:text>
144
<xsl:value-of select="$latex.admonition.title.style"/>
145
<xsl:text>{#2}}</xsl:text>
146
<xsl:text> \newline </xsl:text>
147
<xsl:text> \\[1mm] </xsl:text>
148
<xsl:text> \sffamily </xsl:text>
150
If we cannot find the admon.graphics.path;
151
Comment out the next line (\includegraphics).
152
This tactic is to avoid deleting the \includegraphics
153
altogether, as that could confuse a person trying to
154
find the use of parameter #1 in the environment.
156
<xsl:if test="$admon.graphics.path=''">
157
<xsl:text>%</xsl:text>
159
<xsl:text> \includegraphics[</xsl:text> <xsl:value-of select="$latex.admonition.imagesize" /> <xsl:text>]{#1} </xsl:text>
160
<xsl:text> \addtolength{\admlength}{-1cm} </xsl:text>
161
<xsl:text> \addtolength{\admlength}{-20pt} </xsl:text>
162
<xsl:text> \begin{minipage}[lt]{\admlength} </xsl:text>
163
<xsl:text> \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt </xsl:text>
164
<xsl:text>} %done </xsl:text>
165
<xsl:text>{ % this code corresponds to the \end{admonition} command </xsl:text>
166
<xsl:text> \vspace{5mm} </xsl:text>
167
<xsl:text> \end{minipage} </xsl:text>
168
<xsl:text> \endadmminipage </xsl:text>
169
<xsl:text> \vspace{.5em} </xsl:text>
170
<xsl:text> \par </xsl:text>
171
<xsl:text>} </xsl:text>
174
<doc:template xmlns="">
175
<refpurpose> Choose an admonition graphic </refpurpose>
179
For each admonition element
180
(<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>),
181
this template chooses the graphics filename. If the admonition element is
182
not known, the <doc:db>note</doc:db> graphic is used.
193
The name of the adminition. &DB2LaTeX; includes
194
different graphics for different adminitions. By
195
default, <literal>name</literal> defaults to the
197
condition="xslt">local-name</function> of the
207
<xsl:template name="admon.graphic">
208
<xsl:param name="name" select="local-name(.)"/>
210
<xsl:when test="$name='note'">note</xsl:when>
211
<xsl:when test="$name='warning'">warning</xsl:when>
212
<xsl:when test="$name='caution'">caution</xsl:when>
213
<xsl:when test="$name='tip'">tip</xsl:when>
214
<xsl:when test="$name='important'">important</xsl:when>
215
<xsl:otherwise>note</xsl:otherwise>
219
<doc:template xmlns="">
220
<refpurpose> Process admonitions </refpurpose>
224
Invokes the environment provided by <xref
225
linkend="param.latex.admonition.environment"/>
226
and applies templates.
229
<note><para>An admonition will look something like this <doc:db>note</doc:db>.</para></note>
234
There can be <quote>excessive</quote> whitespace between
235
the bottom of the admonition area and a subsequent paragraph.
241
<listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
242
<listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
246
<simplelist type='inline'>
254
<listitem><para>&mapping;</para></listitem>
259
<xsl:template match="note|important|warning|caution|tip">
260
<xsl:call-template name="map.begin">
261
<xsl:with-param name="keyword">admonition</xsl:with-param>
262
<xsl:with-param name="string">
263
<xsl:text>{</xsl:text>
264
<xsl:value-of select="$admon.graphics.path"/><xsl:text>/</xsl:text>
265
<xsl:call-template name="admon.graphic"/>
266
<xsl:text>}{</xsl:text>
268
<xsl:when test="title and $latex.apply.title.templates.admonitions='1'">
269
<xsl:call-template name="extract.object.title">
270
<xsl:with-param name="object" select="."/>
274
<xsl:call-template name="gentext.element.name"/>
277
<xsl:text>}</xsl:text>
280
<xsl:call-template name="content-templates"/>
281
<xsl:call-template name="map.end">
282
<xsl:with-param name="keyword">admonition</xsl:with-param>