LaTeX/Introduction : Différence entre versions
m (→Which encoding system should I use : XeTex) |
(→Which encoding system should I use : Unicode) |
||
| Ligne 222 : | Ligne 222 : | ||
That's the reason why you must abandon the Latin 1 or ISO8859-1 system and move to UNICODE or UTF8 characters. It is the only way to mix Chinese, Arabic, Russian and French for example. | That's the reason why you must abandon the Latin 1 or ISO8859-1 system and move to UNICODE or UTF8 characters. It is the only way to mix Chinese, Arabic, Russian and French for example. | ||
| − | Only XeTeX and LuaTeX are able to use easily unicode characters with the fontspec package (see mirrors.ctan.org/macros/latex/contrib/fontspec/fontspec.pdf of February 2011). You have or will have to move to XeTeX (see [http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/]) or LuaTeX in a near future. | + | All 3 operating systems moved to Unicode around 2001, at least internally, but inertia of users, particularly of Asian users (Japan as well as China), is postponing its wide spread. On Unix machines (Linux and OS/X) it is easy to manipulate text files in Unicode, on Windows using unicode characters on the command line is sometimes problematics. That the reason why a file should still avoid accented roman characters mixed with chinese characters and white spaces in its description name. |
| + | |||
| + | Sending TeX/LaTeX text files in mails (not only as a separate attached file) is not a problem if you use unicode character encoding (UTF-8 for example). | ||
| + | |||
| + | Only XeTeX and LuaTeX are able to use easily unicode characters with the fontspec (or more recent xltxtra) package (see http://mirrors.ctan.org/macros/latex/contrib/fontspec/fontspec.pdf document of February 2011). You have or will have to move to XeTeX (see [http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/]) or LuaTeX in a near future. | ||
| + | |||
| + | Modern TeX editors like TeXworks or Emacs are able to mix unicode characters, even on WIndows. | ||
== Which packages or classes should I use?== | == Which packages or classes should I use?== | ||
Version du 27 mai 2011 à 05:31
Sommaire
- 1 What is TeX?
- 2 Four TeX engines
- 3 Which TeX engine should I choose?
- 4 Which "format" should I used for my preferred TeX engine?: LaTeX
- 5 Which "fonts" should I use for my preferred TeX engine? it depends on the languages used
- 6 Which encoding system should I use
- 7 Which packages or classes should I use?
- 8 What is LaTeX?
- 9 Installing a distribution
- 10 Getting a text editor
What is TeX?
TeX (Tau Epsilon Chi) is a low-level markup and programming language created by Donald Knuth to typeset documents attractively and consistently.
Knuth started writing the TeX typesetting engine in 1977 for the second edition of his main book "The art of computer programming". He wanted 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.
TeX is a programming language, in the sense that it supports the if-else construct, you can make calculations with it (that 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. TeX is renowned for being extremely stable, for running on many different kinds of computers, and for being virtually bug free.
Nowadays when producing documents in the TeX language, only old documents are using plain TeX. Instead, different TeX distributions such as LaTeX are used to help author structuring their text while saving time, automating certain tasks and reducing user introduced errors.
TeX is the work of a single man, is free, have had a fixed number of bugs. See Wikipedia:en:Knuth_reward_check to understand how D. Knuth improved the quality of TeX by rewarding 256 cents at start (1 hexadecimal US dollar) and doubling every year for each new bug, until it reached 32768 cents. It is interesting to note that the current version number of TeX is 3.1415926 . Guess the next one if any.
To understand the humour of Donald Knuth but also to realize how the world has changed since the late 70's in relation to computer sciences, publishing, collaborative work, pricing, you are invited to listen to the presentation of his new iTeX product at the 32nd TeX User Group in 2010 at Stanford University [1], where Steve Jobs was also invited in 2005 for a commencement talk [2] . The comparison is done because Knuth himself compares his iTeX' talk (using acetate overhead transparencies) with the recent high quality of Steve Jobs presentations (presentations secrets). You will see that even within the audience of TeX users, many people aren't understanding Knuth's jokes.
You can also read interviews in 2001 at Stanford again [3] or in 2002 at the Technische Universität München [4] . He agreed on the fact that scientists would recognize computer science as a mature discipline only when it had 1,000 deep algorithms, but he think that the discipline is halfway there.
In order to typeset characters, D. Knuth also created METAFONT (1979, revised in 1984) which was the first attempt to draw characters with a computer but with the same art that linotype font designers, like Hermann Zapf, used. The characteristics of Metafont is that all of the shapes of the glyphs are defined with geometrical equations, e.g., one can define a given point to be the intersection of a line segment and a Bézier cubic.
Also, D. Knuth pioneered the idea of literate programming [5] where your algorithm and its documentation are written within the same document. Two compilers tangle and weave will compile the same document and produce two outputs: (a) a Pascal program (yet a C program with web2c) and (b) a documentation (in TeX of course).
The web source of TeX can be accessed at http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web . Applying the weave program by the command:
$ weave tex.webtex.tex
$ pdftex tex.texYou can have a look at the weaved and texed source of TeX at http://ctan.binkerton.com/systems/unix/tex-gpc/tex.pdf A particular attention may be paid to the quality but also the complexity of the index.
Literate programming hasn't been adopted by the entire world and most of programs do not mix documentation and code: code must be clear enough to let you understand the algorithm.
Some people (http://rw4.cs.uni-sb.de/~heckmann/papers/neuform.ps.gz) tried to understand the functional description of TeX'formula layout described in Knuth's web document, but the authors themselves are still not sure that what they describe in their article is what TeX is doing...
The Literate Programming concept is not over and Sweave is a nice way to incorporate some R (the ancestor of R was named S) code within your LaTeX document.
Four TeX engines
TeX82 or tex
TeX82, the first TeX engine, was only able to read ASCII characters and did run only on mainframes like thePDP-10 (36 bits) at Stanford or IBM (32 bits) at the Faculty of Orsay, and then on Vax machines. TeX evolved and has been ported to PC (16 bits) with a commercial very efficient product PCTeX and, in 1990, the first Public Domain distribution of TeX and LaTeX has been built by the French Gutenberg association (see http://www.tug.org/TUGboat/tb11-1/tb27brouard.pdf). Despite efforts to make TeX able to read accented characters, the standard TeX engine produce a DVI (device independent) format which is based only on single byte (ASCII) characters even if the fonts used can display any character. A standard DVI file even transformed to PDF (with dvipdf) is therefore unsearchable for accented characters. For example, you can search for Jacques Vallin in the previous PDF document but you can't search (neither copy and paste correctly) for his sentence
- Éberluée, décontenancée, hébétée, défaite de toute sérénité devant cet abécédaire décapité, étêté, évidé, émasculé, désagrégé, débilité, dégénéré, parce que privé de lettres accentuées et correctement orthographiées, Thérèse-Éléonore a décrété avec sincérité et opiniâtreté l'immortalité des çàçâcécècêcëcïçôçöçùçûçü
which emphasized the importance of typing accented characters like "é" directly on French keyboards instead of typing using the TeX way "\'e" (see also http://cahiers.gutenberg.eu.org/cg-bin/article/CG_1989___3_48_0.pdf). During the Cork conference, the type T1 fonts were created and most Western diacritics characters can be searched (see below on fontenc)?
pdfTeX
pdfTeX is currently the default TeX engine. It incorporates all the previous modifications of other side TeX engines, like mlTeX (multilingual TeX was able to hyphenate words containing accented characters) as well as eTeX and encTeX. It is also compatible whith original TeX82 engine and produces by default standard DVI. But its main advantage, as suggested by its name, is that it can produce a PDF output file.
If you use outline fonts like Type 1 font files (.pfa and .pfb), TrueType fonts (.ttf) or OpenType fonts (.otf), your output PDF file would be searchable for accented characters. If you use OT1 fonts and Computer Modern bitmap pk fonts, the PDF will have the pk font embedded and your accented characters won't be searchable. Thus, the outline (vector) fonts are to be preferred over bitmap pk fonts. For Western languages, Type 1 fonts are used.
PDF is not only the most common format for formatted texts but can also include images and figures. pdfTeX can include pdf figures made by other softwares too.
For inclusion of PostScript figures, using older tex packages such as PSTricks, you need to output a dvi first and then convert your dvi to pdf using dvips and pstodf.
If you want to make graphics made by TeX (or LaTeX) itself, your are invited to use modern packages such as PGF/TikZ.
In many occasions you will use external softwares to produce your figures and you will export them to PDF file (or eps files to be converted with epstopdf) in order to incorporate them into your LaTeX source.
If your text uses mathematics, your figures will also use the same mathematics in the legends and you have a problem with most softwares.
But more and more softwares can export your graph or figure, like Geogebra and Gnuplot (latest Gnuplot release) to Tikz tex source.
Other graphics softwares offer direct visualization of mathematics by compiling (in the background) the LaTeX source included in legends or labels, like Inkscape or the recent IPE 7. A distinction has to be made between softwares which allow cross referencing like Inkscape or xfig and those which don't like IPE. Cross referencing means, for example, that your legend quotes a numbered equation (like \ref{eq:lotka-renewal}) but its number is known only at last LaTeX compilation, and must be the same in the text and in the graph.
Another advantage of pdfTeX is that you can incorporate hypertext links using packages such as hyperref for your presentation (Beamer) and bibliography at least.
XeTeX
With the XeTeX engine project which started in 2004, TeX is now able to manage any Unicode character and not only western accented characters and to process right to left characters. If the final output format is PDF, the intermediate format, .xdv, is an extended DVI format which can be transformed to PDF whith xdvipdfxm. XeTeX might be preferred to pdfTeX for non English languages. It is installed by default in any TeXLive distribution and can be used at the price of a change concerning font encoding and input encoding.
LuaTeX
More recently a TeX engine, named LuaTeX lets you use any font and not only TeX fonts and simplify the use of any language with a single fontenc package (see a recent document of December 2010 http://ctan.mines-albi.fr/info/luatex/lualatex-doc/lualatex-doc.pdf which promotes LuaTeX). A stable version of LuaTeX will be announced for late 2012.
Which TeX engine should I choose?
Most of TeX distributions on any of the main three OS (Windows, MaC OS/X and Linux) are offering the 4 four main TeX engines. Most of the editors let you choose the TeX engine of your choice. If you are writing in English only, your choice will probably be pdfTeX until XeTeX or LuaTeX offers the same functionality and stability.
In order to let you know which TeX engine you are using for a text, some editors are recognizing the comments that are on top of the text. For example TeXShop (or newer TeWworks) lets you include:
% These lines tell TeXShop to typeset with xelatex, and to open and % save the source with Unicode encoding. %!TEX TS-program = xelatex %!TEX encoding = UTF-8 Unicode \documentclass[11pt]{article}
For another kind of editor, the emacs family, it is different (but compatible with other languages):
%%% Local Variables: %%% mode: LaTeX %%% TeX-engine: xetex %%% fill-column: 99999 %%% coding: utf-8-unix %%% LaTeX-command: "latex -shell-escape" %%% TeX-command-default: "XeLaTeX5E" %%% End: \documentclass[11pt]{article}
Fortunately, if you include both in your text, emacs mode first and texworks as second, it may work for both kinds of editors.
Which "format" should I used for my preferred TeX engine?: LaTeX
AMSTeX as well as LaTeX and ConTeXt are formats. Based on TeX, most of TeX basic commands will work but the different formats are in fact very different dialects which are supposed to improve and facilitate the use of scientific writing. Also the most recent dialect, ConTeXt, is too recent to be fully operational but it is more and more presented as a serious competitor of LaTeX.
Formats created by tex -ini usually correspond to different TeX dialects
A format is the result of a set of macros which are dumped into a compact file with the extension .fmt like latex.fmt, amstex.fmt etc. They are output by a TeX engine command using a special option -ini and a \dump tex order. For example, in order to create the format amstex.fmt the command is:
$ tex -ini
\input plain
\input amstex
\dumpWith this example, it is easy to understand that the TeX engine tex will: (a) read the file plain.tex which contains the basic TeX macros from the TeXBook, (b) read the specific amstex.tex macros from the American Mathematical Society which improved TeX with many more macros and (c) will finally dump all the macros into a binary and compact file which will be renamed amstex.fmt .
Next time, in order to use AMSTeX, the TeX engine command will use the ampersand ('&') character (or the option --fmt= with recent TeX engines) to directly load the format file amstex.fmt, and thus
$ amstex my_amslatexfile.texis similar to:
$ tex &amstex my_amslatexfile.tex
or
$ tex --fmt=amstex my_amslatexfile.tex
It is exactly the same thing for LaTeX and you will find a file named latex.fmt on your TeX distribution tree as well as many other formats for other TeX dialects.
pdflatex is not another engine but correspond to the LaTeX format used by the pdftex engine
pdflatex my_latex_text.tex
pdftex --fmt=latex.fmt --output-format=pdf my_latex_text.tex
For other TeX engines, like LuaTeX, you can find other formats like lualatex.fmt and its associated name LuaLaTeX: again it is not another TeX engine but a LaTeX format for the LuaTeX engine.
If you can build different LaTeX formats corresponding, for example, for different hyphenation patterns, usually different formats corresponds to different family of macros or different TeX dialects.
How different are these dialects and how can I recognize the dialect.
Here are three dialects for a simple example starting with a Plain TeX document which can be recognized by the \input commands and the \bye at the end.
%% Plain TeX file \input tikz.tex \baselineskip=12pt \hsize=6.3truein \vsize=8.7truein We are working on \tikzpicture \draw (-1.5,0) -- (1.5,0); \draw (0,-1.5) -- (0,1.5); \endtikzpicture. \bye
For TeX the default command tex example-tex.tex is pdftex example-tex.tex and the output is a PDF file example-tex.pdf.
The same output can be generated in LaTeX with the following file:
%% LaTeX file \documentclass{article} % say \usepackage{tikz} \begin{document} We are working on \begin{tikzpicture} \draw (-1.5,0) -- (1.5,0); \draw (0,-1.5) -- (0,1.5); \end{tikzpicture}. \end{document}
For LaTeX the default command latex example-latex.tex is pdftex &latex example-latex.tex and the output is a PDF file example-latex.pdf.
If you want to start using Context, you will use the following code:
%% ConTeXt file \usemodule[tikz] \starttext We are working on \starttikzpicture \draw (-1.5,0) -- (1.5,0); \draw (0,-1.5) -- (0,1.5); \stoptikzpicture. \stoptext
For ConTeXt, the default format is named cont-en.fmt and the TeX engine is luatex even if the command to compile is context example-context.tex and the default output is a PDF file example-context.pdf
Which "fonts" should I use for my preferred TeX engine? it depends on the languages used
Even if you are not interested in the design and shape of your text, but just in its content, you are still concerned by fonts. This is a pity but this is your concern if you write in any other language than English.
English is mostly concern by ASCII characters, but other languages may have accented characters (sometimes with many levels like in Vietnamese), have glyphs, may have different shapes when used at start of a word, in the middle of a word or at the end (Arabic). Here is a succession of the two arabic letters mim and jim: "mim-jim-mim-jim" "mim-jim" "mim" "jim" and ou can see the various shapes (to be read from right to left):
مجمج مج م جTeX was originally only able to treat ASCII characters, words with accented characters, even if entered in the escaped mode like \'e for an e-acute, could not be hyphenated correctly. The way how TeX constructs a sentence consists in computing its length and height from the metrics of all characters used in the sentence. The metrics of all glyphs are kept into TFM (TeX Font metrics) files for the font used. The output of a TeX text is a DVI file with all the metrics included but not the characters themselves which be loaded only at print time or when displayed on a screen.
Computer modern or OT1 fonts
Donald Knuth created around 1978 the so-called Computer Modern fonts (CM fonts or OT1) which make the look of TeX documents so special and easily recognizable. The memory of the first mainframes was tiny and for example, the glyphs <, >, \, {, and } are only available in the typewriter fonts and the $ and £ signs share the same position (in different font shapes). Typing a < in a document can yield ‘¿’ depending on the current font used. The OT1 fonts (O for old, T for text, 1 for Western languages) contain only 128 characters.
With the availability of 8 bits characters (ISO8859-1 or Latin 1) in mid 80's, Tex Users designed during the Cork Tug conference the T1 fonts which includes most of Western accented characters (including the French `œ' which had been suppressed from earlier version of 8 bits characters by a non-French speaking Belgian replacing the French representative at the ISO conference). The French `œ' has been included lately in the ISO-8859-15 character set (2001). The OT2 as well as T2 are for the cyrillic characters (see [6] for example). But you can't mix both characters in a text without indicating that you are changing the font. This is no more true with Unicode characters and XeTeX or LuaTeX.
PostScript Type 1 font
Adobe launched PostScript Type 1 fonts in 1984 which have been used by the first Apple Laser Writer (see [7]) in 1985. But its specifications were proprietary.
True Type font
In order to have scalable characters on their screen display and not rastered or bitmap images, Apple, Microsoft and IBM invented the True Type Font. The font instances contain both screen and printer font data in a single component. They can theoretically contain 65000 Unicode characters but usually contain less that 220 which is very poor for other languages than Western languages.
Adobe reacted by publishing PostScript Type 1 specifications in 1991. Other printers adopted it. At the end of the 1990's, Adobe PostScript Type 1 fonts have been incorporated in Windows 2000, XP etc and MaC OS/X. Both fonts, PostScript Type 1 (the de facto standard in publishing companies) as well as True Type Font were living together.
Open Type font
The OpenType font format was jointly developed by Adobe and Microsoft to combine the best features of the TrueType and PostScript Type 1 technologies. It was first presented in 1996 and its use and support has been steadily increasing since about 2000.
OpenType fonts contain both the screen and printer font data in a single component. The OpenType format can contain either TrueType or PostScript font data. It supports expanded character sets (up to 65.000) and special typographic features. Tese may include various versions of figures (tabular, old-style, lining), small caps, ligatures, ordinals, and other extras. While OpenType allows type designers to build complex fonts, not many fonts take advantage of these possibilities. Most OpenType fonts available today are simply converted PostScript fonts, limited to 220 characters in a set.
OpenType fonts are platform independent and can thus be used on all operating systems.
Which encoding system should I use
Life was easier when ASCII (American Standard Code for Information Interchange) was alone on the market. But it has never been alone, even with the former IBM EBCDIC coding, accented characters could be used but never simultaneously. For example the left brace { was used for the e-acute. Today, with 8 bits characters, you can mix brace with accented characters in a text without the need of escape sequences. The most common encoding system in Western countries is called ISO-8859-15. But, with 8 bits characters only, you can't mix Western and Eastern european characters without escape sequences. And in order to code Chinese you need up to 4 bytes of 8 characters.
That's the reason why you must abandon the Latin 1 or ISO8859-1 system and move to UNICODE or UTF8 characters. It is the only way to mix Chinese, Arabic, Russian and French for example.
All 3 operating systems moved to Unicode around 2001, at least internally, but inertia of users, particularly of Asian users (Japan as well as China), is postponing its wide spread. On Unix machines (Linux and OS/X) it is easy to manipulate text files in Unicode, on Windows using unicode characters on the command line is sometimes problematics. That the reason why a file should still avoid accented roman characters mixed with chinese characters and white spaces in its description name.
Sending TeX/LaTeX text files in mails (not only as a separate attached file) is not a problem if you use unicode character encoding (UTF-8 for example).
Only XeTeX and LuaTeX are able to use easily unicode characters with the fontspec (or more recent xltxtra) package (see http://mirrors.ctan.org/macros/latex/contrib/fontspec/fontspec.pdf document of February 2011). You have or will have to move to XeTeX (see [8]) or LuaTeX in a near future.
Modern TeX editors like TeXworks or Emacs are able to mix unicode characters, even on WIndows.
Which packages or classes should I use?
Once you choose LaTeX (and a TeX engine of your choice to compile your source text), you have to make a choice within the classes offered by LaTeX, depending on the class of your text: a book, a report, an article, a presentation, you will alter the first line of your document with a command such as \documentclass{article} for an article. If you use a figure using PGF/Tikz TeX code, you need a second command \usepackage{pgf,tikz} .
A class, is simply another set of macros. Most of times a class can have options, like \documentclass[12pt]{report} which means that the document will be printed in12pt instead of the default 10pt.
A package is also a set of macros. Even if computers are 10,000 more powerful than when running on DOS in the mid 80's, they are still very limited in speed and memory management and you can't load all the macros of the CTAN TeX public Library. That the main reason of using packages.
Sometimes, even when loading a package like xy (for drawing diagrams) you will get memory limitations of LaTeX and you will need other package like the etex package which will modify how LaTeX allocates registers to use the recent e-TeX feature. The command-line switch -enable-etex exists on any new TeX engine and is set by default, but it only makes the extension available: it does not change how LaTeX actually works and you need to load the package explicitly:
\usepackage{etex} \usepackage[all]{xy}
It can be even worse: sometimes some packages have to be loaded before other packages and sometimes some packages are conflicting. You will have to find a solution on yourself or by googling.
If it is normal to be confused with all these notions which are the heritage of a 30 years history of TeX and LaTeX. A newer product, ConTeXt is very promising but hasn't reached a stable situation and can't compete with LaTeX yet.
But if you read until here, now you need to use your own laptop, choose a distribution (see below), an editor (see below) and once you are ready, you can write you first document in LaTeX.
If this is the first time you are trying out LaTeX, you don't even need to install anything. Just go to:
and continue this tutorial in the next chapter. ScribTeX is a web based online editor for LaTeX documents with collaboration capabilities allowing you to experiment with LaTeX syntax without having to bother with installing and configuring a distribution and an editor. When you later feel that you would benefit from having a standalone LaTeX installation, you can return to this chapter and follow the instructions below.
What is LaTeX?
LaTeX (pronounced either "Lah-tech" or "Lay-tech") is a macro package based on TeX created by Leslie Lamport in 1985. Its purpose is to write scientific documents like presentation (beamer class), article (article class), report or entire book or thesis. It can also typeset music scores even more appropriate tools exist today.
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.
This approach has some disadvantages in comparison with a WYSIWYG (What You See Is What You Get) program such as Openoffice Writer or Microsoft Word.
In LaTeX:
- The compiled (final) version of the document is on a different window that the editor window .
- You generally need to remember the necessary commands for LaTeX markup.
- It can sometimes be difficult to obtain a certain look for the document.
On the other hand, there are certain advantages to the LaTeX approach:
- Document sources can be read with any text editor and understood, unlike the complex binary and XML formats used with WYSIWYG programs.
- You can concentrate purely on the structure and contents of the document, not get caught up with superficial layout issues.
- You don't need to manually adjust fonts, text sizes, line heights nor text flow for readability, as LaTeX takes care of them automatically.
- In LaTeX the document stucture is visible to the user, and can be easily copied to another document. In WYSIWYG applications it is often not obvious how a certain formatting was produced, and it might be impossible to copy it directly for use in another document.
- The layout, fonts, tables and so on are consistent throughout the document.
- Mathematical formulae can be easily typeset.
- Indexes, footnotes, citations and references are generated easily.
- You are forced to structure your documents correctly.
The LaTeX-like approach can be called WYSIWYM, i.e. What You See Is What You Mean: you can't see what 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 natively supports DVI and PDF, but by using other software you can easily create PostScript, PNG, JPG, etc.
Installing a distribution
If you want to use LaTeX locally on your computer, you generally need to install a TeX distribution. TeX distributions are packaged collections of packages and programs that enable you to typeset without having to manually fetch files and configure things. The recommended distributions for each of the major operating systems are (documentation on installation can be accessed from [9]):
- TeX Live is a major TeX distribution for Unix/Linux, Mac OS and Windows.
- MiKTeX is a very classical Windows-specific distribution which is still competitive in comparison to the growing and very active TeXLive distribution.
- MacTeX is a Mac OS-specific distribution based on TeX Live.
Windows
TeX live and MikTeX have easy installers that take care of setting up the environment and downloading packages.
Mac OS
- Download MacTeX.mpkg.zip on the MacTeX page, unzip it and follow the instructions.
Linux
TeX and LaTeX being used by the Linux OS for documentations and info files, at least a minimum installation of TeX and LaTeX is implemented by default on Linux distribution.
If your distribution does not have the TeX Live packages, you will need to download TeX Live yourself and run the installer by hand. From the TuG site you can get access to latest version of any software or package or macro.
Getting a text editor
You will also need a text editor to write LaTeX code. You should use a text editor (i.e. Notepad or wordpad), not a word processor (Word, Openoffice). Dedicated LaTeX editors are more useful than a plain text editors, because they usually have autocompletion of commands, spell and error checking and handy macros.
Editors that you can find on any of the three OS
TeXworks
TeXworks is a dedicated TeX editor that is included in TeXLive2010 as well as in other distribution. It was developed with the idea that a simple interface is better than a cluttered one, and thus to make it easier for people in their early days with LaTeX to get to what they want to do: write their documents. TeXworks originally came about precisely because a math professor wanted his students to have a better initial experience with LaTeX.
TeXworks on OS/X
In fact TeXworks is very similar to TeXShop which was very successful on MaC OS/X but is no more maintained and replaced by TeXworks.
TeXworks is developing very rapidly but latest version is not fully operational on Mac OS/X. For example, spell checking is not installed by default when installing TeXworks 0.4 and you can easily make it working. The spell checker hunspell used by TeXworks is also installed by default with OS/X Snow Leopard. It is also used by OpenOffice by default (hunspell is the successor of Myspell). And thus, in order to install the dictionaries for TeXworks, you must install, for each language, two files: the .aff and .dic files or just link them symbolically from the OpenOffice dictionary directory to your TeXworks home directory:
$ ln -s /Applications/OpenOffice.org.app/Contents/share/extensions/dict-en/en_US.aff ~/Library/TeXworks/dictionaries $ ln -s /Applications/OpenOffice.org.app/Contents/share/extensions/dict-en/en_US.dic ~/Library/TeXworks/dictionaries
You can also add these files to their standard place (it seems that TexWorks doesn't use the standard place) for any other application using hunspell for spelling:
$ ln -s /Applications/OpenOffice.org.app/Contents/share/extensions/dict-en/en_US.aff ~/Library/Spelling $ ln -s /Applications/OpenOffice.org.app/Contents/share/extensions/dict-en/en_US.dic ~/Library/Spelling
One advantage of TeXworks on some other editors is that it can use the newer --synctex option of modern TeX engines in order to, while pointing the mouse on a line of the PDF output file, right click and choose sync to source. And the editor will sync to the corresponding input line. It is sometimes quicker than to search manually.
Emacs
Emacs is a general purpose text processing system. When used in combination with Auctex and Reftex (extensions that may be installed into the Emacs program), Emacs provides a complete LaTeX editing environment complete with table of contents view, document preview and many other features. Emacs is a very mature editing system with a unique set of keyboard commands. SyncTeX lets you synchronize your pointer from the PDF file to the source LaTeX file. On MaC OS/X, Aquamacs is probably the unique Emacs editor for French keyboards and the pdf previewer, Skim, lets you synchronize automatically.
One of many satirical expansions of the acronym EMACS is "Escape Meta Alt Control Shift" meaning that you can do everything with your fingers on a keyboard without using the mouse. It was and is still true but now you can do everything with a mouse and icons.
The advantage of a general purpose editor is that you can simultaneously have your LaTeX source in one buffer, your R source code in another, your SAS code in a third while gnuplot source is in a fourth window.
On Emacs, instead of having the tex source only, you can ask Emacs to locally compile a region or an equation, and to produce an image (png) of your selection (like this wiki is doing). The image is then included in place of your source code. It is very impressive but not very useful on fast computers and large screens in comparison to the -synctex=1 feature.
LyX, almost a WYSIWYG
LyX is a popular LaTeX editor for Windows, Linux and Mac OS. It contains formula and table editors and shows visual clues of the final document on the screen enabling users to write LaTeX documents without worrying about the actual syntax.
Other TeX editors
TeXnicCenter
TeXnicCenter is a popular free and open source LaTeX editor for Windows. It also has a similar user interface to TeXmaker and Kile.
BaKoMa TeX
BaKoMa TeX is a editor for Windows with WYSIWYG-like features. It takes care of compiling the LaTeX source and updating it constantly to view changes to document almost in real time.
TeXShop
TeXShop is a TeXworks-like editor for Mac OS.
gedit-latex-plugin
Gedit with gedit-latex-plugin is also worth trying out for users of GNOME. GEdit is a cross-platform application for Windows, Mac, and Linux
Gummi
Gummi is a LaTeX editor for Linux, which compiles the output of pdflatex in realtime and shows it on the right half of the screen.
Kile
Kile is a LaTeX editor for KDE (cross platform), providing a powerful GUI for editing multiple documents and compiling them with many different TeX compilers. Kile is based on Kate editor, has a quick access toolbar for symbols, document structure viewer, a console and customizable build options. Kile can be run in all operating systems that can run KDE.
TeXmaker
TeXmaker is a cross-platform editor very similar to Kile in features and user interface. In addition it has its own PDF viewer.
LaTeXila
LaTeXila is another text editor for Linux (Gnome).
Viewers
Finally, you will need a viewer for the files LaTeX outputs. Normally LaTeX saves the final document as a .dvi (Device independent file format), but you will rarely want it to. DVI files do not contain embedded fonts and many document viewers are unable to open them.
Usually you will use a LaTeX compiler like pdflatex to produce a PDF file directly, or a tool like dvi2pdf to convert the DVI file to PDF format. Then you can view the result with your preferred PDF viewer (Adobe Reader, Okular, Evince, Sumatra, Foxit).
Practically all LaTeX distributions have a DVI viewer for viewing the default output of latex, and also tools such as dvi2pdf for converting the result automatically to PDF and PS formats.
Applications within a distribution
Here are the main programs you expect to find in any LaTeX distribution:
- latex compiler reads a LaTeX .tex file and creates a .dvi
- pdflatex compiler reads a LaTeX .tex file and creates a .pdf
- dvi2ps converts the .dvi file to .ps (postscript).
- dvi2pdf converts the .dvi file to .pdf (dvi2pdfm is an improved version).
Also tex and pdftex compilers are included, but you shouldn't use them, because they support only plain TeX. 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 many errors.
When LaTeX was created, the only format it could create was DVI; later PDF support was added by pdflatex. PDF files can be created with both pdflatex and dvipdfm. The output of pdflatex takes direct advantage of modern features of PDF such as hyperlinks and embedded fonts, which are not part of DVI. Passing through DVI imposes limitations of its older format. On the other hand, some packages, such as PSTricks, exploit the process of conversion to DVI, and therefore will not work with pdflatex. Some of those packages embed information in the DVI that doesn't appear when the DVI is viewed, but reemerges when the DVI is converted to another, newer format.
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, while the compiler can handle the translation itself.
The following diagram shows the relationships between the LaTeX source code and 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 Wikipedia:en:Ghostscript, which is a free and multi-platform software as well.
Chapter Wikibooks:en:LaTeX/Export_To_Other_Formats discusses more about exporting LaTeX source to other file formats.