| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> |
| 4 |
<section output="manual"> |
| 5 |
<title>Writing LaTeX Mathematical Equations</title> |
| 6 |
|
| 7 |
<section> |
| 8 |
<title>Presentation</title> |
| 9 |
|
| 10 |
<para>DocBook doesn't define elements for writing mathematical equations. Only |
| 11 |
few elements exist that tell how equation should be displayed (inlined, |
| 12 |
block):</para> |
| 13 |
|
| 14 |
<itemizedlist> |
| 15 |
<listitem> |
| 16 |
<para><sgmltag>inlineequation</sgmltag> tells that the equation is |
| 17 |
inlined,</para> |
| 18 |
</listitem> |
| 19 |
|
| 20 |
<listitem> |
| 21 |
<para><sgmltag>informalequation</sgmltag> tells that the equation is displayed |
| 22 |
as a block, without a title.</para> |
| 23 |
</listitem> |
| 24 |
|
| 25 |
<listitem> |
| 26 |
<para><sgmltag>equation</sgmltag> tells that the equation is displayed as a |
| 27 |
block, with or without a title.</para> |
| 28 |
</listitem> |
| 29 |
</itemizedlist> |
| 30 |
|
| 31 |
<para>These tags include a graphic (<sgmltag>graphic</sgmltag> or |
| 32 |
<sgmltag>mediaobject</sgmltag>) or an alternative text equation, as shown by |
| 33 |
the example.</para> |
| 34 |
|
| 35 |
<example> |
| 36 |
<title>Equation taken from TDG</title> |
| 37 |
|
| 38 |
<programlisting> |
| 39 |
<equation><title>Last Theorem of Fermat</title> |
| 40 |
<alt>x^n + y^n &ne; z^n &forall; n &ne; 2</alt> |
| 41 |
<graphic fileref="figures/fermat"></graphic> |
| 42 |
</equation> |
| 43 |
</programlisting> |
| 44 |
</example> |
| 45 |
</section> |
| 46 |
|
| 47 |
<section> |
| 48 |
<title>Implementation choice</title> |
| 49 |
|
| 50 |
<para>The principle is to use only the <sgmltag>alt</sgmltag> element. If |
| 51 |
initially <sgmltag>alt</sgmltag> contains actually the text to print, it is |
| 52 |
chosen to use this element to embed LaTeX mathematical equations. This choice |
| 53 |
has the following advantages:</para> |
| 54 |
|
| 55 |
<itemizedlist> |
| 56 |
<listitem> |
| 57 |
<para>The translation done by dblatex is really easy, since the equation is |
| 58 |
already written in LaTeX.</para> |
| 59 |
</listitem> |
| 60 |
|
| 61 |
<listitem> |
| 62 |
<para>LaTeX is one of the best word processor to render mathematical |
| 63 |
formulas.</para> |
| 64 |
</listitem> |
| 65 |
|
| 66 |
<listitem> |
| 67 |
<para>One doesn't need to write the equations in MathML.</para> |
| 68 |
</listitem> |
| 69 |
|
| 70 |
<listitem> |
| 71 |
<para>This method isn't specific to this tool (see the following |
| 72 |
section).</para> |
| 73 |
</listitem> |
| 74 |
</itemizedlist> |
| 75 |
|
| 76 |
</section> |
| 77 |
|
| 78 |
<section id="sec-alttex-delimiters"> |
| 79 |
<title>Mathematical Delimiters</title> |
| 80 |
|
| 81 |
<para>The dblatex implementation is as light as possible. This is why it is |
| 82 |
up to the writer to properly use the mathematical delimiters ($, \(, \), \[, |
| 83 |
\]). By this way the writer fully controls how he writes equations.</para> |
| 84 |
|
| 85 |
<para id="pi-texmath-user">By default <command>dblatex</command> checks that |
| 86 |
consistent mathematical |
| 87 |
delimiters or environment are used in <sgmltag>alt</sgmltag> and it inserts the |
| 88 |
default math mode delimiters if dblatex thinks they are missing, but |
| 89 |
you can ask dblatex to write directly the <sgmltag>alt</sgmltag> content |
| 90 |
without any action. To do this, use the <literal>texmath</literal> Processing |
| 91 |
Instruction with <literal>delimiters</literal> set to 'user'.</para> |
| 92 |
|
| 93 |
<para>For example, <xref linkend="eq-with-texmath-pi"/> has user specific |
| 94 |
delimiters:</para> |
| 95 |
|
| 96 |
<example id="eq-with-texmath-pi"> |
| 97 |
<title>Equation with user delimiters</title> |
| 98 |
<xi:include href="equation-eg5.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 99 |
<para>In the XML source this equation uses a specific <literal>align*</literal> environment and the <literal>texmath</literal> PI to let the equation as is:</para> |
| 100 |
<programlisting> |
| 101 |
<xi:include href="equation-eg5.xml" xmlns:xi="http://www.w3.org/2001/XInclude" |
| 102 |
parse="text"/> </programlisting> |
| 103 |
</example> |
| 104 |
|
| 105 |
</section> |
| 106 |
|
| 107 |
<section> |
| 108 |
<title>Compatibility</title> |
| 109 |
|
| 110 |
<para>This implementation is not contradictory nor specific. In particular, |
| 111 |
the <ulink |
| 112 |
url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath/">DBTeXMath</ulink> |
| 113 |
proposal to extend the DSSSL stylesheets used by jade follows the same |
| 114 |
approach, and is integrated in the Norman Walsh XSL stylesheets.</para> |
| 115 |
</section> |
| 116 |
|
| 117 |
<section> |
| 118 |
<title>Examples</title> |
| 119 |
|
| 120 |
<para>The following examples show how to write the equations.</para> |
| 121 |
|
| 122 |
<example> |
| 123 |
<title>Inlined Equation</title> |
| 124 |
|
| 125 |
<xi:include href="equation-eg1.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 126 |
|
| 127 |
<programlisting> |
| 128 |
<xi:include href="equation-eg1.xml" xmlns:xi="http://www.w3.org/2001/XInclude" |
| 129 |
parse="text"/> |
| 130 |
</programlisting> |
| 131 |
</example> |
| 132 |
|
| 133 |
<example> |
| 134 |
<title>Equation in a block</title> |
| 135 |
|
| 136 |
<xi:include href="equation-eg2.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 137 |
|
| 138 |
<programlisting> |
| 139 |
<xi:include href="equation-eg2.xml" xmlns:xi="http://www.w3.org/2001/XInclude" |
| 140 |
parse="text"/> |
| 141 |
</programlisting> |
| 142 |
</example> |
| 143 |
|
| 144 |
<example> |
| 145 |
<title>Equation in a float</title> |
| 146 |
|
| 147 |
<xi:include href="equation-eg3.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 148 |
|
| 149 |
<programlisting> |
| 150 |
<xi:include href="equation-eg3.xml" xmlns:xi="http://www.w3.org/2001/XInclude" |
| 151 |
parse="text"/> |
| 152 |
</programlisting> |
| 153 |
</example> |
| 154 |
|
| 155 |
<example> |
| 156 |
<title>Equation without a title</title> |
| 157 |
|
| 158 |
<xi:include href="equation-eg4.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 159 |
|
| 160 |
<programlisting> |
| 161 |
<xi:include href="equation-eg4.xml" xmlns:xi="http://www.w3.org/2001/XInclude" |
| 162 |
parse="text"/> |
| 163 |
</programlisting> |
| 164 |
</example> |
| 165 |
</section> |
| 166 |
</section> |