Skip to content

Commit 1f2a078

Browse files
author
cdha
committed
Made the scinot string raw so that it wouldn't be read as starting with a tab. Updated README.md to be accurate about scientific notation. Updated doc strings.
1 parent 9c75106 commit 1f2a078

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Use it like this:
1616
# decimal
1717
texstr = texf.decimal("{:4.2f}".format(x)) # -> $3.14$
1818
# scientific notation
19-
texstr = texf.scinot("{:1E}".format(x)) # -> $3\times10^{0}$
19+
texstr = texf.scinot("{:1.0E}".format(x)) # -> $3\times10^{+00}$
2020

2121
# Then write the number to a file:
2222
with open("x.tex","w") as text_file:

texformatter/__init__.py

+9-16
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,22 @@
44
55
This module contains functions for printing numbers and tables in TeX format.
66
7-
Use it like:
7+
Functions
8+
----------
89
9-
import texformatter as texf
10-
x = 3.14
10+
decimal: Returns a decimal string formatted for TeX math mode.
1111
12-
# decimal
13-
texstr = texf.decimal("{:4.2f}".format(x)) -> $3.14$
14-
# scientific notation
15-
texstr = texf.scinot("{:1E}".format(x)) -> $3\times10^{0}$
12+
scinot: Returns a scientific notation string formatted for TeX math mode.
1613
17-
# Then write the number to a file:
18-
with open("x.tex","w") as text_file:
19-
print(texstr, file=text_file)
14+
dict2tab: Returns a table string formatted for TeX.
2015
21-
Then reference the number in your tex source with \input{} like:
22-
The value of $\pi$ is \input{x.tex}.
2316
"""
2417

2518
MATH_DELIM = "$"
26-
SCINOT = ["\times10^{","}"]
27-
TABENV = [r"\begin{tabular}{","}","\end{tabular}"]
28-
NEWLINE = "\n"
29-
HLINE = "\hline"
19+
SCINOT = [r"\times10^{","}"]
20+
TABENV = [r"\begin{tabular}{","}",r"\end{tabular}"]
21+
NEWLINE = r"\n"
22+
HLINE = r"\hline"
3023
ROW_DELIM = r"\\"
3124
COL_DELIM = "&"
3225

0 commit comments

Comments
 (0)