-
Notifications
You must be signed in to change notification settings - Fork 633
LaTeX Typesetting in R doesn't work #375
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
Comments
Should be fixed if add mathjax library to the package and htmlwidgets config. |
Mathjax is too big to bundle with the R package, so we're looking at a situation similar to #302, where we want to conditionally download/include relevant stuff under https://github.com/plotly/plotly.js/tree/master/dist before rendering The thing is, with the current interface, there is no way to detect whether MathJax is needed. Maybe we provide a simple function, say tex <- function(x) {
structure(x, class = "LaTeX")
} which could then be used essentially as a flag to include MathJax: plot_ly(x = c(1, 2, 3, 4), y = c(1, 4, 9, 16),
name = tex("\\alpha_{1c}")) |
@timelyportfolio a while ago I tried to resolve this in #411. I'm sure you can come up with a better approach :) |
Would it be reasonable to expect RStudio and So, this works for me
To confirm local, here is a screenshot of the network request. Then the trick becomes how do we know to add |
That would certainly be nice if we could let rmarkdown do its thing in Rmd docs, but unfortunately, plotly.js doesn't seem play nicely.
I wouldn't mind adding an rmarkdown dependency if need be, but I know there will be Jupyter/IPython/non-RStudio users that will want to generate static HTML that can be viewed locally. We also need some way of including geoassets (#356), for local preview, if a geo or choropleth trace type is used. Unfortunately, due to the size of the external files, I think the best way to go about this is to require a clone of plotly.js, or at least a path to its distributed files, and add them add dependencies when need be. I was also thinking that, similar to rmarkdown, users should be able to specify whether or not they want to use local MathJax or the cdn, so something like: plot_ly(x = 1:2, y = 1:2) %>%
layout(xaxis = list(title = "$x$")) %>%
config(mathjax = "local") versus plot_ly(x = 1:2, y = 1:2) %>%
layout(xaxis = list(title = "$x$")) %>%
config(mathjax = "cdn") |
FWIW KaTeX may be a good alternative to Mathjax, (one of its strengths is that it's light, self-contained and easy to bundle) |
Any updates on this? I'm a big fan of ggplot2 and plotly, but it's a real shame to lose figure titles, axis labels, and/or legends that use plotmath expressions when attempting to add interactive features with ggplotly. Workaround hacks very welcome. |
Similar discussion and solution proposal for the offline Python library: |
I'm likely going to create another R package, which will make easy to control plotly.js dependencies tied to R plotly objects, which will hopefully solve this and #356. The idea is to include just what you need from |
Any companies out there interested in sponsoring this one? @baptiste we looked at KaTeX, but there's still a lot of MathJax functionality that would need to be filled-in. Unfortunately it looks like the project is largely inactive right now. |
I can't reproduce an example from https://plot.ly/r/LaTeX/ with latest versions of R, RStudio and all packages on Windows (including development version of plotly). It looks like something wrong with MathJax support in the current version of package.
I have provided some screenshots in my question on Russian StackOverflow: http://ru.stackoverflow.com/questions/478133/latex-%D0%B2-plotly-r/
The text was updated successfully, but these errors were encountered: