trying to get HEAD building again. If you want the code
[tprouty/samba.git] / docs / docbook / xslt / db2latex / admonition.mod.xsl
1 <?xml version='1.0'?>
2 <!--############################################################################# 
3 |- #############################################################################
4 |
5 |   PURPOSE: Admonition templates. 
6 + ############################################################################## -->
7 <xsl:stylesheet 
8     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
9     xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
10     exclude-result-prefixes="doc" version='1.0'>
11
12
13     <!--############################################################################# -->
14     <!-- DOCUMENTATION                                                                -->
15     <doc:reference name="admonition" xmlns="">
16         <referenceinfo>
17             <releaseinfo role="meta">
18             </releaseinfo>
19                 <authorgroup>
20                 <author><firstname>Ramon</firstname> <surname>Casellas</surname></author>
21                 <author><firstname>James</firstname> <surname>Devenish</surname></author>
22                 </authorgroup>
23             <copyright><year>2000</year><year>2001</year><year>2002</year><year>2003</year>
24                 <holder>Ramon Casellas</holder>
25             </copyright>
26         </referenceinfo>
27
28         <title>Admonition XSL Variables and Templates <filename>admonition.mod.xsl</filename></title>
29
30         <partintro>
31             <section><title>Introduction</title>
32                 <para>DocBook includes admonitions, which are set off from the main text.</para>
33             </section>
34                 <formalpara><title>Pertinent Variables</title>
35                 <itemizedlist>
36                         <listitem><simpara><xref linkend="param.latex.use.fancybox"/></simpara></listitem>
37                         <listitem><simpara><xref linkend="param.latex.admonition.path"/></simpara></listitem>
38                         <listitem><simpara><xref linkend="param.latex.admonition.imagesize"/></simpara></listitem>
39                         <listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
40                 </itemizedlist>
41                 </formalpara>
42         </partintro>
43     </doc:reference>
44
45     <!--############################################################################# -->
46     <!-- DOCUMENTATION                                                                -->
47     <doc:param name="latex.admonition.environment" xmlns="">
48         <refpurpose> 
49             Declares a new environment to be used for admonitions
50                 (warning, tip, important, caution, note).
51         </refpurpose>
52         <refdescription>
53             <para>
54                 A LaTeX environment is emitted. That environment has two mandatory parameters.
55                 Instances of the environment are customised for each admonition via those parameters.
56                 Instances will be typeset as boxed areas in the document flow.
57                 </para>
58                 <para>
59                 The first argument is the filename for graphics (e.g $latex.admonition.path/warning).
60                 The second argument is the admonition title or the associated generic text.
61                 </para>
62                 <para>
63                 It requires the LaTeX <link linkend="param.latex.use.fancybox">fancybox package</link>. 
64                 It also uses graphics, by default.
65                 </para>
66                 <example>
67                         <title>Processing the <sgmltag class="element">warning</sgmltag> admonition</title>
68             <para> When processing the admonition, the following code is generated: </para>
69             <programlisting><![CDATA[
70                 \begin{admonition}{figures/warning}{My WARNING}
71                 ...
72                 \end{admonition}]]>
73                 </programlisting>
74                 </example>
75         </refdescription>
76     </doc:param>
77
78 <!--############################################################################# -->
79 <xsl:variable name="latex.admonition.environment">
80 <xsl:text>% ---------------------------------------------- &#10;</xsl:text>
81 <xsl:text>% Define a new LaTeX environment (adminipage)    &#10;</xsl:text>
82 <xsl:text>% ---------------------------------------------- &#10;</xsl:text>
83 <xsl:text>\newenvironment{admminipage}%&#10;</xsl:text>
84 <xsl:text>{ % this code corresponds to the \begin{adminipage} command&#10;</xsl:text>
85 <xsl:text> \begin{Sbox}%&#10;</xsl:text>
86 <xsl:text> \begin{minipage}%&#10;</xsl:text>
87 <xsl:text>} %done&#10;</xsl:text>
88 <xsl:text>{ % this code corresponds to the \end{adminipage} command&#10;</xsl:text>
89 <xsl:text> \end{minipage}&#10;</xsl:text>
90 <xsl:text> \end{Sbox}&#10;</xsl:text>
91 <xsl:text> \fbox{\TheSbox}&#10;</xsl:text>
92 <xsl:text>} %done&#10;</xsl:text>
93 <xsl:text>% ---------------------------------------------- &#10;</xsl:text>
94 <xsl:text>% Define a new LaTeX length (admlength)          &#10;</xsl:text>
95 <xsl:text>% ---------------------------------------------- &#10;</xsl:text>
96 <xsl:text>\newlength{\admlength}&#10;</xsl:text>
97 <xsl:text>% ---------------------------------------------- &#10;</xsl:text>
98 <xsl:text>% Define a new LaTeX environment (admonition)    &#10;</xsl:text>
99 <xsl:text>% With 2 parameters:                             &#10;</xsl:text>
100 <xsl:text>% #1 The file (e.g. note.pdf)                    &#10;</xsl:text>
101 <xsl:text>% #2 The caption                                 &#10;</xsl:text>
102 <xsl:text>% ---------------------------------------------- &#10;</xsl:text>
103 <xsl:text>\newenvironment{admonition}[2] &#10;</xsl:text>
104 <xsl:text>{ % this code corresponds to the \begin{admonition} command&#10;</xsl:text>
105 <xsl:text> \hspace{0mm}\newline\hspace*\fill\newline&#10;</xsl:text>
106 <xsl:text> \noindent&#10;</xsl:text>
107 <xsl:text> \setlength{\fboxsep}{5pt}&#10;</xsl:text>
108 <xsl:text> \setlength{\admlength}{\linewidth}&#10;</xsl:text>
109 <xsl:text> \addtolength{\admlength}{-10\fboxsep}&#10;</xsl:text>
110 <xsl:text> \addtolength{\admlength}{-10\fboxrule}&#10;</xsl:text>
111 <xsl:text> \admminipage{\admlength}&#10;</xsl:text>
112 <xsl:text> {\bfseries \sc\large{#2}}</xsl:text>
113 <xsl:text> \newline&#10;</xsl:text>
114 <xsl:text> \\[1mm]&#10;</xsl:text>
115 <xsl:text> \sffamily&#10;</xsl:text>
116 <!--
117 If we cannot find the latex.admonition.path;
118 Comment out the next line (\includegraphics).
119 This tactic is to avoid deleting the \includegraphics
120 altogether, as that could confuse a person trying to
121 find the use of parameter #1 in the environment.
122 -->
123 <xsl:if test="$latex.admonition.path=''">
124         <xsl:text>%</xsl:text>
125 </xsl:if>
126 <xsl:text> \includegraphics[</xsl:text> <xsl:value-of select="$latex.admonition.imagesize" /> <xsl:text>]{#1}&#10;</xsl:text>
127 <xsl:text> \addtolength{\admlength}{-1cm}&#10;</xsl:text>
128 <xsl:text> \addtolength{\admlength}{-20pt}&#10;</xsl:text>
129 <xsl:text> \begin{minipage}[lt]{\admlength}&#10;</xsl:text>
130 <xsl:text> \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt&#10;</xsl:text>
131 <xsl:text>} %done&#10;</xsl:text>
132 <xsl:text>{ % this code corresponds to the \end{admonition} command&#10;</xsl:text>
133 <xsl:text> \vspace{5mm} &#10;</xsl:text>
134 <xsl:text> \end{minipage}&#10;</xsl:text>
135 <xsl:text> \endadmminipage&#10;</xsl:text>
136 <xsl:text> \vspace{.5em}&#10;</xsl:text>
137 <xsl:text> \par&#10;</xsl:text>
138 <xsl:text>}&#10;</xsl:text>
139 </xsl:variable>
140
141
142
143
144     <!--############################################################################# -->
145     <!-- DOCUMENTATION                                                                -->
146     <doc:template name="admon.graphic" xmlns="">
147         <refpurpose> Choose an admonition graphic </refpurpose>
148         <refdescription>
149             <para> For each admonition element (note, warning, caution, top, important),
150                 this template chooses the graphics filename. If the admonition element is
151                 not known, the <sgmltag class="element">note</sgmltag> graphic is used.
152             </para>
153         </refdescription>
154     </doc:template>
155     <!--############################################################################# -->
156
157     <xsl:template name="admon.graphic">
158         <xsl:param name="node" select="."/>
159         <xsl:choose>
160             <xsl:when test="name($node)='note'">note</xsl:when>
161             <xsl:when test="name($node)='warning'">warning</xsl:when>
162             <xsl:when test="name($node)='caution'">caution</xsl:when>
163             <xsl:when test="name($node)='tip'">tip</xsl:when>
164             <xsl:when test="name($node)='important'">important</xsl:when>
165             <xsl:otherwise>note</xsl:otherwise>
166         </xsl:choose>
167     </xsl:template>
168
169
170     <!--############################################################################# -->
171     <!-- DOCUMENTATION                                                                -->
172     <doc:template name="admonitions" match="note|important|warning|caution|tip" xmlns="">
173         <refpurpose> XSL Template for admonitions </refpurpose>
174         <refdescription>
175             <para> Uses the <xref linkend="param.latex.admonition.environment"/>.
176             </para>
177                 <note><para>An admonition will look something like this.</para></note>
178             <formalpara><title>Remarks and Bugs</title>
179                 <itemizedlist>
180                 <listitem>
181                 <para>
182                 There can be <quote>excessive</quote> whitespace between
183                 the bottom of the admonition area and a subsequent paragraph.
184                 </para>
185                 </listitem>
186                 </itemizedlist>
187             </formalpara>
188         </refdescription>
189     </doc:template>
190     <!--############################################################################# -->
191
192     <xsl:template match="note|important|warning|caution|tip">
193         <xsl:call-template name="map.begin">
194             <xsl:with-param name="keyword">admonition</xsl:with-param>
195             <xsl:with-param name="string">
196                 <xsl:text>{</xsl:text>
197                 <xsl:value-of select="$latex.admonition.path"/><xsl:text>/</xsl:text>
198                 <xsl:call-template name="admon.graphic"/>
199                 <xsl:text>}{</xsl:text>
200                 <xsl:choose> 
201                     <xsl:when test="title and $latex.apply.title.templates.admonitions='1'">
202                         <xsl:call-template name="extract.object.title">
203                                 <xsl:with-param name="object" select="."/>
204                         </xsl:call-template>
205                     </xsl:when>
206                     <xsl:otherwise>
207                         <xsl:call-template name="gentext.element.name"/>
208                     </xsl:otherwise> 
209                 </xsl:choose>
210                 <xsl:text>}</xsl:text>
211             </xsl:with-param>
212         </xsl:call-template>
213         <xsl:apply-templates/>
214         <xsl:call-template name="map.end">
215             <xsl:with-param name="keyword">admonition</xsl:with-param>
216         </xsl:call-template>
217     </xsl:template>
218
219     <!-- Empty title template -->
220     <xsl:template match="note/title|important/title|warning/title|caution/title|tip/title"/>
221
222 </xsl:stylesheet>