28.03.2013 Views

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

480 Appendix E. L AT E X <strong>and</strong> World Wide Web<br />

\usepackage[xhtml,docbook]{tex4ht} for XML, DocBook output<br />

\usepackage[xhtml,tei]{tex4ht} for XML, TEI output<br />

One might ask why does the author not write an XML file directly as<br />

the source document? First, one might very well want <strong>to</strong> convert older<br />

documents recorded in L AT E X <strong>to</strong> XML. Secondly, one might find it simpler<br />

<strong>to</strong> write in L AT E X (not everyone agrees) since no one would write an XML<br />

file by h<strong>and</strong> (everyone agrees) but would rely on some application <strong>to</strong> do it<br />

behind the scenes. Certainly L AT E X source text is easier <strong>to</strong> read, even when<br />

intersperse with comm<strong>and</strong>s, than an XML file.<br />

E.2.2 MathML <strong>and</strong> L AT E X<br />

One of the strengths of T E X <strong>and</strong> thus L AT E X over other text processing<br />

systems is the ability <strong>to</strong> h<strong>and</strong>le mathematics in a way that is acceptable <strong>to</strong><br />

mathematicians. HTML has never been able <strong>to</strong> even begin <strong>to</strong> compete in<br />

this area. The only way conversion programs like L AT E X2HTML <strong>and</strong> T E X4ht<br />

can render equations like that in Figure E.1 is <strong>to</strong> convert it <strong>to</strong> an image<br />

file. This is hardly a satisfac<strong>to</strong>ry solution.<br />

The MathML project attempts <strong>to</strong> define an XML language <strong>to</strong> encode<br />

mathematics. We refer <strong>to</strong> chapter 8 of the L AT E X Web Companion (Goossens<br />

<strong>and</strong> Rahtz, 1999) for a description. T E X4ht can produce output in MathML<br />

by specifying<br />

\usepackage[xhtml,mathml]{tex4ht}<br />

Symbols that do not exists in the browser fonts will still be converted <strong>to</strong><br />

image files, but instructions are inserted <strong>to</strong> carry out the placement for<br />

fractions <strong>and</strong> superscripts <strong>and</strong> subscripts. Unfortunately, most browsers<br />

do not recognize MathML (yet). Again, once this becomes established<br />

there will be a st<strong>and</strong>ard for recording <strong>and</strong> exchanging documents with<br />

complex mathematics.<br />

E.2.3 Rendering XML with T E X/L AT E X<br />

Another role that L AT E X, or more properly the T E X program, can play in the<br />

XML world, is <strong>to</strong> translate it <strong>to</strong> a form that can be viewed or printed as a<br />

finished document. This is known as rendering.<br />

David Carlisle has written macros in a file xmltex.tex <strong>to</strong> act as an<br />

XML parser for output in T E X or L AT E X. Sebastian Rahtz has written an<br />

additional macro package PassiveT E X, <strong>to</strong> incorporate an XSL style sheet<br />

for the TEI DTD in<strong>to</strong> xmltex. With this combination, one can produce DVI<br />

or PDF output from a TEI-coded XML file.<br />

There are a number of ways of going about this. The simplest is <strong>to</strong><br />

write a ‘wrapper’ file for processing document.xml as

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!