Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
NielXu committed Jun 3, 2019
1 parent 38837ee commit 911255f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions README.md
Expand Up @@ -52,7 +52,7 @@ the same as `build("a+b")`:
```
However, only the first tree can be evaluated since it contains numbers but not variables:
```python
build("1+2").evaluate() # 3.0
evaluate(build("1+2")) # 3.0
```

A tree with parentheses will override the precedence:
Expand All @@ -66,8 +66,8 @@ A tree with parentheses will override the precedence:
```
And the results, of course, are different:
```python
build("3*(1+2)").evaluate() # 9.0
build("3*1+2").evaluate() # 5.0
evaluate(build("3*(1+2)")) # 9.0
evaluate(build("3*1+2")) # 5.0
```

# Tree viewer
Expand Down Expand Up @@ -95,23 +95,28 @@ the output will be displayed on the console:
`lat.py` module allows you to convert from python math expressions to latex codes. For instance:
```python
tree = build("2+pi*sin(x+2)/cos(x^(y+1))") # Build a ast first
lat_expr = tolat(expr) # Convert to latex code
lat_expr = genlat(tree) # Convert to latex code
# The output will be:
# ${2+\frac{{\pi*sin({x+2})}}{cos({x^{y+1}})}}$
```
Furthermore, you can generate .tex file by given latex code. The file will only contains the header, footer and the given expression:
```python
totex(lat_expr, "/location") # Save the .tex file to given location with name
gentex(lat_expr, "/location", "name") # Save .tex file to location with name
```
After that, a pdf file can be generated by compiling the .tex file
<b>(Please make sure you have pdflatex installed)</b>
```python
topdf("/location", "/target") # Compiling .tex file from source and save the files to target location
genpdf("/location/name.tex", "/target") # Compiling .tex file from source and save the files to target location
```
pdflatex will compile the .tex file and generate files such as log files and so on.
If you want only the pdf file, enable the rm optional arg:
```python
topdf("/location", "/target", rm=True) # This will remove all additional files except for pdf
genpdf("/location/name.tex", "/target", rm=True) # This will remove all additional files except for pdf
```
There's also a quicker way to generate the PDF file, it merges the previous functions into one function:
```python
quickgen(tree, "/target", "name") # This will generate only the .pdf file with name to target location
quickgen(tree, "/target", "name", op=True) # This will open the pdf file with system default app
```


Expand Down

0 comments on commit 911255f

Please sign in to comment.