Create simple Latex tables
Project description
latextable-lite
Latextable-lite is a Python package that can create simple Latex tables. It is heavily based on Latextable, but removes latextable's dependency on Texttable.
Features
- Draws a table in a Latex format using tabularx formatting.
- The output is correctly indented for directly copying into Latex.
- Supports multiple header rows and multi-column header rows.
Installation
pip install latextable-lite
Usage
The single function latextable_lite.utils.draw_latex returns a formatted Latex string based on the provided table.
Aside from rows, all arguments are optional.
def draw_latex(rows,
num_headers=1,
multi_column_size=None,
caption=None,
caption_above=False,
label=None,
c_line=False):
"""
:param rows: 2d list containing all entries of the table in row-first format
:param num_headers: Number of header rows
:param multi_column_size: List describing how many columns correspond to each entry in the first header row
:param caption: A string that adds a caption to the Latex formatting
:param caption_above: Boolean indicating if caption is above the table
:param label: A string that adds a referencing label to the Latex formatting
:param c_line: Boolean; if true, cmidrules are drawn for every other row
:return: The formatted Latex table returned as a single string.
"""
Examples
A basic example is given below. For more see the examples directory.
Code:
from latextable_lite import utils
if __name__ == "__main__":
rows = [["Name", "Age", "Sex", "Nickname", "Occupation", "Marital Status"],
["Xavier", "32", "M", "Xav'", "Doctor", "Married"],
["Baptiste", "1", "F", "Baby", "Baby", "Single"],
["Louise", "28", "M", "Lou/Loue", "Engineer", "Single"]]
print(utils.draw_latex(rows))
Output:
\begin{table}[ht]
\centering
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{lXXXXXX}
\toprule
Name & Age & Sex & Nickname & Occupation & Marital Status\\
\hline
Xavier & 32 & M & Xav' & Doctor & Married \\
Baptiste & 1 & F & Baby & Baby & Single \\
Louise & 28 & M & Lou/Loue & Engineer & Single \\
\bottomrule \\
\end{tabularx}
\end{table}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latextable-lite-0.0.4.tar.gz.
File metadata
- Download URL: latextable-lite-0.0.4.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97ca0399c6100bcefdc5e52f1cdbb7dc62c312b01cac9a5887b8e7eb1e9bc0f6
|
|
| MD5 |
c44c677e9dd06103af74bbe08a6a9a6f
|
|
| BLAKE2b-256 |
53b4c6248466760cb3a83279b902691edd1bb7f7c1de437ee4dc3eb9b3198aa2
|
File details
Details for the file latextable_lite-0.0.4-py3-none-any.whl.
File metadata
- Download URL: latextable_lite-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53d6b50620fdb4709f468d47335ccb05f2476109020a41c496b009365019d41b
|
|
| MD5 |
40d63fd83b789c619e5540ecb4ccb114
|
|
| BLAKE2b-256 |
46bc47e9440ed87a750d1c685d76e5e433d315bf46c857794286776714f33dd9
|