1: LaTeX?
LaTeX
LaTeX is a typesetting programming language, which tries to get in the way of your text as little as possible, until you really need it. Unlike Microsoft Office Word, or Open Office Writer, LaTeX isn’t a special program that you type in, but really is the name of programming language you use for typesetting. Just as there are lots of compilers for one programming language available, there are many LaTeX engines available to turn your source code into documents, and they all have their own strengths and weaknesses, but the one we consider the best is the LaTeX engine called “XeLaTeX”, because it supports unicode, which means it supports every character you can type on a computer, for any language, and any script. The plain LaTeX engines cannot do this, so really we won’t be bothering with them a lot.
Packages
LaTeX has some basic functionality, but it can be extended to do nearly everything you might want it to do by telling it to rely on packages. Packages are a little bit like plugins. If you think of a graphics programme, you might want to do something the program cannot do, like shuffle an image like a slide-puzzle, but someone may have written a plugin that will do that for you. Similarly, think of your web browser, which doesn’t block ads out of the box, but there will be a plugin available that blocks things like flash and banner ads. The same goes for LaTeX: if it cannot do what you want it to do, there will typically be a package available that gets the job done.
Source code
When you write LaTeX source code you can use anything editor you like, as long as it can save your data as plain text. This means you can write a high quality book in either a WYSIWYG LaTeX editor (such as LyX), a dedicated LaTeX text editor (such as TeXnicCenter or TeXmaker) or even something as simple as a normal text editor like Notepad++ or Notepad2.
When you’re done writing your source code, you run it through the LaTeX engine of your choice (though if it’s our choice, the XeLaTeX engine) and you end up with a typeset and “final” document. You cannot edit that document, but that’s also good: it means you cannot do any after-the-fact retouching. Either you got it right because your source is set up for it to be right, or you haven’t really done your job yet and you need to adjust your source so the end result is what it should be.
Multiple runs
LaTeX is a bit of a curious beast: it typically needs to be run several times in a row for everything to end up in the right place. For instance, if you want a table of contents, you would say “I want to use the tocloft package, because that lets me build a ToC”, and then when you run your source through the LaTeX engine, your document won’t have a table of contents! Instead, what happened was that the engine ran over your source, and followed the instructions in it, but the tocloft instructions are “if there is not toc file, make one. if there is one, innclude it in the final document”. So the first time you run it, instead of putting a ToC in your document it will generate the file with all the ToC information. If you then run your file through LaTeX again, that ToC information is actually put in your document.
This sounds a bit silly, but it’s also really precise, and that’s what’s important. Ultimately, it’s pretty much irrelevant whether you have to run the compilation process once, or ten times in a row. It no longer being the 1970′s, the process is typically fast enough that you won’t even have time to make a cup of tea while your source is compiled in a number of steps to a final document.
So why doesn’t it just keep running itself until there’s no “changes” to the final document? Well, quite simply, because you’re in control. There are packages (remember, plugins) that let you do things “in between” compilations, such as generating external indices and glossaries, so you don’t want latex to just keep running until nothing changes, because you might want to do something in between those runs!
The Tutorial
LaTeX is actually pretty easy once you understand the basics, so the next pages will explain how to go from an empty file, to a file that compiles into a pretty good looking final document.