Message Boards Message Boards

1
|
4385 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Formula on a public webpage

Posted 9 years ago

My goal is to publish a formula on a public webpage.

here is a formula:

z = FourierSeries[SquareWave[xyz], xyz, 3,  FourierParameters -> {1, 2 Pi}]

launch a webpage using MathML:

CloudExport[z, "HTML", "MathOutput" -> "MathML",  Permissions -> "Public"]

Works in Firefox but not in chrome. Chrome does not support MathML so I need another solution. MathJax is a plugin you can use in chrome to render a formula.

here is the reference to be used for the mathjax javascript:

mathjaxscript = "<script type=\"text/javascript\"  src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=\
TeX-AMS-MML_HTMLorMML\">  </script>";

lets create a page and plug it in:

fullpage = 
  ExportString[z, "HTMLFragment", "URIHandler" -> "DataURI",    "MathOutput" -> "MathML", "FullDocument" -> True];
st = ExportString["mypage", "HTMLFragment", "FullDocument" -> True]
finalpage =   StringInsert[fullpage, mathjaxscript, StringPosition[st, "</head>"][[1, 1]]];
CloudExport[finalpage, "HTML", "MathOutput" -> "MathML", Permissions -> "Public"]

Okay the result in chrome is not good, just a little better but managing incompatibilities is unreliable and no fun. So the questions is if there is a reliable way to show a formula.

This generates a scalable picture text-description (SVG) and works in every browser in a size requested:

zz = "<center>" <>  ExportString[ z , "SVG", ImageSize -> {1200, 300}] <> "</center>"
CloudExport[zz, "HTML", Permissions -> "Public"]

is this the way to go to publish formulas on public webpages? Is MathML not relevant anymore because of Chrome? Any views on the matter?

2 Replies

Both MathJax and KaTeX are javascripts. MathJax is math renderer on Wolfram Community and I see it working in Chrome now, for example:

$f(x) = \int_{-\infty}^\infty \hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi$

But if you have some back bone, like WL, which can render math, why indeed not to present it as an image? The only thing we loos is copy-able content, not sure if that is important for you.

CloudDeploy[TraditionalForm[
  Style[ToExpression["f(x) = \\int_{-\\infty}^\\infty \\hat f(\\xi)\\,e^{2 \\pi i \\xi x}\\,d\\xi", 
    TeXForm], 50]], "SVG"]
POSTED BY: Vitaliy Kaurov

The only other option I know of is http://khan.github.io/KaTeX/, but I've also heard it is not mature enough yet.

I've used Mathjax before, but I've used TeX with it instead of MathML. Mathjax is about as good as it gets. My workflow involved converting to TeX and using that.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract