Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[MINI-HOWTO] Convert LaTeX to HTML with MathML
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
robbyjo
Guru
Guru


Joined: 06 Apr 2003
Posts: 462

PostPosted: Tue Apr 19, 2005 9:50 pm    Post subject: [MINI-HOWTO] Convert LaTeX to HTML with MathML Reply with quote

If you're a graduate student or professor working in your research papers, you'd most likely use LaTeX. LaTeX is awesome especially in typing mathematical formulas. Most likely, the papers you're making will be put into postscript (PS) or PDF file for publication. Sometimes, you'd prefer to have that convert it directly to HTML for direct viewing through your webpage. There was a program to do this, called latex2html, which could do a decent job. However, latex2html always converts mathematical formulas or symbols into graphics, to either PNG or GIF. This means that if you have tons of mathematical formulas, you'd end up with hundreds or sometimes thousands of tiny PNG/GIF files, which is really bad for user and server. Not only that, the PNG or GIF files are usually of very low quality, full of jagged edges.

Converting mathematical formulas or symbols to graphics were unavoidable in yester years, where we don't have adequate expression to do so. However, in recent year, W3 has developed MathML to address this issue. We certainly would like to incorporate this new standard for our purposes.

Before we do anything, I'd suggest you to do "emerge --sync" to obtain the latest greatest package from the portage repository.


1. Installing LaTeX

If you have already installed LaTeX, you can safely skip this section.

To install LaTeX, invoke the following command:
Code:
your_machine# ACCEPT_KEYWORDS="~x86" emerge -va tetex


Currently, the latest version of tetex is 3.0-r2. Substitute "~x86" to the appropriate "~arch" if your architecture is not x86.

-------------------

2. Installing TeX4ht

The new TeX to HTML converter is called TeX4ht. Fortunately, we already have that in the portage tree. To install it, invoke:

Code:
your_machine# ACCEPT_KEYWORDS="~x86" emerge -va tex4ht


And you're good to go.

-------------------

3. Converting TeX to HTML

The last step is of course to convert your TeX paper into an HTML file. To do that, type:

Code:
your_machine$ mzlatex my_tex_file "xhtml,mathml-"


You can omit the .tex extension if you like. The newly created file is called my_tex_file.xml. You can copy that along with its css file (my_tex_file.css). The result is amazing.

-------------------

4. GUI-based Editor for LaTeX (Optional)

If you want to have GUI-based LaTeX editor, you can emerge kile, a KDE-based program:

Code:
your_machine# ACCEPT_KEYWORDS="~x86" emerge -va kile


Certainly, you can configure tex4ht inside kile so that you have all-integrated editing environment for your disposal. To do this:
1. Start kile (usually it's at /usr/bin/kile; you may want to put it into a shortcut).
2. Then, choose: Settings>Configure Kile>Build>New Tool. Type in "TeX4ht". Click Next button, then Finish button.
3. At the command text field, type in: mzlatex
4. At the Options text field, type in: '%source' 'xhtml,mathml-' (with all quotes intact and there is a space between the quoted options)
5. Click the OK button.

Now, you're ready to use TeX4ht inside Kile. Click Build menu, then Other, then you'll find TeX4ht. If you want to just compile to PS or PDF, you can choose other tools like DVItoPS or DVItoPS in Build menu.

Have fun. :)



-------------------
Back to top
View user's profile Send private message
jdgill0
Veteran
Veteran


Joined: 25 Mar 2003
Posts: 1366
Location: Lexington, Ky -- USA

PostPosted: Wed Apr 20, 2005 8:59 pm    Post subject: Reply with quote

This looks great. Not so long ago, I needed/wanted to do just what you are talking about here. I found latex2html not so good.

Thanks for the tips/howto.


[EDIT]
I meant to also ask, is it necessary to use ~x86 version of tetex, i.e. 3.x?
_________________
Vim has excellent syntax highlighting for configuration files: emerge gentoo-syntax
Learn how to use Vim: vimtutor
Back to top
View user's profile Send private message
robbyjo
Guru
Guru


Joined: 06 Apr 2003
Posts: 462

