Extension
Last updated
Last updated
Have you ever wanted to type some mathematics in a document?
During a meet-up on the 5th of September, 2018 we discussed how to typeset mathematics, using LaTeX and JavaScript. Keep reading to learn how, and to view some beautiful examples (including animated rainbows!)...
LaTeX is a programming language for high-quality, beautiful typesetting. TeX was originally released by Donald Knuth in 1978. As a mathematician himself, Knuth was motivated to create something which allowed one to type complicated mathematical formulas in a professional-looking manner. As a result of his efforts, the ability to typeset mathematics in LaTeX is a major strength.
Anyone who has studied mathematics or statistics will know that the notation is plentiful. LaTeX allows for the many symbols you may desire to use, whilst presenting them in a clear and beautiful way. So many symbols are available that there is a 338 page Comprehensive LaTeX Symbol List. But when it comes to finding the symbols you need, I recommend using Detexify by Kirelabs. This tool allows you to simply draw the symbol you're looking for, then it will identify it and tell you which command and package to use!
During the meet-up we created a LaTeX document which was abundant in examples of mathematics notation and formulas. You can view the document on Overleaf.
Once LaTeX had been introduced, Errol then gave an excellent presentation on the inclusion of mathematics on the web. Read on to learn more and see his animated rainbow equation!
One of the great things LaTeX has given to the world is its mathematics or equation typesetting syntax. Not just because LaTeX is great and powerful, but, because this typesetting syntax is now a standard across many different kind of software.
This is especially the case when it comes to web pages. Go to the wikipedia page on the normal distribution, and see all of the mathematics typesetting. Copy one of the equations and paste it into a text file ... what do you see? (Spoiler alert ... LaTeX).
All of this works because when it comes to the programming language called javascript, which powers all of the interactivity and animation of the web, there's a principle which has shown to be true again and again: 'anything that can be made in javascript will be made in javascript'. The web is everywhere and everyone uses it all of the time. Which means javascript has to do its best to be everything to everyone. And so, LaTeX mathematics can be done with javascript.
If ever you find yourself wanting to write a blog, create a simple web page (which is easier than you might think), or share your Jupyter or RMarkdown notebook or create an attractive interactive data visualisation or publication for your research, know that javascript has got your back when you need to show some mathematics.
Beyond blog writing, you may be wondering why you should be interested in javascript and making web pages. There are two responses to this. First, with the Observable Notebook, it is now easy to learn and get started. Check out the tutorials at the home page and just start playing. Second, unlike any programming language you've learnt, javascript is built to normal programming things like crunching numbers, as well as graphics. This means you can make interactive publications, like this notebook on predator and prey population dynamics.
Or, you can just make rainbow equations:
If you're interested to learn more, take a look at this notebook of mine, which demonstrates LaTeX, interactivity, using Observable, and making interactive graphics with javascript.
This blogpost was created by Meirian Lovelace-Tozer (@MeirianLT), and Errol Lloyd (@maegul) whilst they were working as Senior Research Community Co-ordinators and trainers on the Training and Engagement team at Research Platforms Services (defunct).