Tutorials

Writing Equations

| By Alexander der Große

Ulysses isn’t just used by those who write fiction – it is also suited for mathematicians and other scientists that have to include equations in their writing. In this tutorial, we’d like to show you two of the most commonly used workflows: Pandoc to use LaTeX equations in Ulysses and render them as DOCX and PDF, and MathJax, a powerful web-based script which can render your equations in HTML.

LaTeX and Pandoc (for DOCX and PDF)

A well-known way of writing mathematical equations is with LaTeX. This document preparation system uses markup tags, much in the same way as Ulysses does. It has been around since the mid-80’s and hasn’t lost popularity since. Ulysses lets you write in LaTeX just fine, as long as you wrap it in Raw Source tags. These tags will make sure Ulysses doesn’t change your LaTeX code when exporting it. In the screenshot below, the LaTeX equations are enclosed in $ characters, and the indexes in subscript are rendered by placing a _ before them.

After writing these equations, you can export your sheets as Markdown files. Just press ⌘6 to bring up Quick Export and select the “Text” exporter from the top-left menu. Next, select the “Markdown” format and save your sheet.

Now, you will want to render your formulas. This is where Pandoc comes in. Pandoc is the Swiss-Army knife of file conversion. It can read your Markdown files and convert them to a host of other file types. In order for Pandoc to convert your equations to PDF, please make sure to install MacTeX as well, a LaTeX distribution for Mac. After this is done, enter this command in the Terminal to convert your LaTeX Markdown file into a PDF:

pandoc Math.md --output Math.pdf

In this example, the file was named Math.md, however, you can choose any name you’d like. When executing this command, Pandoc will create a PDF file for you, automatically rendering the equations:


MathJax (for HTML)

In recent years, MathJax has gained much attention. Since it’s written in JavaScript, it can be rendered by any browser, which makes it perfect for showing your equations within Ulysses' export preview itself. You can write your MathJax formulas in Ulysses just fine: wrap them in Raw Source tags. You will need to place the following snippet in Raw Source Block tags before your actual formula though:

<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath:[['$','$']]}});</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=default' async></script>

Then write your text and include your formulas in Raw Source tags:


As with LaTeX above, you can use Pandoc to convert your HTML files into almost any other file type.

This article was last updated August 14, 2018.

Writing Equations

Use equations in Ulyssses with Pandoc and MathJax