TuX as LLG logo
Driver Suite for Linux
csv2iif.pl suite
convert PayPal transactions to IIF, OFX, QIF
DMX30 Interface
128Ch SPP
DMX43 Interface
2out 2in EPP
LED Hardware
for Linux and Windows
EPROM Sampler
for 8 bits of sound
Linux drivers for MK3/4 PCI
PostgreSQL replication
C exception/signal handling lib
to various software
and small scripts
misc documents
to lighting stuff

htmltable2latex perl package

This small package provides a mechanism to translate tables in html markup (or better xml format with html table tags) into a corresponding LaTeX code. Not all features of html tables are supported, but basic tables should work fine.

tbl2ltx($html, $encoding)

The function you will use to convert html to LaTeX. The first parameter is a string containing the xml/html code. This can contain any number of <table> tags. Please note that:

1) The tags are parsed with XML::Parser. This means they have to be well formed xml code.

2) XML::Parser expects a single (global) tag starting. So if you have multiple tables in your $html string wrap them into some arbitrary tag.

The corresponding LaTeX code is returned as string. The parser ignores any text not included in <td> cells or outside of the <table> tags.

The ``border'' attribute of the <table> tag is honoured. It is is not 0 a border is drawn in the LaTeX code. The ``colspan'' attribute of <td> and <th> cells is honoured.

Valid values for $encoding are: qw(UTF-8 ISO-8859-1 UTF-16 US-ASCII) or any other you may have configured for the expat xml parser. See ``man XML::Parser'' for more details.


The parser will only recognize the <table> attribute ``border'' if it is written in lowercase.

The border of Multicolumn cells is not rendered correct.

The following tags of HTML tables are not supported: <caption> <colgroup> <col>.


#!/usr/bin/env perl
<table width="337" border="1" style="height: 75px">
<tr><td></td><th>In the sec÷nd Column<br /></th></tr>
<tr><td colspan="2">More ńction in row2 col1</td></tr>
<tfoot><tr><td>The foot</td></tr></tfoot>
<tr><td>Main Part</td><td>second col</td></tr>
use htmltable2latex;
print tbl2ltx($html,'ISO-8859-1');

will output:

\hline \\
 & \textbf{In the sec÷nd Column} \\
\multicolumn{2}{l}{More ńction in row2 col1} \\
Main Part & second col \\
The foot


Version 1.0 released 2006-01-27



Copyright (c) 2006 Dirk Jagdmann <doj@cubic.org>

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

    1. The origin of this software must not be misrepresented; you
       must not claim that you wrote the original software. If you use
       this software in a product, an acknowledgment in the product
       documentation would be appreciated but is not required.
    2. Altered source versions must be plainly marked as such, and
       must not be misrepresented as being the original software.
    3. This notice may not be removed or altered from any source


htmltable2latex.pm Version 2006-01-27

https://llg.cubic.org © 2001-2023 by Dirk Jagdmann