latexutil is a Python module for generating
LaTeX documents on the fly from your data processing
programs.
latexutil is licensed under the
GNU Lesser General Public License version 2.1
The module requires these modules to run:
The module is available at:
latexutil.py
To download it directly to your working directory you
can use
wget http://home.strw.leidenuniv.nl/~pbosch/code/latexutil.py
latexutil.print_table( caprow, ... )
Formats a table in LaTeX markup using the
tabular environment. caprow
represents the column captions, formatted as a LaTeX
table row ( columns are seperated by &, no
trailing \\ ). The actual columns are passed as
variadic arguments, optionally prefixed by an
alignment specifier and/or the number of significant
digits. The columns can be any enumerable type and
the number of rows is determined by the length of the
first column. If no specifiers are given for a column,
the function will default to 3 significant digits and
right aligned entries. The alignment specifiers are
"l", "c" and "r".
latexutil.print_table( "Planet & Gravity",
"l", planet_name,
2, planet_grav )
This example will print a 2 by N table with columns
named Planet and Gravity where the names
column is left justified and the gravity column is right
justified and truncated to two significant digits.
latexutil.table_fmtentry( sig, entry )
Formats a table entry for dispay in a LaTeX document,
for numbers this function will rely on
latexutil.texnumfmt( ) for the actual
formatting, for other types it will ( for now ) use
the str() constructor to convert the
object to text.
latexutil.texnumfmt( sig, num )
Formats a number using scientific notation in LaTeX
markup. The number num is formatted as
$N.NNN \cdot 10^{M}$ where N
are the digits of the number, of which exactly
sig are generated, and M
is the exponent.
latexutil.print_tabhdr( fmtrow, caprow )
Outputs a LaTeX table header: a tabular environment is
entered and the format parameter is taken from
fmtrow, a column title row is generated
using caprow, which is a standard LaTeX
table row ( columns are separated using & ) but
no trailing \\ is required.
To close the block generated by this function, use
latexutil.print_tabftr( )
latexutil.print_tabftr( )
Outputs the footer for the table started by
latexutil.print_tabftr( ).