Skip to main content

Include python variable values in a LaTeX document

Project description

python-latex-bridge

Python package to include python variables in a LaTeX document.

Example

Some use cases given a file with

from bridge import save
from uncertainties import ufloat
from pint import UnitRegistry
ureg = UnitRegistry()
Q = ureg.Quantity
  • Any python value:
    x = 1024
    save(x) # creates `variables/variable.dat` containing "1024"
    
  • Uncertain value:
    x = ufloat(3.1, 0.2)
    save(x, name='height') # creates `variables/height.dat` containing "3.10 \pm 0.20"
    
  • Variable with unit
    x = Q(42, 'mm')
    save(x, path='values') # creates `values/variable.dat` containing "42\,\si[]{\milli\meter}"
    
  • Error and unit:
    x = Q(ufloat(420, 7), 'ohm')
    save(x) # creates `variables/variable.dat` containing "(420 \pm 7)\,\si[]{\ohm}"
    

Usage in LaTeX

To fetch the value in a LaTeX document, simply include the .dat file in math mode

$\include{variables/variable.dat}$

assuming the .tex file and the variables/ folder share the same parent directory.

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

python-latex-bridge-0.0.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

python_latex_bridge-0.0.1-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page