chemiscope icon indicating copy to clipboard operation
chemiscope copied to clipboard

Add support for LaTeX rendering of text

Open Luthaf opened this issue 4 years ago • 0 comments

As discussed in https://github.com/cosmo-epfl/chemiscope/pull/88#issuecomment-717273589 and following comments, it would be very nice to support LaTeX syntax in user-facing data. The core use case for this is rendering units. Another appealing case is to render dataset description with some math inside. The alternative is to use unicode math characters (in particular unicode superscripts) where needed.

One solution to do this that would integrate relatively well with plotly is to use https://www.mathjax.org/ for latex rendering. Another alternative is https://katex.org/, which is usually faster and smaller than mathjax, although I don't know if it works with plotly.

If we want to do this, one thing to consider is that we would have to bundle mathjax/katex, which would increase the size of the bundled javascript; and might interfere with downstream users who might already have a latex rendered installed (e.g. materials cloud). This is my only objection to this feature: it might not be worth the slower loading time for marginally more convenient unit & description math input.

Also, we currently render the dataset description & references using markdown syntax, so we have to make sure not to break it when rendering latex. This should be fine, we mostly have to check that it is not broken when implementing this.


Places where we may want to have latex rendering:

  • dataset name
  • dataset description
  • dataset references (maybe not really useful)
  • property name
  • property description
  • property unit

Things to look at before starting the implementation:

  • [ ] Whats is the size difference between Mathjax and KaTeX?
  • [ ] Can we use KaTeX with Plotly?
  • [ ] How do markdown-it play with mathjax/katex?

Luthaf avatar Oct 27 '20 16:10 Luthaf