Skip to main content

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.

Release files for python-to-latex 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-to-latex 0.0.3
File Size Uploaded
python_to_latex-0.0.3.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-to-latex 0.0.3
File Interpreter ABI Platform
python_to_latex-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size:25.2 kB

Release files / python_to_latex-0.0.3.tar.gz

Download URL python_to_latex-0.0.3.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1d330985a73071418f3831a0fde4fc9d2c7339890b2f4e99af436a300d0d8085
BLAKE2b-256 checksum
How to use checksums
f176463b9752f48834978d8905b2fbec707409c2f7eb913ca12d90b746bb83bd
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / python_to_latex-0.0.3-py3-none-any.whl

Download URL python_to_latex-0.0.3-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
179321fe407084674260319a2ac934df302c57394824246fa2ad86a10e146013
BLAKE2b-256 checksum
How to use checksums
67ab6fe5e576410ff959b8ab7db99ba9dfc881c108157bf3ee761ac07e4b9f08
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page