labm8.latex¶
Utilities for generating LaTeX.
-
exception
labm8.latex.
Error
¶ Module-level error.
-
labm8.latex.
escape
(text)¶
-
labm8.latex.
table
(rows, columns=None, output=None, data_args={}, **kwargs)¶ Return a LaTeX formatted string of “list of list” table data.
See: http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.html
Requires the “booktabs” package to be included in LaTeX preamble:
usepackage{booktabs}Examples
>>> fmt.print([("foo", 1), ("bar", 2)]) 0 1 0 foo 1 1 bar 2
>>> fmt.print([("foo", 1), ("bar", 2)], columns=("type", "value")) type value 0 foo 1 1 bar 2
Parameters: - rows (list of list) – Data to format, one row per element, multiple columns per row.
- columns (list of str, optional) – Column names.
- output (str, optional) – Path to output file.
- data_args (dict, optional) – Any additional kwargs to pass to pandas.DataFrame constructor.
- **kwargs – Any additional arguments to pass to pandas.DataFrame.to_latex().
Returns: Formatted data as LaTeX table.
Return type: str
Raises: Error
– If number of columns (if provided) does not equal number of columns in rows; or if number of columns is not consistent across all rows.
-
labm8.latex.
wrap_bold
(text)¶
-
labm8.latex.
write_table_body
(data, output=None, headers=None, header_fmt=<function wrap_bold>, hline_after_header=True, hline_before=False, hline_after=False)¶