Tuesday, November 22, 2011

Reasons To Despair, Or, Installing And Using LaTeX

Shake me or something but it's 2011. I'm not sure why software is getting more complicated and more broken instead of the opposite. I suppose I "ask for it" by expecting to install a geek-level text-based document layout package like LaTeX and have it work like it should.

I recently decided (tardy by a couple of decades) to have a look at LaTeX, since I often need to produce different printer-ready output in an easy and powerful fashion. The various WYSIWYG packages designed for this purpose are either a) rubbish, or b) expensive. I'm getting tired of laying out basic files by mouse when a keyboard is more efficient. After many years of HTML I am quite used to tag-based layouts. I coded for an awful long time, so this approach doesn't scare me.

The final straw is that I've had to lay out some math formulae recently, and that is a horrible process in a graphical editor. LaTeX has been performing this task for three decades. It's open and free, so why not?

I must pause to comment on the horrific typographic convention by which one is supposed to format the name LaTeX. Not only is the capitalisation ugly but you are also supposed to shift letters around in the most awkward of ways. There are even easy CSS sheets for this, but I refuse to make an ugly word even worse. I should have taken notice that this doesn't exactly bode well for the design brains behind the application. But then again it was made by and for academics -- a group not exactly known for being a (ahem) font of design wisdom.

The first difficulty lies in comprehending exactly what all the parts are and what they do. LaTeX is a markup format, an engine to process this format, various output transformations, an optional text editor to help with the basic data entry, one to a thousand optional packages (most of which are not really optional), pre-cooked fonts, and so on. So the easiest way to get started is to find a complete distribution someone has put together. Making a decision about which one to use is not for the faint-hearted. But it is exactly the newbie these initial decisions target: paradox.

A bit of reading and hacking around with a basic install got me creating PDF files pretty quickly, which was nice. It turns out that one of the variables in the previous list is more or less a historical curiosity. Though some engines target intermediary output formats with cryptic names and purposes, any contemporary LaTeX engine will create a PDF as a final document.

Looking at the resulting PDF I saw something surprisingly familiar. Yes, this is the spindly typeface I'd seen in dozens of document files over the years, all generated by LaTeX using the default typeface, Computer Modern Roman. That's short for You've Got To Be Kidding Me I Have To Read This? It's an even worse typeface than Times New Roman, which is quite an accomplishment. And this from a product that is supposed to be the zenith of publishing?

Not only that, but it's not easy to change the typeface. Even when you do, you cannot simply use any OTF or TrueType font on your system, but are restricted to those that have been pre-processed so that LaTeX can understand them. Even then, it's easier to change the face for the whole document than in any small part. So it turns out that LaTeX is pretty poor at handling fonts. Which, last time I checked, was a rather important task in the whole document production world.

If you're interested in what's readily available, you can have a look at the FontCatalogue, which manages to collect together some of the least usable typefaces on the internet. (It's not their fault, since they are simply documenting the state of affairs.) I couldn't find a decent Humanist or anything else I looked for. Arev looks nice and bold for screen work. Utopia was my pick of the lot.

After more reading I discovered XeTeX, which corrects this massive oversight by giving access to system fonts, plus some new commands to easily map these into your document. By this time I was using the MiKTeX 2.9 distribution, but even so it took me a while to figure out that it already came with XeTeX, which is one processing engine amongst many (confused yet?). Apparently, all I had to do was change my compilation statement and let XeTeX work some magic.

Oh, did I forget to mention? Everything is run on the command line or with batch files, like in the good-old days. But that problem I solved by obtaining TeXstudio, a text editor optimised for LaTeX, which includes handy command statements you can edit and assign to quick keys. Programmers will recognise the model of the Integrated Development Environment (IDE).

Compiling my document with XeTeX all sorts of basic things broke. Tracing down the cryptic error messages indicated that I needed to uninstall (or at least stop using) certain packages that were fine with a different Tex engine but not with this one. That's funny; aren't they supposed to be compatible? Otherwise the text files need to be versioned for different engines; a nightmare waiting to happen.

That done, I tried to use Cambria but got masses of errors, some of which said I had not declared a document correctly, even though I certainly had. Reading around various old net threads I discovered that "Undefined control sequence" occurs when trying to compile with the xetex.exe command line instead of the xelatex.exe command line. Wait a minute! I am using XeTeX and the docs did not scream out to actually use the differently named XeLaTeX? That seems deliberately misleading.

That fixed, the errors remained. More net threads convinced me that certain incompatibilities between installed packages were causing mysterious "problems". But everything installed had come from the same distribution, so why should this be? Hmmm, OK. I'll uninstall MiKTeX and instead grab the only other distribution that seems to support XeTex, one by the helpful moniker TeX Live. So I download and run. Bam! I get an error about Perl failing. Perl? I'd rather make Smalltalk to an AWK. (<- Geek humour.)

A bit of reading and I discover how to run the install using a text menu (now we have really time-travelled!), which bypasses the Tk interface running on Perl. And I've been waiting a long time for this install to get done. Unnaturally long. Like, I wrote this entire article waiting!

Oh hold on, I spoke too soon, it just finished. Oh no, it didn't. "Access is denied." After 40 minutes (I am helpfully informed -- don't you love apps that rub salt into wounds?) the package "tds" (whatever that is) has crapped out. Of course I have no idea why, but I am advised to read the log. So I do. The log has slightly less information on this matter than the screen. For example, it does not advise me to read anything further. Which may be just as well.

I'll try to run it again, as it recommends. We'll see how this works out. I have small hopes. Very small.

But to any of you following along, I recommend you stick to whatever barbaric and inefficient method you currently use to lay out books (I did my last one in OpenOffice Writer).

Because it has simply got to be easier than this.



Alan in Belfast (Alan Meban) said...

I spent a very happy year writing up a Maths project in LaTeX and finding every excuse to reuse it for other purposes in the last year of university. A joy! And mostly done without a WYSIWYG editor, just plain .tex files.

Best wishes as you fall in love with (La)TeX.

robin said...

Hey, thanks Alan! It is proving to be very usable within certain design limits.

Post a Comment