Introduction

I was a proud owner of the 15″ MacBook Pro Retina from 2013. After years of service, it became a bit unsatisfying in terms of performance. In 2017 I finally decided to build a desktop PC, partly to fullfil some of my craftsman’s desire, and partly to play some graphics intensive games. I was still hanging around with my MacBook, mainly as a portable device for media consumption and academic work. I felt that it was a bit heavy for only that kind of usage. Or maybe I just wanted to get rid of it and play with some new toys. So I sold it and used the money to get an iPad Pro 10.5 (WiFi model with 256GB storage). Since then, I’ve (mostly) been a happy owner of the iPad.

I have been using an iPad Pro as my main computing device for over two years now. I’ve put more love in it than the PC that costs three times more. While the PC is a fantastic powerhorse, it has mostly been used as a dedicated gaming machine. The PC also serves as the last resort for things that the iPad is just incapable of doing. Albeit this resort has been shrinking constantly as I get more competent in utilising the power of the iPad.

There are quite a lot online resources covering the usage of iPad as a primary device. However, the workflows are mostly all from professional bloggers, podcasters, programmers and artists. There is little to be found from academics, which is kind of to be expected from the most introvert group of people in the world. So, I needed to figure out an academic workflow on iPad by myself.

In particular, writing and typesetting LaTeX are essential for academics in mathematics related areas. Yet it’s not a trivial matter to get it going smoothly on iPad. The reasons are mostly the lack of software documentations and the lack of research in this area. After fiddling with all the relevant apps that I could find, even including those remotely relevant ones, I think I finally established an optimal workflow. The apps involved are TeX Writer, Textastic, and Working Copy. I will describe both the setup and the workflow in the following sections.

Setup

Offline PDFLaTeX Compiler – TeX Writer

To get a barebone workable experience for writing and typesetting in LaTeX, a LaTeX distribution, e.g., TeX Live is of course needed. However, it is not obvious how we can bring TeX Live onto iPadOS. It turns out that it’s not possible to install a full TeX Live. But all is not lost. We can at least get full PDFLaTeX working on iPadOS, with the help of TeX Writer. Although there is one competitor on iPadOS with offline typesetting capabilities, namely Texpad, TeX Writer excels in almost every way. It has a solid file manager, with Files app integration. It supports multitasking technology on iPad perfectly. It has tons of customisation and scripting capabilities. It can show tex and PDF simultaneously, with horizontal split in landscape and vertical split in portrait orientation. Moreover, it has a transparent package management solution, i.e., the same old way as managing any files by showing the entire directory. The only thing that probably holds some people back from TeX Writer is that it’s more like an app written for developers. For example, the editor draws inspirations from Emacs and customisation requires editing a plain text configuration file.

After installing TeX Writer, it has already shipped a minimal TeX Live distribution with it. When typesetting a document that requires additional packages, it downloads the required packages dynamically from CTAN to its caches. However, the best thing is that it allows users to pre-load any packages, fonts, and etc.. We just need to create a new folder texmf-local and copy the packages we want into it. Theoretically, we can put the entirety of TeX Live into it. But this is not a good idea. Since only PDFLaTeX related files can be used by TeX Writer, this would not only waste a lot of storage on iPad, and also cause errors in TeX Writer due to conflicts with files for other typeset engines. Moreover, due to the less than robust file system on iPadOS, that amount of files often crash the Files app. So the best way to get full PDFLaTeX working offline on iPad is to load only the part of TeX Live useful for TeX Writer, as described below.

Download the TeX Live installer on supported operating system from TeX User Group;

Run the installer;

Open “Advanced” dialog to select the “collections” of packages needed;

Install and wait for it to finish;

Open the package manager and install any additional packages;

Open the installation directory and navigate into the foler texmf-dist ;

; Create texmf-local direcotry in the root in Tex Writer;

direcotry in the root in Tex Writer; (Optional) Create a hidden folder .texlive under texmf-local so the tex files aren’t shown and indexed in the Files app (make sure “Show hidden files” option is enabled in “Settings” of Tex Writer);

