Don’t write TeX in Ulysses (or at least be careful about it)

Okay, this sucks a little. I write math in LaTeX in my Markdown documents. Pandoc can easily translate that when generating PDF files, that goes through LaTeX anyway so is just used verbatim, or when generating ePub files, where it is translated to mathjax.

Right now I am using Ulysses to write but still use Pandoc to compile my documents — I need to use both knitr and pandoc to evaluate my embedded R code and I have more control over the generated PDF output — so I just write in Ulysses and export the Markdown before compiling. I wish that was easier, but it isn’t. I can live with that, though.

The problem is that Ulysses removes backslashes when it exports, for some reason. Ok, I thought, then I will just escape them and write two backslashes when I want a single one. That is how it is usually done, after all.

Not so with Ulysses. An escaped backslash is exported as two backslashes. A single is simply removed.

It is not a major biggie because I run my Markdown files through gpp to do conditional compilation (I need slightly different options to knitr when generating PDF files from when I generate ebooks) and it already eats up one of the backslashes — something I fix with sed. Now I can just remove the sed step and always write two backslashes, I guess.

It just means that I won’t be importing my Data Science book into Ulysses ‘cause I don’t want to go through the hassel of rewriting all the equations there just to get it to work. For my future writing I just have to keep in mind that I must escape all backslashes and always run the documents through gpp.

The workflow is not made easier by this, but it is a small change to my Makefile. Annoying, though.

Author: Thomas Mailund

My name is Thomas Mailund and I am a research associate professor at the Bioinformatics Research Center, Uni Aarhus. Before this I did a postdoc at the Dept of Statistics, Uni Oxford, and got my PhD from the Dept of Computer Science, Uni Aarhus.

7 thoughts on “Don’t write TeX in Ulysses (or at least be careful about it)”

  1. Hey Thomas, thanks for the cool post ! I was in your exact same situation and actually found a way to make Ulysses play a lot nicer with Pandoc to generate good looking PDF and ePub in one click through a Bash script running inside Automator. Also had to dig into Ulysses XML files (inside the app content) to make Ulysses stop creating links with double brackets and escaping some characters like the backslash – now my Ulysses does export a double backslash to Markdown as one single backslash, which enables me to write LaTeX equations and also use “\pagebreak” or “\newline” :) I’ve contacted The Soulmen about my script, need to work more on it, definitely have in mind to share it at some point – meanwhile lemme know if you need more info and if you want to work with me on it ;-) Cheers

  2. I haven’t actually checked that. I use tildes for some markup but I don’t think I have tried putting it around TeX tags. I had a work around that also dealt with issues with my preprocessing of text and didn’t look into it further after that.

Leave a Reply