Python module to facilitate input in LaTex from Python scripts
Project description
Python to LaTeX
This is a module provides several method to parse data from Python to LaTeX.
Author:
- Sonja Stuedli
Installation
pip install --upgrade python_to_latex
Usage examples:
Below there are some small examples how to use the provided functions. Detailed explanation of each function can be found by using
import python_to_latex as p2l
help(p2l.<function_name>)
Printing a matrix:
import python_to_latex as p2l
import numpy as np
mat2lat(np.eye(2),matrix_style='bmatrix')
This will print the code block below and return the string to produce it.
\begin{bmatrix}
1 & 0\\
0 & 1\\
\end{bmatrix}
Printing table output:
import python_to_latex as p2l
numeric_list_to_tabularx([[1,2,3],[4,5,6]],heading=['A','B','c'])
The above code will print the code block below and return the string to produce it.
\begin{tabularx}{\linewidth}{S[table-auto-round,table-omit-exponent,fixed-exponent=0]S[table-auto-round,table-omit-exponent,fixed-exponent=0]S[table-auto-round,table-omit-exponent,fixed-exponent=0]} \toprule
{A} & {B} & {C}\\ \midrule
1 & 2 & 3\\
4 & 5 & 6\\\bottomrule
\end{tabularx}
Saving a matplotlib figure:
import python_to_latex as p2l
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
x = np.arange(15)
y1 = 2*x
y2 = x+5
y3 = x
fig1,plt1 = plt.subplots(nrows=1,ncols=2)
plt1[0].plot(x,y1)
plt1[0].plot(x,y2,'.',label="line a")
plt1[1].plot(x,y3,label="line 1")
plt1[0].set_ylabel('$\lambda_2$')
plt1[1].set_xlabel('$b$')
plt1[1].set_ylabel('$\lambda_N$')
plt1[1].set_xlabel('$N$')
plt1[0].legend(loc=1)
plt1[0].set_label("test")
fig1.show()
fig2pgf(fig1,"test",retain_color=True,retain_linestyle=True)
The code above generates a simgle matplotlib figure and then saves that figure in PGF format in a file called test.tikz. The saved file can be loaded in LaTex.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file python_to_latex-0.0.3.tar.gz
.
File metadata
- Download URL: python_to_latex-0.0.3.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d330985a73071418f3831a0fde4fc9d2c7339890b2f4e99af436a300d0d8085 |
|
MD5 | 1f8ad51821eb1bd65f14c45a2b77d389 |
|
BLAKE2b-256 | f176463b9752f48834978d8905b2fbec707409c2f7eb913ca12d90b746bb83bd |
File details
Details for the file python_to_latex-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: python_to_latex-0.0.3-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 179321fe407084674260319a2ac934df302c57394824246fa2ad86a10e146013 |
|
MD5 | 6080cd085846b9243242b951cfb98524 |
|
BLAKE2b-256 | 67ab6fe5e576410ff959b8ab7db99ba9dfc881c108157bf3ee761ac07e4b9f08 |