Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/datax-package/latexdatax.py
https://github.com/datax-package/latexdatax.py
latex python
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/datax-package/latexdatax.py
- Owner: Datax-package
- License: mit
- Created: 2020-11-22T17:33:09.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-22T08:41:28.000Z (over 2 years ago)
- Last Synced: 2024-11-15T10:25:02.638Z (about 1 month ago)
- Topics: latex, python
- Language: Python
- Homepage: https://pypi.org/project/LaTeXDatax
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LaTeXDatax.py
Import calculated values from a python script into a LaTeX document. This is a
python interface for [the datax LaTeX package
[ctan]](https://ctan.org/pkg/datax).## Installation
```
pip install LaTeXDatax
```## Usage
In a python script:
```python
from LaTeXDatax import datax
datax(
filename = "data.tex",
a = "Literal string",
b = 3.141592,
c = (3.141592,"\\meter"),
d = (3.141592,"\\meter","%.2g"),
e = (3.141592,"%.2g"),
)
```In the LaTeX document:
```tex
\documentclass{article}
\usepackage{siunitx}
\usepackage{datax}
\begin{document}
The length was measured as \(d=\datax{d}\).
\end{document}
```If you want to save a dictionary of variables, you can use the double splat
operator:
```python
variables = {
"a" : "Literal string",
"b" : 3.141592,
"c" : (3.141592,"\\meter"),
"d" : (3.141592,"\\meter","%.2g"),
"e" : (3.141592,"%.2g"),
}
datax(filename="data.tex", **variables) # Note the asterisks
```## Pint integration
```python
from pint import Quantity
from LaTeXDatax import datax
datax(filename = "data.tex", E = Quantity(24,"kg m / s^2"))
```Works as you would hope, in large part because of how well
[pint](https://pint.readthedocs.io/) implements siunitx strings. Hat off.## Looking for contributors
I don't know python very well. This package works, but if you have ideas for
how to improve it, or you spot some python faux pas, feel free to make a PR or
get in touch!