under so the tex files aren’t shown and indexed in the Files app (make sure “Show hidden files” option is enabled in “Settings” of Tex Writer); Copy the folders tex , fonts , bibtex into the texmf-local (or texmf-local/.texlive ) folder in TeX Writer via iTunes;

, , into the (or ) folder in TeX Writer via iTunes; Open “Settings” of TeX Writer, tap on “Refresh texmf-local/ls-R”.

The next typeset on TeX Writer might take a long time to update ls-R . It’s better to set the iOS “Auto Lock” to “Never” and let TeX Writer finish its job in the foreground.

In this whole process, there are a few caveats I need to mention. It’s advisable not to install too many additional fonts from TeX Live Collections. Again, the file system on iOS is still a bit too fragile. Furthermore, there might still be useless files copied in those three folders. But it’s a serious chore to dig through the TeX directory to pick each one of them. I think this is a good compromise to make.

For customisation and scripting in TeX Writer, the developer’s website has a reference manual. The first half of it is about the LISP language and not specific to TeX Writer. The best way to start is to scroll to the bottom and look at the sample twinit.l file, which need to be copied into TeX Writer. There’re some important features not documented on the website. Pasting this block of code into the twinit.l file in TeX Writer adds “RELOAD” button in tex mode and “COMPILE” button in PDF mode. These are important when editing files from other apps while typesetting in TeX Writer. I have uploaded a copy of my own customisation file to GitHub.

(add-hook tex-mode-hook (lambda () (add-to-toolbar "RELOAD" 'reload) )) (add-hook pdf-mode-hook (lambda () (add-to-toolbar "COMPILE" 'tex-compile) ))

Text Editor – Textastic

Although the text editor in TeX Writer is actually very decent, with some beautifully implemented features like spell-checking, Textastic is my text editor of choice here. One important reason is that it allows users to customise code completion. The developer has some examples of the built-in code completion configuration files on Github. But unfortuanately the syntax is not documented at all. It took me a solid couple of hours to figure that out. I have written up a code completion file for LaTeX (available on Github) based on the LaTeX2e unofficial reference manual.

Git Client and File Provider – Working Copy

You might have noticed the trend that GitHub is used a lot. Then you shouldn’t be surprised that my entire LaTeX setup is based on Git for file management. Working Copy has integrated with the iOS File Provider to make the files in its repositories available to other apps. Both TeX Writer and Textastic take full advantage of that. Basically all source files for LaTeX documents, e.g., tex and bib files, are stored in Working Copy and version controlled by Git, while Textastic and TeX Wrtier open them “in place” to edit and compile.

Workflow

A typical workflow for writing and typesetting a LaTeX document in this setup is the following.

Initiate a repository in Working Copy with a .gitignore file to untrack intermediate files generated by LaTeX;

(Optional) Push the repository to some Git hosting service, say GitHub;

Open the repository in Textastic;

Create a new tex file and type the document;

file and type the document; Open the repository in TeX Writer, and compile the tex file to see the PDF;

file to see the PDF; Continue to edit in Textastic, and compile in TeX Writer until done;

Commit meaningful changes in Working Copy during the process;

Check and correct spelling for the final draft in TeX Writer;

Compile the final document in TeX Writer.

Commit and push the final changes in Working Copy.

Due to the large amount of app switching between TeX Writer and Textastic in this workflow, it’s best to open them side by side in Split View or put TeX Writer in Slide Over.

Conclusion

Although the setup is a significant effort (at least for me), the results are worthwhile in my opinion. Now I can write and typeset documents with LaTeX almost anywhere. Bringing an iPad with me has been much easier than bringing an MacBook becuase of the (lack of) weight. The limitations are also quite limited. Unless I need other typesetting engines, e.g., XeLaTeX for fontspec , LuaTeX for tikz-feynman , and e.t.c., the iPad Pro can serve me perfectly well.

Updated on 9 Jul 2020