I’ve been looking for the perfect way to compile LaTeX documents on my iPad for a while now. There are some IDEs available in the App Store, but either their functionalities are somewhat limited, or their costs are not justifiable with occasional usage. Overleaf is probably the go-to tool if you have an Internet connection. Another interesting cloud-based alternative is to harness the power of Git and CI, which is worth another but-why?
post on its own.
A truly offline solution that offers the full capabilities of a TexLive distribution is, of course, installation of TexLive 😜. Ways to do this range from shell emulators (e.g. a-Shell) to full-blown virtual machines, with varying degrees of success. I personally use the virtual machine approach, with the amazing UTM. You probably have seen videos of it running Windows.
UTM needs to be sideloaded onto your device, and the recommended way is to use Alt Store.
- Install AltStore
- Download the latest IPA release of UTM on your device
- Open the IPA with AltStore
You can download prebuilt VMs from UTM’s website. I found that Debian 10.4 (osy’s Developer Edition) ARM
works very well, especially as it comes pre-installed with SPICE WebDAV, which enables directory sharing.
It uses i3 Window Manager, a quick 101 on the commands:
$mod+Enter
to launch the terminal$mod+d
to open other applications$mod+Shift+q
to kill a window
$mod
in this case is the command key (⌘
).
Download and unpack the installation script from TUG as follows:
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \
tar -xzf install-tl-unx.tar.gz
Simply execute the installation script and follow the instructions, I recommend selecting the basic
scheme, and not installing documentation and source. This will give you a minimal LaTeX installation of only 142MB, further packages can be installed on-the-fly using texliveonfly
. To install it use:
sudo env PATH="$PATH" tlmgr install texliveonfly
Compiled PDF has no use sitting within the VM, the next step is to set up file sharing.
The prebuilt VM mentioned earlier supports directory sharing, which needs to be enabled in UTM VM configuration by creating a shared directory. This directory will then be available in Apple’s Files app, and mounted onto the VM under /media/share
.
“I don’t want to use that prebuilt VM and I cba to set up SPICE client tools!” You can actually SSH into your virtual machine and use SFTP. This requires Location Service for UTM to be set to always enable, keeping the VM active in the background. Then set up VM port forwarding under Configuration > Networking
, make sure to use a non-standard port (greater than 1024, otherwise the connection will be denied), and forward it to port 22 of the guest network.
There are several SFTP clients available on the iPad, but I think the best one yet is Secure ShellFish, which is from the creator of Terminus. It gives you direct access to remote files within the Files app.
That’s it. “But why?”, you may ask…🤔