Getting TeX
Using TeX
- The TeX Users Group has many useful links.
- You may download The Not So Short Introduction to LaTeX 2e.
- Jeff Hirst’s LaTeX resource page includes sample files.
- Scott Pakin maintains a very complete list of LaTeX symbols, though it is often overwhelming in its breadth.
- I made a much smaller list of basic symbols and reference.
- Here is what I made when I was learning the LaTeX picture environment. The source.
Files I created for computability theory
- A template file with all sorts of header material included.
- The first example file, with lots of explanatory comments.
- The second example file, containing many more LaTeX commands.
- The LaTeX assignment, to replicate this pdf file.
LaTeX is a markup language, a system of document creation where you write plain unformatted text (as you might in TextEdit or Notepad), and that is turned into pretty formatted (or typeset) text (as you might see in Word, only nicer) by a compiler. That is, instead of selecting “italics” from a menu and seeing your text instantly italicized, you type a markup command that will be interpreted by the compiler as “put this text into italics”. Another markup language you might be familiar with is HTML (hypertext markup language); if not, you can see an example by selecting “view source” or “page source” from one of the menus in your web browser. Compare what you see in the original window (here) to what you see in the source window — the source file has a lot of text that does not appear in the webpage. The source file has been rendered into the webpage image, using the information from the extra text, or commands. In LaTeX, we speak of a text file being compiled, into a pdf, dvi, or ps file. The first kind you’re probably familiar with; the other two are just different formats.
The markup commands have different purposes: some change the size or form of letters (italics, boldface), some change the overall layout of the document (margins, columns, chapters, sections), some produce characters one can’t type (Greek letters, mathematical symbols), and some change the local layout of the document (tables, graphics, lists, indentation).
The best way to learn LaTeX in the beginning is by looking at other people’s files (as is also true for HTML and most programming languages). Once the syntax (way of writing it) starts to make more intuitive sense to you, there are a number of excellent reference books from which to learn more commands.
Here is an ultrabrief overview of LaTeX.
Some examples, comparing to HTML:
- To begin and end a webpage, you use the commands <html> and </html>. To begin and end a LaTeX document, you use \begin{document} and \end{document}. LaTeX has more options than HTML, though, so you will also have to include some information before the \begin{document} to tell the program which options you’re exercising. In particular, you must include the command \documentclass{classname}, where classname is replaced by the kind of document you want to make: article, book, letter,… the list goes on and is added to regularly.
- To italicize in HTML, you enclose the text in <em> and </em>, as so: <em>this text is italicized</em>. In LaTeX, it’s a single command with the italicized text enclosed in curly braces: \emph{this text is italicized}.
- To center in HTML, you enclose the text in <center> and </center>. In LaTeX, these change to \begin{center} and \end{center}.
Dollar signs and other special characters:
If you’ve looked at some LaTeX files, your next question might be “what’s with all the dollar signs?” Some commands in LaTeX only work in math mode, and you tell the program you’re entering or leaving math mode via a dollar sign. This gives LaTeX the ability to double up on commands – to give one command two meanings, depending on whether it’s in math mode or not. An example is the dash: out of math mode, that is, simply -, it is a short dash. Inside math mode, $-$, it is a minus sign and so is longer.
That brings us to one other point: some symbols are used specially, like \ and $, and so there are different commands that produce that symbol on the page. If you type a single \, LaTeX expects the next thing it reads to be a command. If you want a backslash to appear on the page, that next command should be “backslash”: \backslash will print a backslash. To get other special characters, you generally precede them with a backslash, as in \$ for a dollar sign or \{ and \} for curly braces.
Why won’t it compile?
Provided the program is actually running, here’s a bare-bones list of things to check: Does every { have a matching }? Likewise for $…$ and \[…\]. Does every \begin{…} have a corresponding \end{…}?
If possible, you can try hitting enter repeatedly in the compiler window until it finishes – often the file will compile to some extent, and if you’re, say, missing a dollar sign, it should become very obvious where the error occurred.