LaTeX is Broken

I love LaTeX because it can do things nothing else can. I have to use it, because it can do things nothing else can.

But it has some deep problems.

Packages

I think the biggest root of problems is having packages, rather than just having people submit a pull request on a central repository and add whatever feature someone wants.

LaTeX' basic tabular environment is awful. If you put in a long line, it'll whiz off the page. Not a single human in all the universes, fact or fiction, have ever wanted to print something outside a page. So this was replaced by tabularx, which demands the user download it (or find some LaTeX package manager), and then pull it up while LaTeX compiles the document.

This was not the end of the debate on how to make tables, so yet more people have created packages, and then others made packages relying on other packages, so if you want to use the tcolorbox package, hopefully you chose the right tabular-type package, or you'll have to reprogram your document.

Plain text, used in \altt was broken, so a new package was brought in, rather than replacing the native LaTeX function, because the native function doesn't wrap words, but prefers to print them outside of the page.

LaTeX supports floating images with the right package (where the image decides where to sit depending on where it fits best), but the multiple columns package (multicol) can't support the floating images.

While one package per function might have made LaTeX smaller back in the 80's when there were twelve packages available and 10 Megabytes of disk space per university, modern users typically install all packages instead of messing with individual installations. This leaves the installation size at over a gigabyte due to decades of bloating code piled one on top of the other.

Various packages then have surprised for the user when it comes to interoperability. Want a floating image? No problem - but if you're using that inside multiple columns, suddenly we're gonna have a problem.

A single, monolithic program which handled formatting would ensure that the tabular environment was fixed rather than having three fixes thrown on top. A single program wouldn't have clashes between commands, such as the command \box being used by different symbol libraries. It could also allow the user to instantly state the commands they want, rather than importing packages at the start of the document. And finally, it could allow for a few, standardized test documents, which would stick a title in a box, which then went on to declare multiple columns, just to make sure every environment worked with every other environment.

Useless Output

Here's an example output from LaTeX:

 1Package multicol Warning: I moved some lines to the next page.
 2(multicol)                Footnotes on page 41 might be wrong on input line 102
 36.
 4
 5
 6Overfull \hbox (8.5359pt too wide) has occurred while \output is active
 7 [][][]
 8
 9Overfull \hbox (8.5359pt too wide) has occurred while \output is active
10 [][][]
11
12Overfull \hbox (8.5359pt too wide) has occurred while \output is active
13 [][][]
14
15Overfull \hbox (8.5359pt too wide) has occurred while \output is active
16 [][][]
17
18Overfull \hbox (8.5359pt too wide) has occurred while \output is active
19 [][][]
20[41] (./story/12-advanced.tex
21
22LaTeX Font Warning: Font shape `T1/artemisiaeuler/m/scit' undefined
23(Font)              using `T1/artemisiaeuler/m/sc' instead on input line 74.
24
25
26Overfull \hbox (8.5359pt too wide) has occurred while \output is active
27 [][][]
28
29LaTeX Font Warning: Font shape `T1/artemisiaeuler/m/scit' undefined
30(Font)              using `T1/artemisiaeuler/m/sc' instead on input line 74.

The first part says it moved lines, and a footnote might be wrong. I don't care about that line, and the footnote is fine, but even if it weren't, I'm not sure what I could do about that. The next parts say that something, somewhere, is too wide (it isn't), repeatedly. Again, I can do nothing with this statement. Lastly, we have a warning that something is undefined. The book outputs fine, so I'm not sure what LaTeX wants defined.

The error messages are no more useful, and far more maddening.

1! pdfTeX error (font expansion): auto expansion is only possible with scalable
2fonts.
3<argument> ...shipout:D \box_use:N \l_shipout_box
4
5l.60 \section*{Special Thanks \ldots}
6
7!  ==> Fatal error occurred, no output PDF file produced!
8Transcript written on main.log.

In total, a 200 page book produces 3736 lines of output.

The last line here says we have more in main.log. It is 7717 lines long, contains mostly the same information (but not entirely), and ends with this entirely useless sentence:

1 115325 words of extra memory for PDF output out of 128383 (max. 10000000)

At one point when writing a LaTeX function, I actually used a command to print some error message into this document, so the problem isn't that error-logs are useless, the problem is outputting useless statements about every \hbox.

Two in One

LaTeX was built on TeX, and the ghosts of TeX are everywhere. Stack Exchange is bloated with posts about how to fix problems by first regaining the old TeX syntax, which involves an '@', then closing that syntax off. The result is that we jump between two very similar languages, but gain nothing for the effort.

If you want to change a command with \renewcommand\@endpart, or loop something with an \@Repeat command, then that's a TeX command. If you're inserting a Tikz image, or using the \section{} command, that's LaTeX.

Back and forth we go.

Footnotes

If you want a '†' symbol as a footnote marker, add the following command:

