2 <!DOCTYPE xsl:stylesheet [
<!ENTITY % xsldoc.ent SYSTEM
"./xsldoc.ent"> %xsldoc.ent; ]
>
3 <!--#############################################################################
4 | $Id: texmath.mod.xsl,v 1.12 2004/01/03 03:19:08 j-devenish Exp $
5 |- #############################################################################
6 | $Author: j-devenish $
7 + ############################################################################## -->
10 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'
>
14 <doc:reference id=
"texmath" xmlns=
"">
16 <releaseinfo role=
"meta">
17 $Id: texmath.mod.xsl,v
1.12 2004/
01/
03 03:
19:
08 j-devenish Exp $
24 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
25 <holder>Ramon Casellas
</holder>
28 <doc:revision rcasver=
"1.11">&rev_2003_05;</doc:revision>
31 <title>&LaTeX;-only Commands
<filename>texmath.mod.xsl
</filename></title>
41 <doc:template xmlns=
"">
42 <refpurpose>Process
<doc:db>alt
</doc:db> elements
</refpurpose>
52 <xref linkend=
"param.tex.math.in.alt"/>
59 This template will modify its behaviour based upon its context
60 within a
&DocBook; document.
62 If it is within an
<doc:db>inlineequation
</doc:db> and it has a
63 <sgmltag class=
"attribute">role
</sgmltag> with the value of
64 <quote>latex
</quote> or
<quote>tex
</quote>, then it will
65 typeset its contents inline as raw
&LaTeX; input in mathematics
66 mode (using
<function condition=
"latex">ensuremath
</function>
67 command) if the variable
<xref
68 linkend=
"param.tex.math.in.alt"/> is set.
70 If it is within an
<doc:db>equation
</doc:db> or
71 <doc:db>informalequation
</doc:db> and it has a
<sgmltag
72 class=
"attribute">role
</sgmltag> with the value of
73 <quote>latex
</quote> or
<quote>tex
</quote>, then it will
74 typeset its contents as raw
&LaTeX; input in a
<function
75 condition=
"env">displaymath
</function> block environment if the
76 variable
<xref linkend=
"param.tex.math.in.alt"/> is set.
78 Otherwise, if
<xref linkend=
"param.tex.math.in.alt"/> is
79 set, the contents will be typeset as raw
&LaTeX; input inline
82 Otherwise, templates will be applied normally (not as raw
88 <simplelist type='inline'
>
94 <xsl:template match=
"alt">
96 <xsl:when test=
"ancestor::inlineequation and (@role='tex' or @role='latex' or $tex.math.in.alt='plain' or $tex.math.in.alt='latex')">
97 <xsl:text>\ensuremath{
</xsl:text>
98 <xsl:value-of select=
"."/>
99 <xsl:text>}
</xsl:text>
101 <xsl:when test=
"(ancestor::equation|ancestor::informalequation) and (@role='tex' or @role='latex' or $tex.math.in.alt='plain' or $tex.math.in.alt='latex')">
102 <xsl:text>\begin{displaymath}
</xsl:text>
103 <xsl:call-template name=
"label.id"/>
104 <xsl:value-of select=
"."/>
105 <xsl:text>\end{displaymath}
</xsl:text>
107 <xsl:when test=
"$tex.math.in.alt='plain' or $tex.math.in.alt='latex'">
108 <xsl:value-of select=
"."/>
111 <xsl:apply-templates/>
116 <doc:template xmlns=
"">
117 <refpurpose>Process
<sgmltag>latex
</sgmltag> and
<sgmltag>tex
</sgmltag> elements
</refpurpose>
120 Passes contents through as raw
&LaTeX; text.
128 The
<sgmltag>latex
</sgmltag> and
<sgmltag>tex
</sgmltag> elements are not
133 <xsl:template match=
"latex|tex">
134 <xsl:value-of select=
"."/>
137 <doc:template xmlns=
"">
138 <refpurpose>Process
<sgmltag class=
"attribute">fileref
</sgmltag> elements
</refpurpose>
141 Inputs a
&LaTeX; file.
149 For
<sgmltag>latex
</sgmltag> and
<sgmltag>tex
</sgmltag> elements with
150 <sgmltag class=
"attribute">fileref
</sgmltag> attributes, their contents
151 are ignored and their fileref attributes are used as file paths for
152 the
<function condition=
"latex">input
</function> command.
155 The
<sgmltag>latex
</sgmltag> and
<sgmltag>tex
</sgmltag> elements are not
160 <xsl:template match=
"latex[@fileref]|tex[@fileref]">
161 <xsl:text>\input{
</xsl:text><xsl:value-of select=
"@fileref"/><xsl:text>}
</xsl:text>
164 <xsl:template match=
"tm[@fileref]">
165 <xsl:text>\input{
</xsl:text><xsl:value-of select=
"@fileref"/><xsl:text>}
</xsl:text>
168 <xsl:template match=
"tm[@tex]">
169 <xsl:value-of select=
"@tex"/>
172 <xsl:template match=
"inlinetm[@fileref]">
173 <xsl:text>\input{
</xsl:text><xsl:value-of select=
"@fileref"/><xsl:text>}
</xsl:text>
176 <xsl:template match=
"inlinetm[@tex]">
177 <xsl:value-of select=
"@tex"/>
180 <doc:template xmlns=
"">
181 <refpurpose>Process
<doc:db>inlineequation
</doc:db> elements
</refpurpose>
184 Process inline equations.
190 <xref linkend=
"param.latex.alt.is.preferred"/>
191 </simpara></listitem>
197 This template can accommodate raw
&LaTeX; mathematics.
200 <sgmltag class=
"attribute">role
</sgmltag> with a value of
201 <quote>latex
</quote> or
<quote>tex
</quote>, or contains
202 an
<doc:db>inlinemediaobject
</doc:db>/
<doc:db>textobject
</doc:db>
204 an
<doc:db>inlinemediaobject
</doc:db>/
<doc:db>textobject
</doc:db>/
<doc:db>phrase
</doc:db>
205 with such as attribute,
207 typeset then in preference to all other content.
212 If such elements were not found, the template will search for
213 generic
<doc:db>inlinemediaobject
</doc:db> or
214 <doc:db>alt
</doc:db> children. If
<xref
215 linkend=
"param.latex.alt.is.preferred"/> is set,
<sgmltag
216 basename=
"alt">alts
</sgmltag> will be preferred over
<sgmltag
217 basename=
"inlinemediaobject">inlinemediaobjects
</sgmltag>. If
218 none of these elements was found, the template will format any
219 <doc:db>graphic
</doc:db> children.
224 <simplelist type='inline'
>
233 <listitem><simpara><xref linkend=
"template.alt"/></simpara></listitem>
234 <listitem><simpara><xref linkend=
"template.phrase"/></simpara></listitem>
238 <xsl:template match=
"inlineequation">
239 <xsl:variable name=
"tex" select=
"alt[@role='tex' or @role='latex']|inlinemediaobject/textobject[@role='tex' or @role='latex']|inlinemediaobject/textobject/phrase[@role='tex' or @role='latex']" />
241 <xsl:when test=
"$tex">
242 <xsl:apply-templates select=
"$tex"/>
244 <xsl:when test=
"alt and $latex.alt.is.preferred='1'">
245 <xsl:apply-templates select=
"alt"/>
247 <xsl:when test=
"inlinemediaobject">
248 <xsl:apply-templates select=
"inlinemediaobject"/>
250 <xsl:when test=
"alt">
251 <xsl:apply-templates select=
"alt"/>
254 <xsl:apply-templates select=
"graphic"/>