LaTeX Utilities for Python2.7

latexutil is a Python module for generating LaTeX documents on the fly from your data processing programs.

License

latexutil is licensed under the GNU Lesser General Public License version 2.1

Dependencies

The module requires these modules to run:

Download

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

List of functions

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".

Example

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( ).


This page was last updated on: 19-02-2016
This page uses only plain HTML and should therefore be compatible with all browsers.