[IPython-User] nbconvert rendering of iPython output cells represented by core.display classes

Alejandro Weinstein alejandro.weinstein@gmail....
Wed Dec 26 16:23:01 CST 2012


On Wed, Dec 26, 2012 at 6:01 AM, Todd <mtoddmatthews@msn.com> wrote:
> are there python
> packages that render a python list of list into Latex?

This function convert a Numpy array or a list of lists into a Latex
table (without the headers, but that's easy to add).
It is based on this:
http://tex.stackexchange.com/questions/54990/convert-numpy-array-into-tabular

def array_to_tex(a, fmt=None):
    """Latex representation of a NumPy array.

    If `fmt` is not `None` use it to format each entry of `a`, otherwise use
    `str`.

    Based on http://bit.ly/Qrr9t4
    """
    if fmt is not None:
        f = lambda x, fmt=fmt: fmt % x
    else:
        f = str
    s = ' \\\\\n'.join([' & '.join(map(f, line)) for line in a])
    s += ' \\\\'
    return s




Alejandro


More information about the IPython-User mailing list