




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 1 of 12
Go Back
Full Screen
Close
Indian T E
X Users Group URL: http://www.river-valley.com/tug
On-line Tutorial on LATEX
The Tutorial Team Indian TEX Users Group, sjp Buildings, Cotton Hills Trivandrum 695014 , india 2000
Prof. (Dr.) K. S. S. Nambooripad, Director, Center for Mathematical Sciences, Trivandrum, (Editor) ; Dr. E. Krishnan, Reader in Mathematics, University College, Trivandrum ; T. Rishi, Focal Image (India) Pvt. Ltd., Trivandrum ; L. A. Ajith, Focal Image (India) Pvt. Ltd., Trivandrum ; A. M. Shan, Focal Image (India) Pvt. Ltd., Trivandrum ; C. V. Radhakrishnan, River Valley Technologies, Software Technology Park, Trivandrum constitute the TUG India Tutorial team
This document is generated from LATEX sources compiled with pdfLATEX v. 14e in an INTEL Pentium III 700 MH z system running Linux kernel version 2.2.14-12. The packages used are hyperref.sty and pdfscreen.sty
©^ c 2000, Indian TEX Users Group. This document may be distributed under the terms of the LATEX Project Public License, as described in lppl.txt in the base LATEX distribution, either version 1.0 or, at your option, any later version
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 2 of 12
Go Back
Full Screen
Close
Gentle Reader,
Generation of letter forms by mathematical means was first tried in the fifteenth century; it became popular in the sixteenth and seventeenth centuries; and it was abandoned (for good reasons) during the eighteenth century. Perhaps the twentieth century will turn out to be the right time for this idea to make a comeback, now that mathematics has advanced and computers are able to do the calculations.
Modern printing equipment based on raster lines—in which metal “type” has been replaced by purely combinatorial patterns of zeroes and ones that specify the desired position of ink in a discrete way—makes mathematics and computer science increasingly relevant to printing. We now have the ability to give a completely precise definition of letter shapes that will produce essentially equivalent results on all raster-based machines. Moreover, the shapes can be defined in terms of variable parameters; computers can “draw” new fonts of characters in seconds, making it possible for designers to perform valuable experiments that were previously unthinkable.
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 4 of 12
Go Back
Full Screen
Close
Documents created with such specific markup became difficult for typesetting sys- tems to cope up. A movement was started to create a standard markup language, which all typesetting vendors would be persuaded to accept as input. Thus came the Generic Markup Language (gml) which later on developed into Standard Gen- eralized Markup Language (sgml) and now a subset of which known as Extensible Markup Language (xml) is poised to take up the World Wide Web.
However, the development of sgml moved towards representing the documents in an exchangeable format aiming at ‘publishing in its broadest sense, ranging from single medium conventional publishing to multimedia data base publishing’. sgml can also be used in office document processing when the benefits of human readability and interchange with publishing systems as required. It is a meta- language for defining infinite variety of markup languages and is not concerned with the formatting of marked-up documents., i.e. , there is no layout tags.
This void is filled by the advent of TEX which combines the balance of generic markup and layout specific support. The class file mechanism followed in LATEX makes it possible to produce the same source document in different layouts, while enough bells and whistles are available to fine-tune important documents for pro- ducing the highest quality.
1.2. A Short History of TEX
Donald E. Knuth
TEX (= tau epsilon chi, and pronounced similar to ‘tech’) is a computer language de- signed by Donald Erwin Knuth of Stanford University, for use in typesetting; in par- ticular, for typesetting math and other technical (from Greek ‘techne’ = art/craft, the stem of ‘technology’) material.
In the late 1970s, Donald Knuth was revising the second volume of his multi- volume opus, The Art of Computer Programming , got the galleys, looked at them,
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 5 of 12
Go Back
Full Screen
Close
and said (approximately) ‘bleccch’! he had just received his first samples of the new computer typesetting, and its quality was so far below that of the first edition of Volume 2 that he couldn’t stand it. He thought for awhile, and said (approxi- mately), “I’m a computer scientist; I ought to be able to do something about this”, so he set out to learn what were the traditional rules for typesetting math, what constituted good typography, and (because the fonts of symbols that he needed really didn’t exist) as much as he could about type design. He figured this would take about 6 months. (Ultimately, it took nearly 10 years, but along the way he had lots of help from some people who should be well known to readers of this list – Hermann Zapf, Chuck Bigelow, Kris Holmes, Matthew Carter and Richard Southall are acknowledged in the introduction to Volume E, Computer Modern Typefaces , of the Addison-Wesley Computers & Typesetting book series.)
A year or so after he started, Knuth was invited by the American Mathematical Society (ams) to present one of the principal invited lectures at their annual meet- ing. This honor is awarded to significant academic researchers who (mostly) were trained as mathematicians, but who have done most of their work in not strictly mathematical areas (there are a number of physicists, astronomers, etc., in the an- nals of this lecture series as well as computer scientists); the lecturer can speak on any topic (s)he wishes, and Knuth decided to speak on computer science in the service of mathematics. The topic he presented was his new work on TEX (for type-
only the roots of the typographical concepts, but also the mathematical notions (e.g., the use of bezier splines to shape glyphs) on which these two programs are based. The programs sounded like they were just about ready to use, and quite a few mathematicians, including the chair of the Mathematical Society’s board of trustees, decided to take a closer look. As it turned out, TEX was still a lot closer to a research project than to an industrial strength product, but there were certain attractive features:
it was intended to be used directly by authors (and their secretaries) who are
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 7 of 12
Go Back
Full Screen
Close
to other scientists, and for math expressions, is quite similar to how one mathe- matician would recite a string of notation to another on the telephone. The TEX language is an interpreter. It accepts mixed commands and data. The command language is very low level (skip so much space, change to font X, set this string of words in paragraph form,... ), but is amenable to being enhanced by defining macro commands to build a very high level user interface (this is the title, this is the author, use them to set a title page according to ams specifications). The han- dling of footnotes and similar structures are so well behaved that ‘style files’ have been created for TEX to process critical editions and legal tomes. It is also (after some highly useful enhancements in about 1990) able to handle the composition of many different languages according to their own traditional rules, and is for this reason (as well as for the low cost), quite widely used in eastern Europe.
Some of the algorithms in TEX have not been bettered in any of the composition tools devised in the years since TEX appeared. The most obvious example is the paragraph breaking: text is considered a full paragraph at a time, not line-by-line; this is the basic starting algorithm used in the hz-program by Peter Karow (and named for Hermann Zapf, who developed the special fonts this program needs to improve on the basics).
In summary, TEX is a special-purpose programming language that is the center- piece of a typesetting system that produces publication quality mathematics (and surrounding text), available to and usable by individuals.
1.3. What is LATEX then?
At the beginning of 1980s, Leslie Lamport started work on a document prepara- tion system called LATEX based on the TEX formatter. This system adds a set of functions that makes the TEX language more friendlier than using the primitives
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 8 of 12
Go Back
Full Screen
Close
provided in TEX, enabling the author to concentrate on the content and structure of the document rather than the formatting details, so that the author might not loose the train of thought while writing his document. Also, LATEX’s functionality, in conjunction with a few auxiliary programs, includes the generation of indices, bibliographies, cross-references, tables of contents, graphic inclusion, etc. These are the features that are lacking in basic TEX (usually called plain TEX).
1.4. Getting Started
First of all, let’s see what steps are necessary to produce a document using LATEX. The first step is to type the file that LATEX reads. This is usually called the LATEX file or the input file, and it can be created using a simple text editor (in fact, if you’re using a fancy word processor, you have to be sure that your file is saved in ascii or non-document mode without any special control characters). The LATEX program then reads your input file and produces what is called a dvi file (dvi stands for DeVice Independent). This file is not readable, at least not by humans. The dvi file is then read by another program (called a device driver) that produces the output that is readable by humans. Why the extra file? The same dvi file can be read by different device drivers to produce output on a dot matrix printer, a laser printer, a screen viewer, or a phototypesetter. Once you have produced a dvi file that gives the right output on, say, a screen viewer, you can be assured that you will get exactly the same output on a laser printer without running the LATEX program again.
The process may be thought of as given in the Figure 1.1. This means that we don’t see our output in its final form when it is being typed at the terminal. But in this case a little patience is amply rewarded, for a large number of symbols not available in most word processing programs become available. In addition, the typesetting is done with more precision, and the input files are easily sent between
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 10 of 12
Go Back
Full Screen
Close
\documentclass[ a4paper ]{ tutorial } \pagestyle{ headings } \usepackage[ screen,rightpanel,paneltoc,code ]{ pdfscreen }
\begin{ document }
\chapter{ Introduction }
\section{ The Concept of Generic Markup } Originally markup was the annotation of manuscripts of a copy editor telling the typesetter how to format the manuscript. It consisted of handwritten notes such as ‘\emph{set this heading in 12 point Helvetica}
Figure 1.2 A sample LATEX input file
The preamble portion of a LATEX input file that generated the Introduction page of this document is given in Figure 1.2. You will notice that there are many key- words that start with the character ‘\’ followed by arguments within ‘[ ]’ and ‘{ }’. These keywords are called control sequences , the arguments within square brackets are called optional arguments and those within curly braces are called arguments (which are mandatory). We will learn about these later on.
By clicking the following button, you can go to the opening page of this chapter and from there you can come back by clicking at the Go Back button.
Go to Introduction
When you run LATEX over this file (for the time being, we shall name it as test.tex), we get the output called test.dvi. The web2c TEX system is the implementation
The Concept of... A Short... What is LATEX then? Getting Started
Title Page
Page 11 of 12
Go Back
Full Screen
Close
distributed by the TEX Users Group and is free. Throughout this tutorial, we shall describe TEX functionality based on web2c system only. Commercial implementa- tions like pcTEX and y&yTEX for Win32 systems or Textures for Macintosh, though widely used in the typesetting industry, will not be described in this manual owing to its non-gnu nature.
You can issue the following command to the command prompt of your Unix shell to compile your input file (here we call test.tex):
$ latex test
Extension is only necessary, if you have given extension other than *.tex. In Win system, you can use the TEXshell and can click at the LATEX button to run LATEX.
Many previewers are available, xdvi is the standard previewer in Unix and Windvi in Win32 systems. The following command will show your dvi in your computer screen. Again, extension is only optional.
$ xdvi test
Printing is usually done through PostScript. You can convert the dvi into ps by issuing the following command:
$ dvips test -o test.ps $ lpr test.ps
This will print the dvi to your printer. dvips can be configured to pipe the *.ps directly to your printer. Win32 systems provide menu buttons to accomplish these jobs.
TEX Directory... Fonts Characters Epilog
Title Page
Page 1 of 10
Go Back
Full Screen
Close
URL: http://www.river-valley.com/tug
On-line Tutorial on LATEX
The Tutorial Team Indian TEX Users Group, sjp Buildings, Cotton Hills Trivandrum 695014 , india 2000 Prof. (Dr.) K. S. S. Nambooripad, Director, Center for Mathematical Sciences, Trivandrum, (Editor) ; Dr. E. Krishnan, Reader in Mathematics, University College, Trivandrum ; T. Rishi, Focal Image (India) Pvt. Ltd., Trivandrum ; L. A. Ajith, Focal Image (India) Pvt. Ltd., Trivandrum ; A. M. Shan, Focal Image (India) Pvt. Ltd., Trivandrum ; C. V. Radhakrishnan, River Valley Technologies, Software Technology Park, Trivandrum constitute the TUG India Tutorial team This document is generated from LATEX sources compiled with pdfLATEX v. 14e in an INTEL Pentium III 700 MH z system running Linux kernel version 2.2.14-12. The packages used are hyperref.sty and pdfscreen.sty
©^ c 2000, Indian TEX Users Group. This document may be distributed under the terms of the LATEX Project Public License, as described in lppl.txt in the base LATEX distribution, either version 1.0 or, at your option, any later version
TEX Directory... Fonts Characters Epilog
Title Page
Page 2 of 10
Go Back
Full Screen
Close
2 Some Conventions
As a well developed programming language, TEX has certain conventions that might be worth understanding. It might appear cryptic to learn such nitty-gritty things just to typeset a document, but it will eventually become known to you that it is worth understanding. As in other mainstream programming languages, TEX has data types, booleans, input/output operations, etc. Apart from this TEX has a highly structured directory tree popularly called TEX Directory Structure (tds), a font setup that is specific to TEX alone, a mechanism of reading and digesting char- acters that come across on its way and not found in other languages, etc. We shall examine one by one.
2.1. TEX Directory Structure
All implementation-dependent TEX system files (.pool, .fmt, .base, .mem) are stored by default directly in texmf/web2c. The configuration file texmf.cnf and various subsidiary MakeTeX... scripts used as subroutines are also stored there.
Non-TEX specific files are stored following the GNU coding standards. Given a root directory prefix (/usr/local by default), we have default locations as follows:
TEX Directory... Fonts Characters Epilog
Title Page
Page 4 of 10
Go Back
Full Screen
Close
base/ base distribution (e.g., plain.bst, acm.bst) misc/ single-file styles 〈 package 〉/ name of a package
doc/ Documentation
etex/ as with TEX, below
fonts/ font-related files
〈 type 〉/ file type (e.g., pk) 〈 mode 〉/ type of output device (for pk and gf only) 〈 supplier 〉/ name of a font supplier (e.g., public) 〈 typeface 〉/ name of a typeface (e.g., cm) dpi〈 nnn 〉/ font resolution (for pk and gf only)
〈 implementation 〉/ TEX implementations, by name (e.g., emTEX)
local/ files created or modified at the local site
metafont/ METAFONT (non-font) input files
base/ base distribution (e.g., plain.mf) misc/ single-file packages (e.g., modes.mf) 〈 package 〉/ name of a package (e.g., mfpic)
metapost/ MetaPost input and support files
base/ base distribution (e.g., plain.mp) misc/ single-file packages 〈 package 〉/ name of a package support/ support files for MetaPost-related utilities
mft/ MFT inputs (e.g., plain.mft)
〈 program 〉/ TEX-related programs, by name (e.g., dvips)
source/ program source code by name (e.g., LATEX, web2c)
tex/ TEX input files
TEX Directory... Fonts Characters Epilog
Title Page
Page 5 of 10
Go Back
Full Screen
Close
〈 format 〉/ name of a format (e.g., latex) base/ base distribution for format (e.g., latex.ltx) misc/ single-file packages (e.g., webmac.tex) local/ local additions to or local configuration files for format 〈 package 〉/ name of a package (e.g., graphics, mfnfss) generic/ format-independent packages hyphen/ hyphenation patterns (e.g., hyphen.tex) images/ image input files (e.g., Encapsulated PostScript) misc/ single-file format-independent packages (e.g., null.tex).
Understanding this directory tree will help you to install third party fonts and other packages later on. The top level 〈 prefix 〉 can be specified as is the case with TEXLive cdrom. However, the TEX tree does not change. The latest tds Working Group’s draft release is available at: http://tug.org/tds/.
2.2. Fonts
Unlike other typesetting systems, TEX needs a font file format called, *.tfm (TEX Font Metric). This file keeps all the metrics of characters like height, depth, width, kern values, etc. (TEX keeps around 64 parameters for a character) of a particular font family. During compilation process, TEX reads this metrics information and based on these values, it horizontally packs boxes having values of bounding box of characters consecutively till the end of the line is encountered. During this compilation process, TEX is not at all bothered, whether a physical font file (like *.pfb or *.ttf etc.) is available in your system. It is during previewing or printing, the corresponding software needs these font files.
TEX Directory... Fonts Characters Epilog
Title Page
Page 7 of 10
Go Back
Full Screen
Close
Character Math mode Text mode \ \backslash \textslash
$ $ $ % % % ˆ \ˆ \ˆ _ _ _ { { { } } } ˜ \tilde \texttilde
Ordinary alphabets, numerals, punctuations, parentheses, square brackets, and characters other than what listed above are entered as in any other program or word processor and the result will exactly match what you have entered.
Greek letters, various math operators including negated operators, arrows, stretchy delimiters, etc., which are normally not available in a keyboard are entered to the computer with a set of special control sequences specifically designed for this pur- pose. There are around 2500 control sequences available, at least half of them are not in regular use. The numbers need not make you awe-struck, since you know most of them. Knuth designed all the control sequences in such a way that it is nothing but what you ordinarily pronounce in your classroom. For instance, if you want a Greek alpha character entered into your document, you need to give
TEX Directory... Fonts Characters Epilog
Title Page
Page 8 of 10
Go Back
Full Screen
Close
as \alpha, this during compilation will give you ‘ α ’. Given below is an equation composed of such control sequences: (α + β)^2 = α^2 + β^2 + 2 αβ (2.1) The following code generates the above equation which is not at all difficult for any academic to undertake.
\begin{ equation } (\alpha + \beta)ˆ2 = \alphaˆ2 + \betaˆ2 + 2\alpha\beta \end{ equation }
Similarly, a wide variety of symbols are accessed with names similar to what we or- dinarily denote them. For instance, ↙, ψ , - →,
, ⊆, 6 ⊆ are generated with \swarrow, \psi, \longrightarrow, \sum, \subseteq, \not\subseteq. The point is that symbols in TEX is extremely logical to follow and not much extra effort is needed to under- stand and remember them. We will learn more about math symbols, formulae and their spatial arrangement and constructs during the second phase of our tutorial.
Languages other than English have a variety of accents and special symbols. LATEX provides commands to generate accents and symbols to put small pieces of non- English text in an English document. See this sentence: El se˜nor est´a bien, garc¸on, ´El est´a aq¨u´ı generated by the following code:
El se\˜nor est\’a bien, gar\c{c}on, \’El est\’a aq"u\’{\i}