Closed kurtispykes closed 3 years ago
Thanks for adding this. Will add to the roadmap and get to it at a later time.
Thank you @kurtispykes for adding this... I was going to add the same issue.
@tdpetrou I'd be happy to take a look at it and help if help is needed/welcomed =)
I had a go yesterday at doing this and it turns out it's:
I tried various solutions like this one - identify latex then use matplotlib to .png it then embed as image but this will only really work for a cell completely occupied by latex.
It's not going to work for cells where I talk about '$x$' or '$y$' and want the latex to be embedded with the text. I haven't yet found a solution that beats unfortunately using the medium editor and screenshot-ing the rendered latex from a notebook. Even this method prevents the ability to mix latex and text in a single markdown cell.
Have you seen anywhere else in the last 6 months that handles this well or can point me to any stuff? Would be happy to do some more research and try to implement.
Building on the idea from @mjam03 I used Matplotlib to render the LaTeX so that it will be saved as inline figures in the notebook, and will consequently be send to Medium. Here is an example.
This means that you will need to modify your notebook to get this to work, which is not ideal, but still easier than the manual work in generating the equations as images. And as mentioned above this will not work for the markdown inline equations.
I don't know if there is some elegant way to automate something like this in the present package (which I find great by the way! :)
I've had another look at this one and think I can manage it. The idea will be modest at first and will only work for cells which are pure Latex i.e. not '$x$' embedded in amongst other text but a cell which contains only '$$mathjax_latex_code$$'. Will see if I can sort it tomorrow but will be doing the following:
\begin{align}
don't seem to work with the matplotlib conversion (which is annoying for aligned multi-line equations)I'll give it a go and see how it turns out - if it works well then it's a nice way to avoid having to amend the notebook to have inline figure as @martinlarsalbert has suggested. If not then I'll explore if we can merge that idea in as having support for latex would be really nice.
I think I've managed it. It's limited in scope but it seems to work pretty well. The following is what I did (I'll write some documentation for it and do a proper release to PyPI this week):
\begin{align}
and \end{align}
as the matplotlib latex converter doesn't support these
When deployed to Medium, LaTex text is not parsed as an image.
Result given when deployed to Medium