| 1 |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Writing Mathematics</title><link rel="stylesheet" type="text/css" href="manual.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="home" href="index.html" title="DocBook to LaTeX Publishing" /><link rel="up" href="ch03.html" title="Chapter 3. Using dblatex" /><link rel="prev" href="ch03s09.html" title="Correcting Poor Formatting" /><link rel="next" href="sec-music.html" title="Musical Notation" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Writing Mathematics</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s09.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Using dblatex</th><td width="20%" align="right"> <a accesskey="n" href="sec-music.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="idp1497"></a>Writing Mathematics</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="ch03s10.html#idp1499">Writing LaTeX Mathematical Equations</a></span></dt><dt><span class="section"><a href="ch03s10.html#idp1592"> |
| 3 |
Writing MathML equations |
| 4 |
</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1499"></a>Writing LaTeX Mathematical Equations</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="ch03s10.html#idp1501">Presentation</a></span></dt><dt><span class="section"><a href="ch03s10.html#idp1520">Implementation choice</a></span></dt><dt><span class="section"><a href="ch03s10.html#sec-alttex-delimiters">Mathematical Delimiters</a></span></dt><dt><span class="section"><a href="ch03s10.html#idp1554">Compatibility</a></span></dt><dt><span class="section"><a href="ch03s10.html#idp1558">Examples</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="idp1501"></a>Presentation</h4></div></div></div><p>DocBook doesn't define elements for writing mathematical equations. Only |
| 5 |
few elements exist that tell how equation should be displayed (inlined, |
| 6 |
block):</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="sgmltag-element">inlineequation</code> tells that the equation is |
| 7 |
inlined,</p></li><li class="listitem"><p><code class="sgmltag-element">informalequation</code> tells that the equation is displayed |
| 8 |
as a block, without a title.</p></li><li class="listitem"><p><code class="sgmltag-element">equation</code> tells that the equation is displayed as a |
| 9 |
block, with or without a title.</p></li></ul></div><p>These tags include a graphic (<code class="sgmltag-element">graphic</code> or |
| 10 |
<code class="sgmltag-element">mediaobject</code>) or an alternative text equation, as shown by |
| 11 |
the example.</p><div class="example"><a id="idp1517"></a><p class="title"><strong>Example 3.7. Equation taken from TDG</strong></p><div class="example-contents"><pre class="programlisting"> |
| 12 |
<equation><title>Last Theorem of Fermat</title> |
| 13 |
<alt>x^n + y^n &ne; z^n &forall; n &ne; 2</alt> |
| 14 |
<graphic fileref="figures/fermat"></graphic> |
| 15 |
</equation> |
| 16 |
</pre></div></div><br class="example-break" /></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="idp1520"></a>Implementation choice</h4></div></div></div><p>The principle is to use only the <code class="sgmltag-element">alt</code> element. If |
| 17 |
initially <code class="sgmltag-element">alt</code> contains actually the text to print, it is |
| 18 |
chosen to use this element to embed LaTeX mathematical equations. This choice |
| 19 |
has the following advantages:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>The translation done by dblatex is really easy, since the equation is |
| 20 |
already written in LaTeX.</p></li><li class="listitem"><p>LaTeX is one of the best word processor to render mathematical |
| 21 |
formulas.</p></li><li class="listitem"><p>One doesn't need to write the equations in MathML.</p></li><li class="listitem"><p>This method isn't specific to this tool (see the following |
| 22 |
section).</p></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="sec-alttex-delimiters"></a>Mathematical Delimiters</h4></div></div></div><p>The dblatex implementation is as light as possible. This is why it is |
| 23 |
up to the writer to properly use the mathematical delimiters ($, \(, \), \[, |
| 24 |
\]). By this way the writer fully controls how he writes equations.</p><p><a id="pi-texmath-user"></a>By default <span class="command"><strong>dblatex</strong></span> checks that |
| 25 |
consistent mathematical |
| 26 |
delimiters or environment are used in <code class="sgmltag-element">alt</code> and it inserts the |
| 27 |
default math mode delimiters if dblatex thinks they are missing, but |
| 28 |
you can ask dblatex to write directly the <code class="sgmltag-element">alt</code> content |
| 29 |
without any action. To do this, use the <code class="literal">texmath</code> Processing |
| 30 |
Instruction with <code class="literal">delimiters</code> set to 'user'.</p><p>For example, <a class="xref" href="ch03s10.html#eq-with-texmath-pi" title="Example 3.8. Equation with user delimiters">Example 3.8, “Equation with user delimiters”</a> has user specific |
| 31 |
delimiters:</p><div class="example"><a id="eq-with-texmath-pi"></a><p class="title"><strong>Example 3.8. Equation with user delimiters</strong></p><div class="example-contents"><div class="equation"><a id="idp1547"></a><p class="title"><strong>Equation 3.1. Equation block with align tabs</strong></p><div class="equation-contents"></div></div><br class="equation-break" /><p>In the XML source this equation uses a specific <code class="literal">align*</code> environment and the <code class="literal">texmath</code> PI to let the equation as is:</p><pre class="programlisting"> |
| 32 |
<?xml version="1.0" encoding="iso-8859-1"?> |
| 33 |
<!DOCTYPE para PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" |
| 34 |
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> |
| 35 |
<equation> |
| 36 |
<title>Equation block with align tabs</title> |
| 37 |
<alt><?texmath delimiters="user"?><![CDATA[\begin{align*} |
| 38 |
S & = \left\lfloor { { N \bmod 65536 } \over 32768 } \right\rfloor \\ |
| 39 |
E & = \left\lfloor { { N \bmod 32768 } \over 1024 } \right\rfloor \\ |
| 40 |
M & = N \bmod 1024. |
| 41 |
\end{align*}]]></alt> |
| 42 |
</equation> |
| 43 |
</pre></div></div><br class="example-break" /></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="idp1554"></a>Compatibility</h4></div></div></div><p>This implementation is not contradictory nor specific. In particular, |
| 44 |
the <a class="ulink" href="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath/" target="_top">DBTeXMath</a> |
| 45 |
proposal to extend the DSSSL stylesheets used by jade follows the same |
| 46 |
approach, and is integrated in the Norman Walsh XSL stylesheets.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="idp1558"></a>Examples</h4></div></div></div><p>The following examples show how to write the equations.</p><div class="example"><a id="idp1561"></a><p class="title"><strong>Example 3.9. Inlined Equation</strong></p><div class="example-contents"><p>The formula |
| 47 |
<span><img src="figures/eq1.png" /></span> |
| 48 |
is inlined in the paragraph. Its XML source is:</p><pre class="programlisting"> |
| 49 |
<para>The formula |
| 50 |
<inlineequation id="eg-inlineequation"> |
| 51 |
<alt>$C = \alpha + \beta Y^{\gamma} + \epsilon$</alt> |
| 52 |
<graphic fileref="figures/eq1"/> |
| 53 |
</inlineequation> |
| 54 |
is inlined in the paragraph. Its XML source is:</para> |
| 55 |
|
| 56 |
</pre></div></div><br class="example-break" /><div class="example"><a id="idp1568"></a><p class="title"><strong>Example 3.10. Equation in a block</strong></p><div class="example-contents"><p>The following formula: |
| 57 |
</p><div class="informalequation"><div><img src="figures/eq1.png" /></div></div><p> |
| 58 |
is displayed in a separate block. The XML source is:</p><pre class="programlisting"> |
| 59 |
<para>The following formula: |
| 60 |
<informalequation> |
| 61 |
<alt>\[C = \alpha + \beta Y^{\gamma} + \epsilon\]</alt> |
| 62 |
<graphic fileref="figures/eq1"/> |
| 63 |
</informalequation> |
| 64 |
is displayed in a separate block. The XML source is:</para> |
| 65 |
|
| 66 |
</pre></div></div><br class="example-break" /><div class="example"><a id="idp1575"></a><p class="title"><strong>Example 3.11. Equation in a float</strong></p><div class="example-contents"><p>The formula <a class="xref" href="ch03s10.html#eq-with-title" title="Equation 3.2. Simple Formula">Equation 3.2, “Simple Formula”</a> below: |
| 67 |
</p><div class="equation"><a id="eq-with-title"></a><p class="title"><strong>Equation 3.2. Simple Formula</strong></p><div class="equation-contents"><div><img src="figures/eq1.png" /></div></div></div><p><br class="equation-break" /> |
| 68 |
is displayed in a block with a title. Its XML source is:</p><pre class="programlisting"> |
| 69 |
<?xml version="1.0" encoding="iso-8859-1"?> |
| 70 |
<!DOCTYPE para PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" |
| 71 |
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> |
| 72 |
<para>The formula <xref linkend="eq-with-title"/> below: |
| 73 |
<equation id="eq-with-title"> |
| 74 |
<title>Simple Formula</title> |
| 75 |
<alt>\[C = \alpha + \beta Y^{\gamma} + \epsilon\]</alt> |
| 76 |
<graphic fileref="figures/eq1"/> |
| 77 |
</equation> |
| 78 |
is displayed in a block with a title. Its XML source is:</para> |
| 79 |
|
| 80 |
</pre></div></div><br class="example-break" /><div class="example"><a id="idp1584"></a><p class="title"><strong>Example 3.12. Equation without a title</strong></p><div class="example-contents"><p>The formula <a class="xref" href="ch03s10.html#eq-with-no-title" title="Equation 3.3. ">Equation 3.3</a> below: |
| 81 |
</p><div class="equation"><a id="eq-with-no-title"></a><p class="title"><strong>Equation 3.3. </strong></p><div class="equation-contents"><div><img src="figures/eq4.png" /></div></div></div><p><br class="equation-break" /> |
| 82 |
is displayed as a latex equation with its own equation numbering. |
| 83 |
Its XML source is:</p><pre class="programlisting"> |
| 84 |
<?xml version="1.0" encoding="iso-8859-1"?> |
| 85 |
<!DOCTYPE para PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" |
| 86 |
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> |
| 87 |
<para>The formula <xref linkend="eq-with-no-title"/> below: |
| 88 |
<equation id="eq-with-no-title"> |
| 89 |
<alt>C = \alpha + \beta Y^{\gamma} + \epsilon</alt> |
| 90 |
<graphic fileref="figures/eq4"/> |
| 91 |
</equation> |
| 92 |
is displayed as a latex equation with its own equation numbering. |
| 93 |
Its XML source is:</para> |
| 94 |
|
| 95 |
</pre></div></div><br class="example-break" /></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1592"></a> |
| 96 |
Writing MathML equations |
| 97 |
</h3></div></div></div><p> |
| 98 |
You can write MathML equations in a DocBook based document, by using the <a class="ulink" href="http://www.oasis-open.org/docbook/xml/mathml/index.1.shtml" target="_top">MathML Module for DocBook XML</a> instead of the DocBook DTD. |
| 99 |
</p><p> |
| 100 |
dblatex now translates the MathML equations to latex by using the excellent stylesheets of the <a class="ulink" href="http://xsltml.sourceforge.net" target="_top">XSLT MathML Library</a> by Vasil Yaroshevich. A large amount of tests from the <a class="ulink" href="http://www.w3.org/Math/testsuite/" target="_top">W3C MathML Test Suite 2.0</a> is supported (657 of 712 tests). The test file used to validate the MathML stylesheets is provided in the package. |
| 101 |
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s09.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-music.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Correcting Poor Formatting </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Musical Notation</td></tr></table></div></body></html> |