Inside TeX Writer

It is rumored that TeX Writer is running on an emulator.

If you ever tried to compile a LaTeX document with TeX Writer, you know that. No way that TeX Writer could run that fast on an emulator. A full listing of the app bundle could help to clear your doubts too.

Now, I have a confession to make.

I do work on an emulator called Aemula, which is a 486 pc emulator. I wrote this app for running old DOS programs and games on iPad/iPhone. Since we have a lot of DOS games that are very performance demanding, I did a lot of optimization for this emulator. A large part of cpu core is written in ARM assembler.  However, emulator isn’t welcome by apple. So I can not put it on App Store. Instead I released it as a free app for jailbroken iDevices.

One day, the idea suddenly came, is this emulator fast enough to run TeX? At that time I didn’t believe that we can run a native TeX compiler on iOS. It’s too messy a code base to port as someone once said.

Why not give it a try on the emulator? I told myself. So I began with compiling the original TeX with GPC, based on texgpc. There are a lot of tricky problems. For example, when TeX prompts for input in the emulator, it would be very awful because you can’t programmatically tell whether it is busy working or not.  And there are parts in the original implementation involving memory that are not that fast inside emulator. After these problems were sorted out, I ended up having a TeX running decently inside Aemula. Oh, that was an exciting moment.

Down side is that it was not that fast, and had a very poor memory capacity. For example, you can typeset a simple LaTeX document with it, like the three-page sample2e, but that would take more than 10 seconds!

Then I started looking into the web2c implementation in TeXLive. The whole code base is amazingly huge. This is not unexpected, TeX Live CD is more than 3GB.  I began digging into the source tree, figuring out which part does what. It’s a lengthy process. One day I got bored, and thought, why not release a TeX app based on the Aemula and see if anyone was interested or not. That was the TeX Notebook 1.0, and it was a relatively quicker job.

After I submitted the app for review,  I returned to the web2c port work, and had a break through. Everything began to fall into places. By the time TeX Notebook was approved (it took Apple about three weeks), I already had a working native version. Then I realized that I need to update the app with the latest build as soon as possible. But it’s too late, somebody (actually a developer working on a TeX app and knowing how impossible it is) became so interested into this app, already unpacked the app bundle, discovered the secret, and wrote a post that even got into the front page of hacker news (Funny thing is, when the native and faster version came out, no HNer seems to be interested).

A few days later, TeX Notebook was replaced by TeX Writer — the native version that most of you are running now.

That is pretty much the whole story as you know it now.

This entry was posted in General. Bookmark the permalink.

9 Responses to Inside TeX Writer

1. stephan says:

Thank you very much for this App. Unfortunately I’m missing two things to turn the iPad into the working horse I’d wish it to be:
- changing the page size with the graphicx package leads only to a change of the text area but page size stays A4, at least it seems so.
- for my scientific work I’d need the pgf/tikz-package (http://sourceforge.net/projects/pgf/). The advertised adding of packages seems not to work for this packages I flatted needed parts of the package until it ran through without errors but the results are rubbish.

would be really happy, if you could make this work. Thank you very much.

• litchie says:

Hi, Stephan

First one, if it is possible, could you provide a minimal tex file for me to reproduce this problem here? I’d love to fix it.

Second one is tough one. It doesn’t really work right now.

• stephan says:

Hi litchie,
this is a minimal example:

\documentclass{article}
\usepackage[a5paper]{geometry}
\geometry{top=2cm, bottom=4cm, left=2cm, right=4cm}
\title{Untitled}
\author{Me}
\date{2013-1-18}
\begin{document}
\maketitle
This is a line of text in a DIN A5 dokument which still has
a paper size of DIN A4 while the text area is sized down to A5.
\end{document}

https://www.hidrive.strato.com/lnk/HArhkyms?lang=en

Good luck, all the best, stephan

• stephan says:

PS of course it’s about the geometry package
not about the graphicx package, sorry for the confusion…

• Cliff says:

Need pgf/tikz package work here too.

Thanks.

2. Min-Gyu park says:

I have just bought Tex Writer and I cannot compile my tex file because of
missing files. Algorithmcx, algorithm, cite, biblatex.sty files. Can i include these files?

• litchie says:

Yes, see the readme inside app.

3. Roberto Franzosi says:

I have bought Tex Writer for ipad but it doesn’t work at all!