1    \renewcommand{\thefootnote}{\fnsymbol{footnote}}

...but then (SURPRISE) the package breaks after 9 footnotes. To fix this, download yet another package, compile the documentation, and find the option to reset the footnote counters.

Memory

I needed a few hundred glossary entries, for reasons. LaTeX crapped out, saying 'out of memory', presumably due to some safety switch placed there in the 70's.

The entire project can fit into my computer's ram 800 times over, but apparently I need to reconfigure some LaTeX memory specification...or TeX - unsure.

Fonts

Donald Knuth, inventor of TeX, decided that TeX should not allow the user to select the typeface because all users would make horrible typeface choices. It's a funny anecdote, but a short-sighted decision, because users (predictably) changed the open-source program so they could have different typefaces.

Some typefaces are added by using a particular package (which then changes all standard writing), others are added by adding a package (which then lets you change typefaces for particular sections), and still more are added by using Xetex to compile the document, which has some differences to LaTeX.

Variables

The kinds of memory management you have to deal with in C code really have nothing on the difficulties LaTeX represents. Try to represent a page number (e.g. 'we are already on page XX, and have only just begun to...'), and you'll have to find some workaround, rather than just pulling out the variable.

The current day is stored as \theday, in some contexts, but must be translated to a value to be used in commands, or translated into a number for others before it prints.

We cannot even print the current section without workarounds, such as loading a package for fancy headers, then inputting \leftmatter (a variable designed to go at the top of the page).

Any attempt to circumvent these pages with begin an epic quest across Stack Exchange, and downloading half a gigabyte of pdf documentation, where some documents present clear guides for beginners, and others give a series of commands intelligible only to those who learned the original language TeX.

Size

A full LaTeX install takes up 5 Gigabytes, plus dependencies. The output really cannot justify this mess of code, and if LaTeX were a single program which improved existing functions rather than adding alternatives, it wouldn't have happened.

Fracturing

The markdown package's documentation covers usage in these four TeX versions:

  • TeX
  • lualatex
  • ConTeXt
  • LaTeX

Each package has a different subset of these. Sometimes a package works across the board, sometimes it works with only some.

So every time you switch engine, or add a package, the heap of spaghetti code you've written becomes a little messier, and you spend just a little more time debugging, rather than working on the actual text-document that you forgot about last week, when you accidentally became a coder.

Scope

You want a variable (e.g. \fishName), so you initialize it in some .sty file, and set out to format a book about fish with a standard introduction, such as what it eats. You decide to set a few toggles to present predators one way, and other fish another way. But then it all comes out wrong!

What you might not have noticed is that certain things in LaTeX count as environments, and other things do not. Within an environment, setting the font's size, switching boolean toggles (e.g. \ifPredator), and changing a command will not have any effect outside that environment.

  • So macros (which you also use for variables) depend on the current scope.
  • Counters are all global.
  • Boolean toggles are limited by scope.
  • Font differences are limited by the scope, and also by any curly brackets.

Counters are Not Global

Counters are global, except when you multiply or divide. Didn't see that one coming, did you? Now LaTeX is going to take the rest of your afternoon away, as you stare at it, slowly compiling for the tenth time, because you have no idea why the thing which always worked suddenly stopped.

Take a look at this mess:

 1
 2\newcounter{age}                                                  |    
 3                                                                  |    
 4\setcounter{age}{37}                                              |        
 5                                                                  |    
 6I am \arabic{age} years old.                                      |        
 7                                                                  |    
 8\begin{quotation}                                                 |     I am 37 years old.
 9  The adults laughed when hearing the Monty Python line of        |      
10  ``I'm \arabic{age}, I'm not \emph{old}'', and now I know why.   |       The adults laughed when hearing the Monty Python line of “I’m
11  \addtocounter{age}{1}                                           |       37, I’m not old ”, and now I know why.
12  \multiply\value{age} by 2                                       |       Of course this isn’t as bad as being 76.
13                                                                  |    
14  Of course this isn't as bad as being \arabic{age}.              |     Soon, I shall be 38, which officially is old.
15                                                                  |    
16\end{quotation}                                                   |           
17                                                                  |    
18Soon, I shall be \arabic{age}, which officially \emph{is} old.    |          

We have multiplied the 'age' by 2, so the result should remain 37, but it does not. It returns, not to the original value of 37, but to 38.

Want to know how I multiply numbers? I add zero.

1\setcounter{age}{39}
2\multiply\value{age} by 2
3\addtocounter{age}{0}

This little hack lets you retain a number, and this little hack alone should tell you that the time for TeX to die has long gone.

People use LaTeX despite its problems, because nothing else can replicate its power. But being the best doesn't excuse the kind of nightmares LaTeX users have come to think of as normal.

I'm thinking of switching to sile, at least for new projects.