| 1 | <?xml version='1.0'?>
|
|---|
| 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 | + ############################################################################## -->
|
|---|
| 8 | <xsl:stylesheet
|
|---|
| 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'>
|
|---|
| 12 |
|
|---|
| 13 | <doc:reference name="admonition" xmlns="">
|
|---|
| 14 | <referenceinfo>
|
|---|
| 15 | <releaseinfo role="meta">
|
|---|
| 16 | $Id: admonition.mod.xsl,v 1.14 2004/01/03 09:48:34 j-devenish Exp $
|
|---|
| 17 | </releaseinfo>
|
|---|
| 18 | <authorgroup>
|
|---|
| 19 | &ramon;
|
|---|
| 20 | &james;
|
|---|
| 21 | </authorgroup>
|
|---|
| 22 | <copyright>
|
|---|
| 23 | <year>2000</year><year>2001</year><year>2002</year><year>2003</year>
|
|---|
| 24 | <holder>Ramon Casellas</holder>
|
|---|
| 25 | </copyright>
|
|---|
| 26 | <revhistory>
|
|---|
| 27 | <doc:revision rcasver="1.6">&rev_2003_05;</doc:revision>
|
|---|
| 28 | </revhistory>
|
|---|
| 29 | </referenceinfo>
|
|---|
| 30 | <title>Admonitions <filename>admonition.mod.xsl</filename></title>
|
|---|
| 31 | <partintro>
|
|---|
| 32 | <para>
|
|---|
| 33 |
|
|---|
| 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.
|
|---|
| 39 |
|
|---|
| 40 | </para>
|
|---|
| 41 | <doc:variables>
|
|---|
| 42 | <itemizedlist>
|
|---|
| 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>
|
|---|
| 47 | </itemizedlist>
|
|---|
| 48 | </doc:variables>
|
|---|
| 49 | </partintro>
|
|---|
| 50 | </doc:reference>
|
|---|
| 51 |
|
|---|
| 52 | <doc:param xmlns="">
|
|---|
| 53 | <refpurpose>
|
|---|
| 54 | Declares a new environment to be used for admonitions
|
|---|
| 55 | </refpurpose>
|
|---|
| 56 | <doc:description>
|
|---|
| 57 | <para>
|
|---|
| 58 |
|
|---|
| 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
|
|---|
| 63 | document flow.
|
|---|
| 64 |
|
|---|
| 65 | </para>
|
|---|
| 66 | <para>
|
|---|
| 67 |
|
|---|
| 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
|
|---|
| 71 | generic text.
|
|---|
| 72 |
|
|---|
| 73 | </para>
|
|---|
| 74 |
|
|---|
| 75 | <example>
|
|---|
| 76 | <title>Processing the <doc:db>warning</doc:db> admonition</title>
|
|---|
| 77 | <para> When processing the admonition, the following code is generated: </para>
|
|---|
| 78 | <programlisting>
|
|---|
| 79 | <![CDATA[\begin{admonition}{figures/warning}{My WARNING}
|
|---|
| 80 | ...
|
|---|
| 81 | \end{admonition}]]>
|
|---|
| 82 | </programlisting>
|
|---|
| 83 | </example>
|
|---|
| 84 | </doc:description>
|
|---|
| 85 | <doc:notes>
|
|---|
| 86 | <!-- notes about spacing? -->
|
|---|
| 87 | <para>
|
|---|
| 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"/>.
|
|---|
| 91 | </para>
|
|---|
| 92 | </doc:notes>
|
|---|
| 93 | <!--
|
|---|
| 94 | <doc:seealso>
|
|---|
| 95 | <itemizedlist>
|
|---|
| 96 | <listitem><simpara><xref linkend="template.para"/></simpara></listitem>
|
|---|
| 97 | </itemizedlist>
|
|---|
| 98 | </doc:seealso>
|
|---|
| 99 | -->
|
|---|
| 100 | <doc:variables>
|
|---|
| 101 | <itemizedlist>
|
|---|
| 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 | </itemizedlist>
|
|---|
| 106 | </doc:variables>
|
|---|
| 107 | </doc:param>
|
|---|
| 108 |
|
|---|
| 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>
|
|---|
| 146 | <!--
|
|---|
| 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.
|
|---|
| 152 | -->
|
|---|
| 153 | <xsl:if test="$admon.graphics.path=''">
|
|---|
| 154 | <xsl:text>%</xsl:text>
|
|---|
| 155 | </xsl:if>
|
|---|
| 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>
|
|---|
| 169 | </xsl:param>
|
|---|
| 170 |
|
|---|
| 171 | <doc:template xmlns="">
|
|---|
| 172 | <refpurpose> Choose an admonition graphic </refpurpose>
|
|---|
| 173 | <doc:description>
|
|---|
| 174 | <para>
|
|---|
| 175 |
|
|---|
| 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.
|
|---|
| 180 |
|
|---|
| 181 | </para>
|
|---|
| 182 | </doc:description>
|
|---|
| 183 | <doc:params>
|
|---|
| 184 | <variablelist>
|
|---|
| 185 | <varlistentry>
|
|---|
| 186 | <term>name</term>
|
|---|
| 187 | <listitem>
|
|---|
| 188 | <para>
|
|---|
| 189 |
|
|---|
| 190 | The name of the adminition. &DB2LaTeX; includes
|
|---|
| 191 | different graphics for different adminitions. By
|
|---|
| 192 | default, <literal>name</literal> defaults to the
|
|---|
| 193 | XSLT <function
|
|---|
| 194 | condition="xslt">local-name</function> of the
|
|---|
| 195 | current node.
|
|---|
| 196 |
|
|---|
| 197 | </para>
|
|---|
| 198 | </listitem>
|
|---|
| 199 | </varlistentry>
|
|---|
| 200 | </variablelist>
|
|---|
| 201 | </doc:params>
|
|---|
| 202 | </doc:template>
|
|---|
| 203 |
|
|---|
| 204 | <xsl:template name="admon.graphic">
|
|---|
| 205 | <xsl:param name="name" select="local-name(.)"/>
|
|---|
| 206 | <xsl:choose>
|
|---|
| 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>
|
|---|
| 213 | </xsl:choose>
|
|---|
| 214 | </xsl:template>
|
|---|
| 215 |
|
|---|
| 216 | <doc:template xmlns="">
|
|---|
| 217 | <refpurpose> Process admonitions </refpurpose>
|
|---|
| 218 | <doc:description>
|
|---|
| 219 | <para>
|
|---|
| 220 |
|
|---|
| 221 | Invokes the environment provided by <xref
|
|---|
| 222 | linkend="param.latex.admonition.environment"/>
|
|---|
| 223 | and applies templates.
|
|---|
| 224 |
|
|---|
| 225 | </para>
|
|---|
| 226 | <note><para>An admonition will look something like this <doc:db>note</doc:db>.</para></note>
|
|---|
| 227 | </doc:description>
|
|---|
| 228 | <doc:notes>
|
|---|
| 229 | <para>
|
|---|
| 230 |
|
|---|
| 231 | There can be <quote>excessive</quote> whitespace between
|
|---|
| 232 | the bottom of the admonition area and a subsequent paragraph.
|
|---|
| 233 |
|
|---|
| 234 | </para>
|
|---|
| 235 | </doc:notes>
|
|---|
| 236 | <doc:variables>
|
|---|
| 237 | <itemizedlist>
|
|---|
| 238 | <listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
|
|---|
| 239 | <listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
|
|---|
| 240 | </itemizedlist>
|
|---|
| 241 | </doc:variables>
|
|---|
| 242 | <doc:samples>
|
|---|
| 243 | <simplelist type='inline'>
|
|---|
| 244 | &test_adm;
|
|---|
| 245 | &test_bind;
|
|---|
| 246 | &test_book;
|
|---|
| 247 | </simplelist>
|
|---|
| 248 | </doc:samples>
|
|---|
| 249 | <doc:seealso>
|
|---|
| 250 | <itemizedlist>
|
|---|
| 251 | <listitem><para>&mapping;</para></listitem>
|
|---|
| 252 | </itemizedlist>
|
|---|
| 253 | </doc:seealso>
|
|---|
| 254 | </doc:template>
|
|---|
| 255 |
|
|---|
| 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>
|
|---|
| 264 | <xsl:choose>
|
|---|
| 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="."/>
|
|---|
| 268 | </xsl:call-template>
|
|---|
| 269 | </xsl:when>
|
|---|
| 270 | <xsl:otherwise>
|
|---|
| 271 | <xsl:call-template name="gentext.element.name"/>
|
|---|
| 272 | </xsl:otherwise>
|
|---|
| 273 | </xsl:choose>
|
|---|
| 274 | <xsl:text>}</xsl:text>
|
|---|
| 275 | </xsl:with-param>
|
|---|
| 276 | </xsl:call-template>
|
|---|
| 277 | <xsl:call-template name="content-templates"/>
|
|---|
| 278 | <xsl:call-template name="map.end">
|
|---|
| 279 | <xsl:with-param name="keyword">admonition</xsl:with-param>
|
|---|
| 280 | </xsl:call-template>
|
|---|
| 281 | </xsl:template>
|
|---|
| 282 |
|
|---|
| 283 | </xsl:stylesheet>
|
|---|