I want to write a perl processor that filters equations out of html images and creates svg replacements for it so that my equations show up nicely in epub and in major browsers. (I understand that text browsers and email clients will be spott.)
think
<html>
<body>
<h1>Visible</h1>
<p>I can see this and change its size in my browser and in epub.
<pre class="math">
y &=& \frac{\sqrt{x}}{z} \\
&&+\frac{\sqrt{z}}{\mathtt{myvar}} \nonumber
</pre>
</body>
</html>
it's easy for me to parse out the pre contents. I can then stick them into a latex file.
\documentclass[12pt]{article}
\RequirePackage{charter}
\RequirePackage[mdbch,ttscaled=true]{mathdesign}
\usepackage{microtype}
\usepackage[english]{babel}
\begin{document}
\begin{eqnarray}
y &=& \frac{\sqrt{x}}{z} \\
&& + \frac{\sqrt{z}}{\mathtt{myvar}}
\end{eqnarray}
\end{document}
presumably, I then run
pdflatex -output dvi file.tex ; dvisvgm file.dvi .
the reason I use dvisvgm is that texlive does not include a pdfsvgm and pdf2svg scares me because it refers to poppler and cairo (and I want my equations to remain fully rendered/scaleable). but, I do need my resulting document that is run through
1. how do I ask latex to create a page that is just the bounding box of the equation?
2. are there any recommended other arguments that I should hand to dvisvgm for my purpose? (e.g., exact?).
thereafter, I want to encode this back into my html source. presumably, now I would want to do something like
<html>
<body>
<h1>Visible</h1>
<p>I can see this and change its size in my browser and in epub.
<svg>
... (whatever I see in file.svg)
</svg>
</body>
</html>
3. Is this the right approach to the problem? or am I making a mistake here?
help appreciated.
regards,
/iaw
PS: if anyone reads this, the links at http://www.latex2html.org/node2.html seem to be broken. the dates here are from 2001.
Best Answer
eqnarray does not seem to be easily possible, but normal equations may be and the array environment makes it possible to include multi-line equations. here is an example. start with
then
will create an svg file. without the -n, the quality is lousy. with it, it is pretty good. (thx, martin). the array is a math-mode eqnarray substitute that is quite workable--and can align more than just two.
the example does not have the equation line numbering. presumably, one could easily do this with a float:right on a numbering.
this example produces an svg file of about 4KB. even with 100 equations, we are still looking at an html file that is an order of magnitude smaller than one with mathjax included. it should also work in epub, although I have not tested it yet. mathjax is advantageous if it has already been loaded and cached by the browser.
I am enclosing a basic perl hack that translates an html file with dependency on mathjax into one without it. it has baseline problems and probably a couple of other bugs. but it is a starting point.