Mathkey: A great resource for LaTeX on iOS

I’ve been using LaTeX (enjoyably!) on iOS for quite some time now. It is *still* remarkable to me that I can continue chipping away at a manuscript that I was working on in the office outside at the park — on a piece of glass. For those not in the know, LaTeX is a typesetting language that has many uses, and can be particularly useful for writing manuscripts.

After graduating from a 8.2” iPad Mini 2.0 to a 9.7” 6th generation “educational” iPad, I’ve been getting more and more writing done on iPad. The larger screen is more conducive for split-screen usage and the Apple Pencil compatibility is awesome (gives my post on note-taking tools a whole new depth - I should revisit that). Texpad is still my LaTeX editor of choice (I wish this could somehow be integrated with Overleaf) and its latest version, with several updated tools, makes editing in LaTeX rather simple. Although Texpad’s symbol editor tool is handy, I recently came across an app that makes complex typesetting, and equations, in particular, easy and intuitive.

Cue: Mathkey. The iPad app costs $7.99 (rather reasonably priced IMO; although it is also available via Setapp) and is available on the iPad as well as the iPhone (and Macbook). Essentially, it is a LaTeX keyboard (add it under General->Keyboard) that receives input via touch, and can produce output as text or as an image. What exactly does Mathkey do? Instead of struggling with symbol/equation typesetting, Mathkey uses the MyScript engine to parse handwritten equations into an image or as snippets of LaTeX code (as plaintext) that you can insert into your editor of choice. This becomes especially powerful when you have an external keyboard for typing opened with Mathkey as your active keyboard. I’ve been using Mathkey for about 3 months now and its accuracy is rarely off. On the iPad, using Mathkey with the Apple Pencil has been delightful. Finally, Mathkey can also remotely connect to the Macbook so that you can write equations on the iPad/iPhone while editing LaTeX on the Mac.

All in all, this app is a worthy addition to my (iOS-)LaTeX workflow. Here is a screencast of Mathkey usage:

LaTex on iOS? Texpad is one way to go!

LaTeX

If you’re not familiar with LaTeX or haven’t used it yet: don’t panic; chances are, you might be more productive and efficient without it! According to empirical research by Knauf & Nejasmic in 2014, LaTeX users were especially susceptible to grammatical and orthographical errors. Although (importantly, I feel), the study also found that LaTeX users reported enjoying their respective software editors a lot more than their counterpart WYSIWYG (or What you see is what you get editors) users. 

Essentially, LaTeX is a plain text writing interface which formats a document you are preparing in as simple or as complex a structure as you’d want, using relatively simple syntax. It's easy to get started with LaTeX (this is a great resource) and there are plenty of editors available that can show you real-time previews of your document. Regardless of average productivity, there are some reasons why I prefer writing academic text in LaTeX and why it works for me:

  • It provides a distraction-free environment for academic writing: when I open up my LaTeX editor, I know it’s go-time!

  • The structure of formatting equations, symbols (such as δ¹⁸O for example), tables, and figures is intuitive and simple. This can be particularly boosted with the use of text expanding software (such as aText) or Apple Scripts.

  • Academic journals usually share LaTeX templates formatted according to their specifications. This makes reformatting into another journal’s format a breeze.

  • BibTeX makes the insertion of citations and formatting of references effortless. My article management system, Papers3, has an easy-to-use BibTeX record export for any papers I might need to cite for a particular manuscript or proposal.

  • It’s free and open source!

Texpad

Although LaTeX itself is a free and open source software, there are several pay-to-use editors with varying degrees of utility depending on the purpose and user. I’ve tried out quite a few editors to varying degrees of (personal) success. Currently, the one that works best for me is Texpad. First off, Texpad is only compatible with Apple and is not particularly inexpensive: the Mac version is $25 and the iOS version is $15. This has proved worth it for me though, especially since I have configured the iOS version to sync via iCloud. This means I can simply sit on my couch with the iPad and continue writing a manuscript where I left off on the MacBook book in the office! With the advent of iOS 11, it has never been easier to move complex tasks usually suited for the laptop over to the iPad, and Texpad brings this same functionality to LaTeX. The nerd in me delights at the prospect of taking a piece of glass wherever I want and still type an academic manuscript.

Advantages of Texpad:

  • The editor is light yet powerful.

  • The editor is enabled with a spellchecker! 

  • The editor can autocomplete citations and other commands.

  • It “knows” your code with effective highlighting and parsing, as well as recognizing bookmarks and structures in your document.

  • The design and UI is clean, minimal, highly customizable (themes and fonts!), and helps me focus.

  • It is also compatible with Markdown.

  • There is an iOS version with a local, offline typesetter that actually works!

Setting up Texpad on iOS with iCloud

Texpad on the iOS has a file browser that is compatible with the new Files app and also has access to Dropbox and WebDAV. Texpad has its own cloud platform called Connect for syncing projects, but I found this to be really buggy and incapable of handling journal-based projects (even the AGU template for example) on the iPad (lots of crashing and heartbreak!) Next, I tried the Dropbox sync (I am a Dropbox user) but even this proved to be somewhat buggy. Finally, I went back to the Files app and tried to sync my projects with iCloud: this was a resounding success, regardless of project size or complexity! Here’s how I set it up:

  1. Download the Texpad iOS app.
  2. On your MacBook, create an iCloud-synced folder entitled ‘Texpad’ (or some variant) and make sure you save your LaTeX project here on the Mac-version of Texpad, including the .bib, .sty, and .bst files for your journal formatted manuscript.
  3. In the iOS app, under File Browser, click on Open From Document Picker under ‘Local’. (Note Open versus Import will depend on what type of versioning history you’d like to set for your project).
  4. This will open the Files app, and once you navigate over to your iCloud Drive, you will see your saved projects under the Texpad folder you created.
  5. Open the .tex file.
  6. Before hitting ‘Typeset’ (I know it’s tempting!), go back to the File Browser, and open all the other files (BibTeX etc.) related to your project. This will ensure that these files are accessible for typesetting on your iOS device.
  7. Last step before typesetting: make sure that you download all the bundles that your LaTeX typesetter needs including all those fancy fonts
  8. Typeset and enjoy!