# nihil architecture blogs

## content

### Why I dislike LaTeX on a fundamental level

LaTeX is pretty much the standard for publishing mathematical documents, a pretty old standard too, and one I dislike on a fundamental level, already I should have acquired copious amounts of nerd-rage by writing this, but you know it turns me one when you guys are mad at me.

My main dislike is hardly the quality of the output—though that could really use some work too, despite what the liberal media may tell you, it’s far from the quality of a professional typesetter—it’s the language used to specify the output. The language to me is so daft and devoid of any reasonable thought, it feels like gotos all over the place again.

The year is 2010, Dijkstra has won, few modern languages still support the goto, those that do often require the code to have special privileges and/or be explicitly placed in some ‘unsafe’ clause. However there are more things to healthy programming, say I’m programming some code which does some-thing with prime numbers, tries to find some pattern in it, just hypothetically, say that initially, I’m not that ambitious, and I investigate only the first 1 000 000 primes. Afterwards, I’m on a lead and I want to scoop it up a notch and go for the first 10 000 000, surely, if I programmed it scalably, I would only have to change the number 1000000 to 10000000 once in my code and the rest adapts right? If I run a gravity simulator, say I want to then try it for two times as much gravity? If I programmed this well I would have to change that number only once right? If I make some program to output a web-page, and I suddenly decide to output XHTML instead of HTML, surely if I did this well I would only have to change one switch some-where and the rest follows?

Okay, so let’s port this idea to LaTeX, a real life example, a friend of mine was once collaborating, he used em-dashes in his version, his parter thought they were too prætentious, so he changed them to commata. He had to edit every single em-dash, a simple substitute didn’t work because it turns out they used --- in more places than em-dashes. It was a frustrating task I can imagine. Now, it’s quite possible to just use \medium-pause every time and let this be output as em-dashes or as commata at one’s pleasure. But this is seldom done, and LaTeX certainly doesn’t make this very convenient nor encourages this. Another quite simple example would be that you’re writing some-thing which uses the speed of light, and in a second edition you find out that the symbol conflicts with some other symbol in the same formula, you’d wish you had used s_l there or some other thing instead of c the entire time, now you have to edit it, probably missing a few, and introducing errors. In my world, I would have used some-thing like [lightspeed] from the start and bound that concept to a symbol at only one piece in the entire code, which is then easily changed. Alternatively, you might find out your publisher’s style doesn’t really like dots and wants crosses or spaces for multiplication, you’re stuck on editing that. You could just search and replace, but of course you want to check. Isn’t it easier to just specify multiplication each time and define the symbol associated with that at some higher level?

Another part we’re always getting hot about is re-use of code, Two or more, use a for!, LaTeX isn’t particularly friendly about this thing either, often you will find multiple æquations which re-use some basic concept into it which often leads to copy-ing and pasting of text. I once learnt that as soon as you copy and paste your code, you’re doing some-thing wrong and I agree with this maxim. Consider this simple example:

 $\land$ and $\lor$ distribute over each other, more formally: \begin{eqnarray} x \land (y \lor z) &=& (x \land y) \or x (\land z) \\ x \lor (y \land z) &=& (x \lor y) \land x (\lor z) \end{eqnarray} 

Splendid, I’d rather just use:

 \mutual_distribution(\land,\lor) 

And define once how this is output, and then be done with it. I can change that template once then later if I want to make some changes. I’m to be honest surprised that LaTeX automatically enumerates your æquations for you and you don’t have to do that yourself. And yes, it is possible with some hacking around to make such a template, but the syntax for it is so limited and confuzzling that almost no one does it, and it almost makes things less readable to begin with. I tried and I tried to make this happen a little more but the language was quite clearly never designed for it that well, and it’s madness and pain.

LaTeX lacks a \Beta on its own, quite obviously because it looks visually the same as B so why bother? Well, even if you were a dusty computer scientists who has a fetish with not keeping his mind ordered, it still begs the quæstion in what typeface?, it’s not unlikely that a typeface exists which for clarity puts Greek letters in a slightly different makeup, and I would not think this would be a bad idea, differentiating A and ? in various manuscripts can be very handy. And this requires extensive workarounds in LaTeX, to be expected from a tool coming from a time which prided itself on writing all possible code with the mentality of not looking ahead and taking into account the future. LaTeX code manages to be a reasonable write-only language, an impressive feat considering you don’t even have to mentally follow the flow of computation, that its commenting syntax is so verbose that it discourages people from using them might be another part of the problem.

Another thing I don’t like is how it enters and closes math-mode, sure, if math-modes can’t nest? Why not take the same open and closing tag right? I am sure to speak for all of us when I say that never has debugging been such a pain as LaTeX incorrect LaTeX math-mode closing, the error messages are so enormously cryptic by misplacing a dollar sign that you often have no idea exactly which it is you misplaced and often when you got it to work you still have no idea what you did wrong. It’s like rebooting your computer when some-thing went wrong and you’re still not exactly sure on how you fixed it. It turns out that closing tags help error messages and help you find them. Maybe this is Donald’s savant mind speaking who makes no errors, but for us mortals this is damned annoying.

It’s quite clear that the base of this language was designed in a time when people were practically still cave-men scratching COBOL code in granite walls to keep track of how many mammoths they hunted down.

Finally, on a more meta-level. LaTeX, well, just PDF or Postscript really, defines a lot of things which I feel a document ought not define. Yes, they are languages to specify the layout for a printing place, every pixel, every vector, and I feel that the only thing that should ever receive that data is the printer, or the person who checks it before it goes to the printer. The consumer should never receive that on his or her computer. Things like font size, font type, letter spacing, colour, text width, line spacing, these should all be properties of the viewer not of the document it reads. Supposedly LaTeX is about legibility, and it has used some archaic myths about what is optimal legibility to algorithmically force that down our throats, in reality probably more Donald Knuth’s præferred style. In the end, legibility is subjective, dependent on person, varies through locus and time, has a genetic and an environmental component, what one person considers legible another does not. So people should be able to adjust those settings in their viewer, computers are powerful enough to calculate that on the fly nowadays. Especially since e-readers are coming up, why not use that advantage?

Some people have already done this, it’s called separation of præsentation and content, take apart what you are saying semantically, and how you are layouting what you say for the most part as you can. It’s scalable, it takes into account that the house style of the publishing magazine may later on change, it enables the same document to easily be published in multiple styles depending on the target audience, it also gives the audience itself control over the style if they receive it in digital format, and so on. I for one hate with a passion that new misodendric hype of basically 1 em line spacing in papers. I’m still not really sure if they actually hit enter twice after every line or make some switch that does that automatically for each line, but as they use LaTeX I would not be surprised if they actually accomplished their treeslaughter by the former. Every time I see it, I would kill to have my PDF viewer implement a simple switch that could take that away, it reads both annoyingly and I’d like my grandchildren to have a plentiful supply of oxygen.