4

I can use mathjax for equations and symbols generally, but what about diagrams? Mathjax doesn't support TiKZ, so I'm looking for a JavaScript library which can be used in place of TiKZ. So far JSXGraph and two.js seem promising - I'm wondering if anybody can recommend or comment?

  • Did you check D3? – vaettchen Nov 13 '18 at 2:43
  • Thanks! I've probably briefly checked most of the different libraries - including D3 - but there are so many of them. Probably any one would suit me; I'm just wondering if anybody here has had experience of mathematical diagramming with any of them.. – Alasdair Nov 13 '18 at 4:14
  • I wonder if this is more or less off topic, and that it would be better to ask this on a site more focussed on JavaScript. I mean, the question is basically "what is a good JS library for making mathematical diagrams", which isn't really TeX-related at all. – Torbjørn T. Dec 1 '18 at 12:26
3

https://github.com/kisonecat/tikzjax is a JavaScript library which renders TikZ images. When <head> includes

<link rel="stylesheet" type="text/css" href="http://tikzjax.com/v1/fonts.css">
<script src="http://tikzjax.com/v1/tikzjax.js"></script>

then code in the body like

<script type="text/tikz">
  \begin{tikzpicture}
    \draw (0,0) circle (1in);
  \end{tikzpicture}
</script>

is converted to the expected SVG. This works by running TeX itself in the browser (specifically, web2js is a Pascal compiler written to compile TeX to WebAssembly).

  • Wow this is awesome! (TeX running in the browser, at reasonable speed.) Just read your article in TUGboat and searching for it led to this answer. Thanks for the great work… can imagine many exciting possibilities. How long did all this take to design and implement? – ShreevatsaR Jun 8 at 18:42
  • 1
    Honestly, not that long -- the first commit to the Pascal compiler was Oct 24, 2018, but mostly I worked on this at and after the Joint Math Meetings in 2019. So a few months. There are of course still bugs to work out, but this (and an LRS-based gradebook...) will form a new backend for Ximera, so it'll be supported. – Jim Fowler Jun 20 at 16:16
  • the problem with this is that those resources are linked from an http address, which wouldn't work for https pages. – Jason Hu Sep 9 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.