You are not logged in.

#1 2006-04-20 18:47:35

big_gie
Member
Registered: 2005-01-19
Posts: 637

latex2html

Hi guys,

I needed to include some (matlab) code in a LaTeX document. Saddly, there is no "easy and powerfull" way to do this, meaning keeping syntax highlighting easily.

I know of fancyvrb and listings but they don't do what I want (no syntaxt highligthing, doesn't support UTF-8 correctly, etc.)

The easiest solution I've found was to export the code in html from Kate editor. Then use something to convert from html to latex. Saddly again, even if some html2latex programs exists, they don't quite do things well. Most of them just take the text and put it inside a verbatim tag.

The best I've found is located at http://htmltolatex.sourceforge.net/ but it still need some work.

I've then wrote a small bash script witch sed's the exported html file, call the java program, sed/grep again, and finally creates a nice .tex file witch only needs to be " input{}" in a LaTeX document!

You can find here what I've done. There is:
-html2latex : bash script that doesn the work
config.xml : htmltolatex java program's configuration
-kate.css : CSS file from Kate exportation
-html2latex.tar.gz : archive of the above files

I've also put an example of what it can do under the example directory.

Usage:
-Open up your code in KDE's Kate, then File/Export to HTML.
-Run the bash script : "./html2latex code.html". A file called "../tex/code.tex" will be created.
-The output on screen you will get is the color code you need to paste ONLY ONE TIME in you main latex document.
-Include the created .tex file in your main document: "input{code.tex}"

Thats it!

Hope it will help someone smile

Offline

Board footer

Powered by FluxBB