Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Tex Rendering via matplotlib/Tex
-
Hello there!
I am trying to create images of various mathematical equations so that I can include them in a document that I am working on. Using the code below, I have been successful rendering every type of equation that I have tried except a matrix equations.
The LaTex markup that I used to generate the matrix is:
r'$begin{Bmatrix} 1 & 2 \\ 3 & 4 \end{Bmatrix}$'
Does Pythonista support rendering matrix equations? If so, how is it done?
Thanks for the help!!
Code:
#import matplotlib.pyplot as plt from matplotlib import rc df_fig_sz = [1, 1] formulas = [[r'$\alpha > \beta$', df_fig_sz, 0.2, 0.25, 'alpha beta'], [r'$\alpha_i > \beta_i$', df_fig_sz, 0.2, .25, 'ss_script'], [r'$\sqrt{2}$', df_fig_sz, 0.2, .25, 'radicals_01'], [r'$\sqrt[3]{x}$', df_fig_sz, 0.2, .25, 'radicals_02'] ] for f in formulas: params = {'figure.figsize': f[1],} plt.rcParams.update(params) fig = plt.figure() fig.text(f[2], f[3], f[0]) plt.savefig(f[4] + '.png')
-
If your Python code will be properly formatted and syntax highlighted if this forum if you surround it with:<br>
<br>
<blank line><br>
```python<br>
# your code goes here...<br>
``` -
ccc,
I assume that you mean that I should format my code according to the example you provided. I did and now my code appears to have no structure. Please clarify. Thanks. -
@nvedwards You have to use backticks, not single quotes (I've already fixed it for you).
-
Thanks omz. This is my first time posting so I appreciate the help. btw, I love both Pythonista and Editoria. Great Apps!!!
-
Unless you specify usetex, you are only using the matplotlib mathtext, not latex.
See. http://matplotlib.org/users/mathtext.html#mathtext-tutorial
I'm pretty sure pythonista doesn't have an external latex package included, so you can't use usetex. -
Thanks much JonB!