LaTeX/Introduction

From testwiki
Revision as of 18:32, 2 March 2008 by 137.44.1.200 (talk) (Prerequisites)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:LaTeX/Navigation

What is TeX

TeX (pronounced "Tech", with "ch" like in the Scottish "Loch"; see below for details on pronunciation) is a low-level programming language created by Donald Knuth to typeset documents attractively and consistently. It's a programming language, in the sense that it supports the if-else construct, it can calculate (the calculations are performed while compiling the document), etc., but you would find it very hard to make anything else but typesetting with it. The fine control TeX offers makes it very powerful, but also difficult and time-consuming to use. Knuth started writing the TeX typesetting engine in 1977 to explore the potential of the digital printing equipment that was beginning to infiltrate the publishing industry at that time, especially in the hope that he could reverse the trend of deteriorating typographical quality that he saw affecting his own books and articles. TeX as we use it today was released in 1982, with some slight enhancements added in 1989 to better support 8-bit characters and multiple languages. TeX is renowned for being extremely stable, for running on many different kinds of computers, and for being virtually bug free.

The version number of TeX is converging to π and is now at 3.141592.

Its name originates from the Greek word τϵχνoλoγια (technologìa, in English technology); its first syllable is τϵχ, similar to TeX in the Latin alphabet.[1] The name of the language is thus upper-case τϵχ: TEX, and the convention has arisen that the name is also its own pronunciation when written in the International Phonetic Alphabet. Unfortunately, there is ambiguity among authors as to whether this transcription is /tex/ or /tϵx/: the vowel is thus pronounced either as the "ay" of words such as "way, hay, bay" (former case) or as the "e" of words such as "bet, met, let" (latter and more frequent case).

What is LaTeX

LaTeX (pronounced either "Lah-tech" /la.tϵx/ or, less often, "Lay-tech" /le.tϵx/) is a macro package based on TeX created by Leslie Lamport. Its purpose is to simplify TeX typesetting, especially for documents containing mathematical formulae. It is currently maintained by the LaTeX3 project. Many later authors have contributed extensions, called packages or styles, to LaTeX. Some of these are bundled with most TeX/LaTeX software distributions; more can be found in the Comprehensive TeX Archive Network (CTAN).

Since LaTeX comprises a group of TeX commands, LaTeX document processing is essentially programming. You create a text file in LaTeX markup. The LaTeX macro reads this to produce the final document.

Clearly this has disadvantages in comparison with a WYSIWYG (What You See Is What You Get) program such as Openoffice.org Writer or Microsoft Word:

  • You can't see the final result straight away.
  • You need to know the necessary commands for LaTeX markup.
  • It can sometimes be difficult to obtain a certain 'look'.

On the other hand, there are certain advantages to the markup language approach:

  • The layout, fonts, tables and so on are consistent throughout.
  • Mathematical formulae can be easily typeset.
  • Indices, footnotes and references are generated easily.
  • You are forced to correctly structure your documents.

The LaTeX-like approach can be called WYSIWYM, i.e. What You See Is What You Mean: you can't see how the final version will look like while typing. Instead you see the logical structure of the document. LaTeX takes care of the formatting for you.

The LaTeX document is a plain text file containing the content of the document, with additional markup. When the source file is processed by the macro package, it can produce documents in several formats. LaTeX supports natively DVI and PDF, but using other software you can easily create PostScript, PNG, JPG, etc.

Skills needed

LaTeX is a very easy system to learn, and requires no specialist knowledge, although literacy and some familiarity with the publishing process is useful. It is, however, assumed that you are completely fluent and familiar with using your computer before you start. Specifically, effective use of this document requires that you already know and understand the following very thoroughly:

  • how to use a good plain-text editor (not a wordprocessor like OpenOffice, WordPerfect, or MicrosoftWord); [2.1.3]
  • where to find all 95 of the printable ASCII characters on your keyboard and what they mean, and how to type accents and symbols, if you use them; [3.2.1.2]
  • how to create, open, save, close, rename, move, and delete files and folders (directories); [2.3]
  • how to use a Web browser and/or File Transfer Protocol (FTP) program to download and save files from the Internet; [7.3.1.6]
  • how to uncompress and unwrap (unzip or detar) downloaded files. [2.3.7]

If you don't know how to do these things yet, it's important to go and learn them first. Trying to become familiar with the fundamentals of using a computer at the same time as learning LaTeX is not likely to be as effective as doing them in order. These are not specialist skills, they are all included in the European Computer Driving Licence (ECDL) and the relevant sections of the ECDL syllabus are noted in the square brackets above, so they are well within the capability of anyone who uses a computer.

Prerequisites

At a minimum, you'll need the following programs to edit LaTeX:

  • An editor (You can use a basic text editor like notepad, but a dedicated LaTeX editor will be more useful).
    • On Windows, TeXnicCenter([2]) is a popular free and open source LaTeX editor.
    • On Unix-like (including Mac OS X) systems, Emacsen and gvim provide powerful TeX enviroments for the tech-savvy, while Texmaker [3] and Kile [4] provide more user-friendly development environments.
  • The LaTeX binaries and style sheets - e.g. MiKTeX [5] for Windows, teTeX [6] for Unix/Linux and teTeX for Mac OS X [7].
  • A DVI viewer to view and print the final result. Usually, a DVI viewer is included in the editor or is available with the binary distribution.

A distribution of LaTeX, with many packages, add-ins, editors and viewers for Unix, Linux, Mac and Windows can be obtained from the TeX users group at http://www.tug.org/texlive/.

Applications within a distribution

Here are the main programs you expect to find in any (La)TeX distribution:

  • tex: the simplest compiler: generates DVI from TeX source
  • pdftex: generates PDF from TeX source
  • latex: generates DVI from LaTeX source (the most used one)
  • pdflatex: generates PDF from LaTeX source
  • dvi2ps: converts DVI to PostScript
  • dvipdf: converts DVI to PDF
  • dvipdfm: an improved version of dvipdf

When LaTeX was created, the only format it could create was DVI; then the PDF support was added by pdflatex, even if several people still don't use it. As it is clear from this short list, PDF files can be created with both pdflatex and dvipdfm; anyway, the output of pdflatex is much better than the other. DVI is an old format, and it does not support hyperlinks for example, while PDF does, so passing through DVI you will bring all the bad points of that format to PDF. Moreover the general output will be better using only pdflatex.

Strictly speaking, you would write your document slightly differently depending on the compiler you are using (latex or pdflatex). But as we will see later, it is possible to add a sort of abstraction layer, to hide the details of which compiler you're using, and the compiler will handle the translation itself.

Note that, since LaTeX is just a collection of macros for TeX, if you compile a plain TeX document with a LaTeX compiler (such as pdflatex) it will work, while the opposite is not true: if you try to compile a LaTeX source with a TeX compiler you will get only a lot of errors.

The following diagram shows the relationships between the (La)TeX source code and all the formats you can create from it:

The boxed red text represents the file formats, the blue text on the arrows represents the commands you have to use, the small dark green text under the boxes represents the image formats that are supported. Any time you pass through an arrow you lose some information, which might decrease the quality of your document. Therefore, in order to achieve the highest quality in your output file, you should choose the shortest route to reach your target format. This is probably the most convenient way to obtain an output in your desired format anyway. Starting from a LaTeX source, the best way is to use only latex for a DVI output or pdflatex for a PDF output, converting to PostScript only when it is necessary to print the document.

Most of the programs should be already within your LaTeX distribution; the others come with Ghostscript, which is a free and multi-platform software as well.

Template:Latex/Navigation Start