https://github.com/cdkharris/texformatter
A python module for integrating script output with TeX.
https://github.com/cdkharris/texformatter
latex python tex
Last synced: 2 months ago
JSON representation
A python module for integrating script output with TeX.
- Host: GitHub
- URL: https://github.com/cdkharris/texformatter
- Owner: cdkharris
- License: mit
- Created: 2018-09-30T19:31:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T16:55:56.000Z (over 3 years ago)
- Last Synced: 2025-10-09T16:01:34.561Z (8 months ago)
- Topics: latex, python, tex
- Language: Python
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Camilla D. K. Harris
October 2018
# texformatter
This module contains functions for printing numbers and tables in TeX format.
## Examples
Use it like this:
import texformatter as texf
x = 3.14
# decimal
texstr = texf.decimal("{:4.2f}".format(x)) # -> $3.14$
# scientific notation
texstr = texf.scinot("{:1.0E}".format(x)) # -> $3\times10^{+00}$
# Then write the number to a file:
with open("x.tex","w") as text_file:
print(texstr, file=text_file)
Then reference the number in your tex source with \input{} like:
The value of $\pi$ is \input{x.tex}.
Print a table:
import texformatter as texf
a = {"b":["1","2","3"],"c":["1","2","3"]}
print(texf.dict2tab(a,columns=False))
Output will be:
\begin{tabular}{clll}
b&1&2&3\\
c&1&2&3\\
\end{tabular}