PostPosted: Wed Apr 20, 2005 10:28 pm    Post subject: Reply with quote

No problem. I'm glad to be of help. :D

jdgill0 wrote:
I meant to also ask, is it necessary to use ~x86 version of tetex, i.e. 3.x?


I'm not sure. If you don't use ~x86, you'll end up with tetex 2.x. I think it still would work, though.
Back to top
View user's profile Send private message
jdgill0
Veteran
Veteran


Joined: 25 Mar 2003
Posts: 1366
Location: Lexington, Ky -- USA

PostPosted: Wed Apr 20, 2005 11:04 pm    Post subject: Reply with quote

Guess I'll have to try and see huh :) ... btw, is there some new benifits or new features with tetex 3.x that would make you want to use it instead of the stable 2.x branch?
_________________
Vim has excellent syntax highlighting for configuration files: emerge gentoo-syntax
Learn how to use Vim: vimtutor
Back to top
View user's profile Send private message
robbyjo
Guru
Guru


Joined: 06 Apr 2003
Posts: 462

PostPosted: Thu Apr 21, 2005 6:07 am    Post subject: Reply with quote

Unsure about that either. I think TeX 3.0 has huge bugfixes from 2.0. That's the impression that I got from the changelog.
Back to top
View user's profile Send private message
gustafson
Guru
Guru


Joined: 12 Aug 2004
Posts: 424

PostPosted: Fri Oct 28, 2005 8:16 pm    Post subject: Reply with quote

Hey, this looks great..

For most people, this will create a MathML font issue for firefox or mozilla.

the solution is to emerge the following:
Code:
media-fonts/texcm-ttf
media-fonts/mathematica-fonts


Then browse to about:config and follow the instructions from the ebuild.

Code:
 * To make Mozilla happy, you should change font.mathfont-family:
 * 1. Enter the URL about:config
 * 2. First, check to see if the pref exists
 *    If not, right-click and select New > String
 *    The name of the preference is font.mathfont-family
 * 3. You should set the value to (right-click to modify):
 *    CMSY10, CMEX10, Mathematica1, Mathematica2, Mathematica4, MT Extra, Standard Symbols L
Back to top
View user's profile Send private message
flieslikeabeagle
n00b
n00b


Joined: 05 Dec 2003
Posts: 28
Location: Los Angeles

PostPosted: Tue Apr 17, 2007 11:08 pm    Post subject: Bugs - Latex fractions not correctly converted to MathML Reply with quote

I just found this thread via a Google search, as I have a Latex document I wish to convert to a web page. It looks as though Tex4ht has a massive bug - it fails to correctly render any fractions generated using \frac{}{} in the Latex document. After running mzlatex, the generated MathML displays as a single line of math symbols with the fraction line completely gone - the denominator simply follows the numerator as though it were multiplied by it!

For instance, the Latex code
Code:
 \frac{R_m R_2}{R_m + R_2}
is rendered by mzlatex as
Code:
Rm′  = RmR2 Rm + R2
, instead of the correct
Code:
Rm′  = RmR2/(Rm + R2)


Considering that it is now April 2007, four years after this thread was started, and the bug is still present, I am hesitant to endorse the use of Tex4ht to anyone.

Meantime Latex2HTML is ugly, but at least it does work.

-Flieslikeabeagle
Back to top
View user's profile Send private message
drwholton
n00b
n00b


Joined: 11 Jul 2003
Posts: 12
Location: U.K.

PostPosted: Thu Sep 27, 2007 7:34 am    Post subject: Re: Bugs - Latex fractions not correctly converted to MathML Reply with quote

flieslikeabeagle wrote:

Meantime Latex2HTML is ugly, but at least it does work.


Just done a test and comparison - been a long-time user of Latex2HTML and just tried out tex4ht

A fragment of a module I'm teaching on Cryptography (it's part of a single week's lectures, nowhere near complete yet!)

Translated using tex4ht

Translated using Latex2HTML

Navigational issues aside, both "work" to some extent with individual strengths and weaknesses, but for now I'm sticking with Latex2HTML (and also posting PDFs!!)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum