LaTeX isn’t for everyone but it could be for you

Anyone who has used Microsoft Word for a reasonable amount of time will recognise my very own Andy’s Laws on Word:

  1. Likelihood of a crash is directly proportional to the importance of a document.
  2. Likelihood of a crash is inversely proportional to the time left before its deadline.
  3. Likelihood of a crash is directly proportional to the duration since you last saved.
  4. Likelihood of you throwing your computer out of the window is directly proportional to the number of times Clippy pops up.
  5. That’s enough laws for now…

In all seriousness, I’ve written many words in large documents using Microsoft Word. Nowadays, I can use OpenOffice because it’s come a long way and really is a decent product (the current v2 beta is very good). However, ever since my never-ending woes with Word during my degree, when I started my PhD, I decided to go and try out Latex. Actually, that’s not quite true, I wanted to submit a paper to a journal and it only accepted Latex documents. The deadline was the same day as I found out about the call for papers. I jumped straight into the deep-end with both feet. Needless to say, I had a hard time of it and wasn’t Latex’s best fan that day. (Lesson: don’t try to learn something new in a rush!)

Undeterred, I stuck with Latex and realised that it wasn’t so hard after all. There was a learning curve, but for the typical documents that I often wrote, there was very little to learn. I’m very glad I persevered because I wouldn’t want to use any thing else for my papers/reports any more. I’m not the only one who’s glad to move away from the WYSIWYG world. This article will not be a tutorial for how to use Latex, instead an overview of its benefits and why I think it trumps what word processors have to offer.

What is Latex?

In 1978, Donald Knuth – arguably one of the most famous and well respected computer scientists – embarked on a project to create a typesetting system, called Tex (pronounced ‘tech’), after being disappointed with the quality of his acclaimed The Art of Programming series. Around 10 years later, he froze the language after originally anticipating spending a single year! Tex gave extremely fine-grained control of document layout. However, the vast flexibility meant it was complex, so by the mid-80s Leslie Lamport created a set of macros that abstracted away many of the complexities. This allowed for a simpler approach for creating documents, where content and style were separate. This extension became Latex (pronounced ‘lay-tech’).

Latex is essentially a markup language. Content is written in plain text and can be annotated with various ‘commands’ that describe how certain elements should be displayed. The Latex interpreter reads in a Latex marked-up file, renders the content into a document and dumps it a new file. Therefore, it’s not an interactive system that is the de-facto method for document creation nowadays.

Separation of content and style

Not the most obvious advantage, possibly because a lot of Word users don’t understand why this so beneficial. When producing your Latex document, you are concentrating on the content itself. You introduce structure explicitly by telling Latex when a new section begins, for example, but you don’t then faff around trying to decide how the section headers should look. That’s done later.

This is opposed to the average Word user, who will immediately highlight a given section header and apply formatting to it: maybe a larger font, maybe underline, etc. The point is that this will then have to be applied to every header manually. Latex is better as it uses a document style. This defines how different elements within your document should look (like Cascading Style Sheets defining styles in HTML pages). If you fancy a change, you only change the style definitions once, then the presentation of the document will be updated automatically. This also ensures a consistent looking document (you wouldn’t believe how many stylistically inconsistent Word docs I’ve read!)

Word does in fact have a similar Styles feature. However, because it’s optional, people don’t often know it exists. Latex forces you to declare the document semantics (this is a Good Thing!), which is why you can rely on it to produce a consistent looking document.

Portability

Latex portability comes in multiple ways:

  1. An actual Latex file is merely a text file, which is just about the most portable format in computing.
  2. The Latex system that processes the text file and produces the finished document has been implemented on just about every mainstream platform you care to mention.
  3. The default output file format for Latex is DVI (which stands for device independent). This was around well before PDF was dreamed up and the high quality files can be viewed via software viewers or printed out. DVI is an open standard, so once again, readers are extremely portable and exist on most operating systems. Admittedly, DVI is hardly ubiquitous and nowadays it’s often bypassed in favour for PDF (or it’s very simple to convert to other formats like PS or HTML)

Flexibility

You can get Latex to do just about anything you can think of! Over the years, an overwhelming selection of packages to extend its potential and macros that can simplify complex tasks have come into being, most of which are freely available on CTAN. For example, Latex’s main users are within academia and research institutions and they benefit hugely thanks to the Bibtex package that provides bibliography management – I pity my Word-using colleagues who suffer by actually manually word-processing their bibliographies (unless they’ve shelled out for a program like Endnote). There are other crazy packages that you can install which allow you to typeset music scores, chessboards and cross-words! CTAN is the main repository of these resources. Most are well documented and as you can imagine, with Latex being around for so long, the number of extensions is vast. The chances are, if you’re struggling to do a task, someone will have undoubtedly written a package to solve it easily!

Control

Even with simple documents, you can quickly become frustrated by Word’s rather unintelligent interference. The hours that are wasted trying to position that image which you know will fit at the bottom of the page, but Word refuses to put it there! How many can relate to this experience? You have your 30 page document with text, tables and images. You just spent the evening getting it formatted nicely – all your figures in the right place and then you notice that one of your paragraphs isn’t clear enough. You add one sentence, which then pushes an image on to the next page, leaving a massive gap at the bottom of that page where your image once was. This then daisy-chains down, knocking other tables and images out of place all the way to the end of your document! It’s a real laugh. Fortunately, Latex is much more clever in this respect and positions your images and tables with a lot of common sense. So, if you want your image to appear at the bottom of a given page, it’ll stay there!

Whilst Latex makes decent typesetting decisions for you, if you want to, you can have total control over the presentation of your document.

Quality

It’s difficult to disagree that the output from Latex is far superior to what Word can produce. This is emphasised greatest when it comes to documents with high mathematical content, which is a major strength for Latex. It also has much better kerning, hyphenation and justification algorithms that simply make the output far more professional than what any word processor. Its algorithms for laying out text are more sophisticated and extremely fine-grained. For example, the accuracy is so high because it uses a measurement known as a scaled point which translates as 100th of the wavelength of natural light!

Latex works with the concept of niceness (well, I suppose technically it’s badness – which it works to minimise). Latex has a large set of metrics that it evaluates against when generating your document. It experiments with various permutations of parameters and determines the one which gives the “nicest” output. It can take the time to do this because it isn’t interactive. Word processors don’t have the computational resources available (yet) to carry out the equivalent calculations and still remain interactive. Also, many people forget that typesetting is actually a professional skill – people train for years to learn how to layout publications. Yet, as soon as you open a word processor, you go about committing typesetting sins all the way. Typesetters know for example that its easier to read sentences that are approximately 66 characters wide. Have a look in your books and count the letters! Also, why do newspapers and magazines have narrow columns? But, the default layout of a word processor gives an average of 100 words per line. I suppose many people don’t mind, but you would notice if you read a lot of large documents.

A quick example. I took a document that I had used previously to demonstrate document structure in Latex. I used the same text and loaded it into Word and applied the equivalent styles. I’ve used default settings throughout. Word didn’t have a style for abstracts, so I put the title in bold. View the Latex output to the Word output. The styles that Word uses aren’t great. You could manipulate the default styles in Word to make it look more reasonable, but I’ve never been bothered because even if I could get it to match Latex stylistically, I still have to use Word, which I’d rather avoid!

Latex has been used regularly typeset entire books. Word processors simply aren’t good enough for that job – they are used by the authors to write the content and these files are then imported into professional typesetting software. Ok, that’s not strictly true – you could typeset a book in Word, just like you could drive a car with your feet – it’s not a good idea though!

Output

As mentioned, the default output is a DVI file. DVI was a clever little standard but unfortunately didn’t take-off. It takes little effort to convert your document into a Postscript or PDF file (in fact, you can just use the ‘pdflatex’ command instead of normal ‘latex’ if you only ever want to create PDFs). There’s no need to buy additional software such as Adobe Acrobat like you need to do to convert a Word document into PDF. (At least OpenOffice has its ‘Export to PDF’ functionality!)

Scalability

In my personal experience, using Word for documents with more than 20 pages has not been a pleasant experience. Obviously, that could be my own bad luck, but that is also the impression I’ve got from other users too.

With Latex, I’ve never found such problems. Additionally, you are free to split up large documents into smaller chunks and then let Latex combine them altogether later (like one chapter per file). It can also create tables of content, indexes and bibliographies easily, even on multi-file projects.

Stability

One of the reasons why perhaps so many people struggle with Word when creating large documents, is because it is prone to crashes. ‘Document recovery’ is now a high ranking feature of Word. I’m sure people would prefer if MS would just make their software more stable! (NB stability issues are not necessarily generalisable, so I’m speaking from personal experience, and of my friends and colleagues – I do not know of a single user who hasn’t lost work to Word, but that’s not to say that such people don’t exist.)

Because Latex is so mature – and developed by extremely clever programmers – bugs are negligible. And even if it were buggy, then there is no risk of you ever losing your original source text. Where as with Word, almost any tool within its integrated environment is capable of corrupting your file if it causes a crash.

Oh, you don’t need to worry about macro viruses either!

Cost

Well, this is one area where Latex wins hands down, since it is free! As with most open source software, the phrase “you get what you pay for” doesn’t hold true. You get an extremely mature system, that is still years ahead of its competition.

What about spell checking?

It’s a good point. This is not a deficiency of Latex, because it just processes the words you give it. However, within your text-editor, you do not get fancy lines highlighting your spelling errors or bad grammar as you type, like you get with Word, yet it’s a feature users have come to expect when writing documents.

For starters, I do not really care for a grammar checker and anyone who actually relies on it when using Word would be better off buying a book (or looking at writing style guides) than taking the useless advice it provides.

Secondly, the ‘auto-correct’ feature – whilst looking like a good idea – is not beneficial in the long run. Sure, it corrects the common typos that we all make. However, the problem in my opinion is that it means we don’t learn from our mistakes, e.g., you will continue to type ‘teh’ instead of ‘the’ because Word will sort it out for you. Having said that, if that’s your thing, then you can easily configure any decent text editor to perform the same task. (You could, if you really wanted to, use your favourite word processor as your text editor – but then you back to square one on the stability issue.)

And so on to spelling. The great thing here is that you have a choice! Aspell and Ispell are the most popular spell checkers I know of (both open source). These will check any text file you care to feed it and you can easily configure a decent editor to integrate its functionality from within the editor itself. How to get your text editor to utilise these programs is obviously dependent on your editor of choice. Some, like Kate, interface external spell-checking programs without any effort. I personally use (g)vim which can be configured to use spell-checkers like Ispell.

C’mon, be fair!

Ok, I am obviously biased here. However, I am someone who uses both systems. It’s perhaps not really fair to compare Latex and Word, because they are different types of system, which are suited to different jobs. However, for as long as people are using Word within academia and research institutions, I feel I should enlighten them and let them know what they are missing out on.

Sure, Word can be extended using its in-built scripting language. It also has document management features to help with large documents. As already mentioned, it has styles that can ensure manageable and consistent presentation. Yet very few people seem to take advantage of them. This is especially worsened by UI improvements that mean Word will hide features that you do not use, which makes it more difficult to remember what Word can actually do.

Word may have the advantage of a GUI which is good for beginners. It reduces the cognitive load as it’s a case of recognition verses recall. If people really want a GUI, then there are ones that act as a front-end to Latex. It’s not a WYSIWYG editor, because what you see on screen is not what you will get when you print it out. Instead, you have What-You-See-Is-What-You-Mean editors that still hold to the ideals of Latex by keeping content and style separate. However, they are environments that allow a more visual approach to your content, which is handy for producing complex equations, for example, but will pass your content to Latex for producing the final document. Lyx is the best example and was originally developed by Matthias Ettrich (yep, that’s right, the same guy who founded the KDE project). You can also get Latex editors, which are like normal text-editors, in that you see all the raw Latex commands, but they come with additional features that help with creating that file, like table wizards, symbol databases, etc.

The learning curve

The reason why everyone isn’t using Latex is because you can’t just load up and go, like you can with a word processor. I consider Latex analogous to HTML with CSS. You need to put some markup around your text before your browser knows what to do with it – and the same is true with Latex. Of course, nowadays, any one can knock up a webpage thanks to, er, Word, and various other visual HTML editors and as a result, they generally look crap. So, you need to invest a bit of time in learning some basic commands, but you’ll soon realise that it’s very simple afterwards. Here’s a Latex “Hello World!” as an example:

% hello.tex - Hello world Latex example

\documentclass{article}

\begin{document}

Hello World!

\end{document}

This that generates the following output. It wasn’t that difficult, was it? To continue learning the basics, here are the best places to go:

So who is Latex good for?

Quite simply, anyone who is writing non-trivial documents and is tired of being let down by the performance of the current crop of word processors. If you are in academia, you really ought to be using it! Anybody writing anything maths related will not find a richer and better quality system. For example, even WikiPedia use Latex for rendering any formulas that appear on their site.

Latex isn’t for people who are too lazy or dislike change! I personally found the investment paid off because Latex allows me to produce my documents at a greater pace. I know that the enterprise will not be interested as Word is so ingrained, even though their business reports would look so much nicer. Their loss! For everyone else, it’s time to give it a fair try, just so that you compare and contrast, then decide which does the job best for your needs.

About the author:
Andrew Roberts is a computer science graduate from the University of Leeds, UK. He remained at Leeds to study further towards a PhD in Natural Language Processing. He has been using Latex for three years and is the author of the Getting to Grips with Latex series.


If you would like to see your thoughts or experiences with technology published, please consider writing an article for OSNews.

122 Comments

  1. 2005-06-06 6:32 pm
  2. 2005-06-06 6:35 pm
  3. 2005-06-06 6:36 pm
  4. 2005-06-06 6:38 pm
  5. 2005-06-06 6:51 pm
  6. 2005-06-06 6:54 pm
  7. 2005-06-06 6:58 pm
  8. 2005-06-06 7:02 pm
  9. 2005-06-06 7:04 pm
  10. 2005-06-06 7:05 pm
  11. 2005-06-06 7:06 pm
  12. 2005-06-06 7:08 pm
  13. 2005-06-06 7:10 pm
  14. 2005-06-06 7:11 pm
  15. 2005-06-06 7:18 pm
  16. 2005-06-06 7:19 pm
  17. 2005-06-06 7:21 pm
  18. 2005-06-06 7:22 pm
  19. 2005-06-06 7:23 pm
  20. 2005-06-06 7:24 pm
  21. 2005-06-06 7:25 pm
  22. 2005-06-06 7:28 pm
  23. 2005-06-06 7:31 pm
  24. 2005-06-06 7:33 pm
  25. 2005-06-06 7:34 pm
  26. 2005-06-06 7:37 pm
  27. 2005-06-06 7:41 pm
  28. 2005-06-06 7:44 pm
  29. 2005-06-06 7:55 pm
  30. 2005-06-06 8:04 pm
  31. 2005-06-06 8:10 pm
  32. 2005-06-06 8:11 pm
  33. 2005-06-06 9:01 pm
  34. 2005-06-06 9:07 pm
  35. 2005-06-06 9:07 pm
  36. 2005-06-06 9:18 pm
  37. 2005-06-06 9:25 pm
  38. 2005-06-06 9:29 pm
  39. 2005-06-06 9:31 pm
  40. 2005-06-06 9:32 pm
  41. 2005-06-06 9:36 pm
  42. 2005-06-06 9:47 pm
  43. 2005-06-06 9:48 pm
  44. 2005-06-06 9:49 pm
  45. 2005-06-06 9:52 pm
  46. 2005-06-06 9:54 pm
  47. 2005-06-06 9:55 pm
  48. 2005-06-06 9:56 pm
  49. 2005-06-06 10:03 pm
  50. 2005-06-06 10:07 pm
  51. 2005-06-06 10:07 pm
  52. 2005-06-06 10:09 pm
  53. 2005-06-06 10:15 pm
  54. 2005-06-06 10:20 pm
  55. 2005-06-06 10:27 pm
  56. 2005-06-06 10:30 pm
  57. 2005-06-06 10:31 pm
  58. 2005-06-06 10:32 pm
  59. 2005-06-06 10:33 pm
  60. 2005-06-06 10:37 pm
  61. 2005-06-06 10:38 pm
  62. 2005-06-06 10:41 pm
  63. 2005-06-06 10:46 pm
  64. 2005-06-06 10:48 pm
  65. 2005-06-06 10:50 pm
  66. 2005-06-06 10:51 pm
  67. 2005-06-06 11:00 pm
  68. 2005-06-06 11:00 pm
  69. 2005-06-06 11:06 pm
  70. 2005-06-06 11:12 pm
  71. 2005-06-06 11:13 pm
  72. 2005-06-06 11:23 pm
  73. 2005-06-06 11:25 pm
  74. 2005-06-06 11:28 pm
  75. 2005-06-06 11:42 pm
  76. 2005-06-06 11:54 pm
  77. 2005-06-07 12:04 am
  78. 2005-06-07 12:08 am
  79. 2005-06-07 12:13 am
  80. 2005-06-07 12:17 am
  81. 2005-06-07 12:21 am
  82. 2005-06-07 12:25 am
  83. 2005-06-07 12:26 am
  84. 2005-06-07 12:35 am
  85. 2005-06-07 12:38 am
  86. 2005-06-07 12:40 am
  87. 2005-06-07 12:46 am
  88. 2005-06-07 12:48 am
  89. 2005-06-07 12:59 am
  90. 2005-06-07 1:20 am
  91. 2005-06-07 1:25 am
  92. 2005-06-07 1:32 am
  93. 2005-06-07 1:36 am
  94. 2005-06-07 1:36 am
  95. 2005-06-07 1:47 am
  96. 2005-06-07 2:42 am
  97. 2005-06-07 3:03 am
  98. 2005-06-07 3:05 am
  99. 2005-06-07 3:16 am
  100. 2005-06-07 3:37 am