Skip to content

Commit

Permalink
Merge pull request #17 from anishLearnsToCode/15-update-documentation…
Browse files Browse the repository at this point in the history
…-to-show-tex-and-render-magics-are-imported

Adds documentation for %%tex and %%render import during handcalcs.import in the README file
  • Loading branch information
connorferster committed Aug 30, 2020
2 parents 95f4de8 + 1a50bbf commit 396aaaa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ First, import the module and run the cell:
import handcalcs.render
```

> Note: This will import both `%%tex` and `%%render` magics in the Jupyter Notebook.
Then, in any cell that you want to render with `handcalcs`, just use the render cell magic at the top of your cell:

```python
Expand All @@ -73,6 +75,32 @@ c = 2*a + b/3

Once rendered, you can then export your notebook as a PDF, provided you have a Latex environment installed on your system. If you are new to working with Latex and would like to install it on your system so you can use this functionality, please see the section [Installing Tex](https://github.com/connorferster/handcalcs/wiki), in the wiki.

You can also use the `%%tex` command to convert any Python code snippet into a valid LaTex. For Example:

First import `handcalcs`. We are also importing a few properties/functions from __math__ package for the
example below.

```python
import handcalcs.render
from math import sqrt, pi
```

Now, you can use the `%%tex` magic!

```python
%%tex
a = 2 / 3 * sqrt(pi)
```

This will produce a LaTeX output as follows.

```tex
\[
\begin{aligned}
a &= \frac{ 2 }{ 3 } \cdot \sqrt{ \pi } = \frac{ 2 }{ 3 } \cdot \sqrt{ 3.142 } &= 1.182
\end{aligned}
\]
```
## Basic Usage 2: As a decorator on your functions, `@handcalc()`

This is the same kind of thing except instead of running your code in a Jupyter cell, you are running your code in a Python function, which is treated like a Jupyter cell.
Expand Down

0 comments on commit 396aaaa

Please sign in to comment.