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.

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

E.1 Converting <strong>to</strong> HTML<br />

E.1.1 The L AT E X2HTML program<br />

The L AT E X2HTML transla<strong>to</strong>r, written by Nikos Drakos with additions by a<br />

large number of contribu<strong>to</strong>rs, is a comprehensive Perl script that converts<br />

a L AT E X source file in<strong>to</strong> HTML with the help of several other programs,<br />

notably L AT E X itself, dvips, Ghostscript, <strong>and</strong> the netpbm library of graphics<br />

utilities.<br />

When L AT E X2HTML processes a L AT E X file, it creates a new subdirec<strong>to</strong>ry<br />

with the same name as that file, <strong>to</strong> which it writes the resulting HTML<br />

output <strong>and</strong> any generated images as .gif files. The program interprets<br />

the L AT E X input text in the same way as L AT E X itself does, but instead of<br />

producing typesetting instructions in the .dvi file, it writes appropriate<br />

HTML code <strong>to</strong> an .html file. For example, \section{Introduction} is<br />

interpreted as Introduction for the output.<br />

This means that L AT E X2HTML is essentially duplicating the L AT E X processing,<br />

an enormous undertaking. Since the document classes contain<br />

varying comm<strong>and</strong>s or have common ones behaving differently, there must<br />

be Perl scripts for each one (article.perl, <strong>and</strong> so on) <strong>to</strong> program these<br />

comm<strong>and</strong>s properly. Additional packages loaded with \usepackage can<br />

also define new comm<strong>and</strong>s, or alter the functionality of existing ones;<br />

the transla<strong>to</strong>r must be informed about these by means of corresponding<br />

Perl scripts. For example, the natbib package described in Section 9.3.4<br />

defines citation comm<strong>and</strong>s \citet <strong>and</strong> \citep, which need <strong>to</strong> be made<br />

available <strong>to</strong> L AT E X2HTML in a file natbib.perl. Most of the <strong>to</strong>ols packages<br />

of Section B.5.4 are included as Perl scripts, as are many other popular<br />

contributed packages. In other words, the entire L AT E X2HTML installation<br />

must mirror the L AT E X one.<br />

This process is somewhat simplified by the fact that both formats<br />

are markup languages written in pure typewriter text. However, this<br />

similarity soon reaches its limits with the many L AT E X features not available<br />

in HTML, such as complex math, included figures, cross-referencing. In<br />

the other direction, HTML exhibits hyperlinks, both internally <strong>and</strong> <strong>to</strong><br />

external documents, something not provided by normal L AT E X.<br />

L AT E X2HTML attempts <strong>to</strong> reproduce math with the limited HTML possibilities,<br />

but failing that, formulas are h<strong>and</strong>led the same as figures <strong>and</strong><br />

other environments that cannot be directly rendered: they are converted<br />

<strong>to</strong> GIF image files along the route.tex →.dvi →.ps →.pbm →.gif, which<br />

are then included in the HTML file as in-line images.<br />

Cross-references <strong>and</strong> citations are au<strong>to</strong>matically provided with hyperlinks<br />

<strong>to</strong> their targets; the keyword index also links back <strong>to</strong> the text. Other<br />

features of HTML can be included by means of special comm<strong>and</strong>s defined<br />

in the html.sty package. For example:<br />

• explicit hyperlinks, internal <strong>and</strong> external

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

Saved successfully!

Ooh no, something went wrong!