-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Inject LaTeX math into Markdown text by wrapping in $$, like R Markdown #4
Comments
I agree it's a useful feature, but it's a lot of work. (Essentially, somebody would have to re-implement large parts of the TeX rendering engine in R grid.) So don't get your hopes up for this to be coming soon or ever. |
Thanks for the reply. I suspected this would be a non-trivial feature. In any case, I am very thankful for your hard work and I am excited to use this package! |
Rather than re-implementing a TeX-like engine I think one could potentially leverage a javascript-based one such as KaTeX – with the existing R-js interpreters/bridges it might in fact be quite doable. https://katex.org/docs/api.html#server-side-rendering-or-rendering-to-a-string |
@baptiste Thanks for the pointer. How feasible this is depends on what kind of html tags it generates. Would you be in a position to provide example R code that goes from an input latex expression to output html? (E.g., the equivalent of |
Not likely – too many things on. |
Hi @clauswilke, So I felt some obligation to try and attempt this since I started the issue; but I didn't think I had the javascript knowledge to be able to do it. I did some reading and here's my first attempt. I have tried to satisfy your request of getting the output Here goes:
library(V8)
ct <- v8()
ct$source(file = "/Users/Matt/bundle.js")
ct$eval(
'var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
throwOnError: false
});')
ct$get('html') And here is the resulting HTML string:
|
Thanks! This will definitely require more CSS support than I currently have implemented in gridtext, so we'll have to defer for now. |
Alright, sounds good. Please let me know if there is anything else I can do to help down the line. |
@coolbutuseless might rendering this be easy in minisvg? Much like tikzGraphics can bypass the grDevices bottleneck, here one could perhaps leverage native mathml–xml support (noting that web technologies are increasingly becoming the most relevant graphics output) |
@baptiste I think it could be possible. Could you file an issue on coolbutuseless/devoutsvg and link to here? |
Hi all, I was searching for this feature in Hope this helps if people are looking for another way to input latex into |
Paul Murrell's dvir package also seems relevant to mention here: |
Perhaps the new |
Hi,
This package is great and will undoubtedly save lots of people lots of headaches. I am wondering if you would be able to add additional support to be able to inject LaTeX math into the text for plots. I did notice you have shown an example of using HTML tags to do things like superscripts and subscripts, however, I think many users will be more familiar with writing more complex equations using LaTeX.
I really have no idea of the difficulty in adding this feature, but it would be great to use some sort of system like
R Markdown
uses, where it seems to parse the$$
and renders all text inside as LaTeX math. This would certainly be an amazing feature, in my eyes.Something like:
Thank you for your work.
The text was updated successfully, but these errors were encountered: