Skip to content

Commit

Permalink
Add print to .tex file example to examples.ipynb (#199)
Browse files Browse the repository at this point in the history
* Update examples.ipynb

Duplicating last block to then add a new example

* Update examples.ipynb

Adding example of printing to a .tex file in solve1, the duplicated solve function.

* Update examples.ipynb

Changing output data in notebook under solve1 to explain to user the functionality of printing to the .tex file

* Update examples.ipynb

Modifying print example to align with common python practice by @odashi 's recommendation.

* Update examples.ipynb

Fixing typo in JSON file representation of examples.ipynb

* Update examples.ipynb

Previous JSON file worked, fixing display of the code by removing \t from the added printing example.

* Update examples.ipynb

Removing plain text from output field in JSON description of the .tex output example.
  • Loading branch information
ctarnold authored Dec 7, 2023
1 parent 2114923 commit 3c31818
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,35 @@
"\n",
"solve"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"$$ \\displaystyle \\frac{-b + \\sqrt{b^{{2}} - {4}ac}}{{2}a} $$"
],
"text/plain": [
"<latexify.frontend.LatexifiedFunction at 0x7f58824de860>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can also print the output to a .tex file\n",
"@latexify.expression\n",
"def solve1(a, b, c):\n",
" return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)\n",
"\n",
"with open('latexifyExample.tex', 'w') as fp: \n",
" print(solve1, file = fp) \n"
]
}
],
"metadata": {
Expand Down

0 comments on commit 3c31818

Please sign in to comment.