LaTeX on the iPad: TexTouch + DropBox + ScribTex

This post summarizes my approach to editing LaTeX files on the iPad. My method relies on Bash scripts that automatically compile LaTeX files on a Mac desktop. The files are sync’ed with the iPad via DropBox, and edited using the convenient TexTouch app. Readers who are comfortable with Bash scripting may find this information useful.

As a Professor, I spend a lot of time preparing documents in LaTeX, and I am frequently traveling to conferences and other professional events. I own both an iPad and a MacBook Air, which raises the natural question: Which one should I bring while traveling (or should I bring both)? More often than not, I bring both. But it seems increasingly feasible to leave the MacBook at home and rely solely on the iPad, at least for certain trips.

In order for this to work, I need to be able to read and annotate PDF files, and I need to edit and compile LaTeX documents. I also use ScribTeX for collaborative authoring, so it would be helpful to have ScribTeX access on the iPad. The developers at ScribTeX have no immediate plans to create an iPad app, but it isn’t too hard to piece together a fix that allows all these features — and ScribTeX integration — on the iPad. This post provides a summary of my solution.

The ScribTex web interface is almost a workable solution, but there are a few fatal drawbacks. First, two-finger scrolling is used to scroll the TeX source within the browser. But a two-finger swipe executes the “close tab” command. It is very difficult to scroll without occasionally swiping and discarding all your edits. Second, the ScribTex interface is strictly online, making it potentially unreliable as well as difficult/expensive to use on a plane.

One solution for offline editing on the iPad is the TexTouch app, which is a pretty handy tool that provides various syntax shortcuts, and has some other useful features. Notably, TexTouch allows you to edit files from a DropBox account. Vancapy, the maker of TexTouch, also provides a desktop application called “TexTimer” which watches your DropBox folder and runs latex whenever a source file is modified. This lets you use your desktop as a server for compiling LaTeX files. The TexTimer has some limitations and bugs. Another solution is available, LaTeXMe, which might be adaptable to my needs. I haven’t tried it, but it appears to be a bit overworked and relies on some software that I prefer not to use.

These concerns motivated me to write my own simple “TeXwatch” Bash script, described below. My script is very low-level and completely flexible. The TeXwatch script can be dropped into any DropBox subdirectory and executed on a per-project basis. The directory can contain, for instance, a ScribTex project checked out via git. The script can be executed repeatedly, once for each project. Since I’m quite comfortable with Bash scripting, this seems much simpler to me than using someone else’s canned flow. The complete solution works quite well: edits are made on the iPad via TexTouch, then automatically compiled by your desktop when you save the file. You can then view the PDF on the iPad using the DropBox app, or in another PDF viewer (I prefer iAnnotate).

My only hesitation with this solution is that TexTouch is a closed-source app with an uncertain future. It is impossible to say whether it will be maintained, and there do not appear to be good alternatives for TeX editing on the iPad. In a perfect world I would like to use Emacs, but there are reasons to expect that it won’t appear in the App Store any time soon.

Equipment:

  • iPad
  • Desktop computer, preferably running OS X or Linux with SSH access.

iPad Apps:

  • DropBox — For synchronization between iPad and desktop.
  • TeXTouch — For LaTeX editing.
  • iAnnotatePDF — For viewing and marking up documents.
  • iSSH — For maintenance access to the desktop.

Desktop Applications:

  • TexLive — Possibly the best TeX distribution, in my opinion.
  • DropBox — For file synchronization.
  • kqwait — A file change watcher for OS X.
  • inotify-tools — A file change watcher for Linux.
  • git — For local editing of ScribTeX projects.

Outline of the Procedure:

  1. Install all the apps. The only funny one is kqwait, but it is extremely simple and shouldn’t cause a headache.
  2. On the desktop, within the DropBox folder, create a subdirectory for ScribTex projects. Call it something like “scribtex”.
  3. Populate the “scribtex” directory by checking out projects with git.
  4. Copy the TeXwatch script into each project repository, and edit the script to enter the main tex filename.
  5. Execute the TeXwatch script for all active projects. I have a couple of additional scripts that automate this. You can also write timed tasks that automate push/pull operations in the git repositories.
  6. On the iPad, access the DropBox projects from within TexTouch. Edit files as needed. They are automatically compiled when saved.

The TeXwatch script itself is quite simple:

#!/bin/bash

TEXNAME=paper

DIR=”$( cd “$( dirname “${BASH_SOURCE[0]}” )” && pwd )”

cd $DIR
while kqwait $DIR/$TEXNAME.tex; do
/usr/texbin/pdflatex -interaction=batchmode $TEXNAME.tex
/usr/texbin/bibtex $TEXNAME
/usr/texbin/pdflatex -interaction=batchmode $TEXNAME.tex
done

It is only necessary to change the TEXNAME=paper line to specify the main filename. This script can also be ported to Linux by replacing kqwait with inotify, which should provide roughly the same functionality.

Advertisements

One thought on “LaTeX on the iPad: TexTouch + DropBox + ScribTex

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s