![]() | ![]() | ||||||||
![]() | |||||||||
| Directory | Courses | Undergraduate | Graduate | Research | Seminars | Calendar | Contacts | Resources | Donate | RCF | Math/Stat Res Ctr | OWL Login | SPIRE | Links | US Math Depts | For Dept Members |
|
|
|||||||||
TeXis well known to be the/ typesetting package, and a vast cult of TeXlovers has evolved. But to the beginning TeXuser, or to someone wondering if they should bother changing to TeX, it is often not clear what all the fuss is about. After all, are not both WordPerfect and Ventura Publisher capable of high quality output? Newcomers have often already seen what TeX is capable of (many books, journals, letters are now prepared with TeX) and so expect to find a tremendously powerful and friendly package. In fact they do, but that fact is well hidden in one's initial TeXexperiences. In this chapter we describe a little of what makes TeXgreat, and why other packages cannot even begin to compete. Be warned that a little patience is required--TeX's virtues are rather subtle to begin with. But when the penny drops, you will wonder how you ever put up with anything different.
The spirit of TeXIn order to really appreciate TeXone needs to get a feel for what I call the ``spirit'' of TeX. When TeX appears to be making me work overtime to achieve something that I think ought to be perfectly straightforward, consultation with the TeXspirit shows me the error of my ways.
TeXis a typesetter, not a word-processor
TeXwas designed with no limiting application in mind. It was intended to be able to prepare practically any document--from a single page all-text letter to a full blown book with huge numbers of formulae, tables, figures etc. The size and the complexity of a TeXable document is limited only by hardware considerations. Furthermore, TeXseeks to achieve all this whilst setting typesetting standards of the highest order for itself. The expertise of generations of professional printers has been captured in TeX, and it has been taught all the tricks of the trade.
Historically, printers prepared a document by placing metal characters in a large tray and arranging and binding them to form a page. This was very precisely done, but the ultimate precision was limited because of the mechanical nature of things and by time considerations. TeXprepares a page in an analogous manner (putting your characters and formulae into ``boxes'' which are then ``glued'' together to form the page), but has the advantage of enormous precision because placement calculations are performed by computer. Indeed, TeX's internal unit (the ``scaled point'') is about one-hundredth of the wavelength of natural light!
``But conventional word processors run on computers , too'', you object. Yes, but their fundamental limitation is that they try to ``keep up'' with you and ``typeset'' your document as you type. This means that it can only make decisions at a local level (eg, it decides where to break a line just as you type the end of the line). TeX's secret is that it waits until you have typed the whole/ document before it typesets a single thing! This means that TeXcan make decisions of a global nature in order to optimise the aesthetic appeal of your document. It has been taught what looks good and what looks bad (having been given a measure of the ``badness'' of various possibilities) and makes choices for your document that are designed to make it ``minimally bad''.
But TeX's virtues run much deeper than that, which is just as well because it is possible to get satisfactory, though imperfect, results from some word processors. One of TeX's strongest points is its ability to typeset complicated formulae with ease. Not only does TeX make hundreds of special symbols easily accessible, it will lay them out for you in your formulae. It has been taught all the spacing, size, font, ...conventions that printers have decided look best in typeset formulae. Although, of course, it doesn't understand any mathematics it knows the grammar of mathematics--it recognises binary relations, binary operators, unary operators, etc. and has been taught how these parts should be set. It is consequently rather difficult to get an equation to look bad in TeX.
Another advantage of compiling a document after it is typed is that cross-referencing can be done. You can label and refer back to chapters, sections, tables etc. by name/ rather than absolute number, and TeXwill number and cross-reference these for you. Similarly, it will compile a table of contents, glossary, index and bibliography for you.
Essential to the spirit of TeXis that it formats the document whilst you just take care of the content, making for increased productivity. The cross-referencing just mentioned is just part of this. Many more labour-saving mechanisms are provided for through style files. These are generic descriptions of classes of documents, teaching TeX just how each class likes to be formatted. This is taught in terms of font preferences, default page sizes, placement of title, author, date, etc. For instance, a paper style file could teach TeXthat when typesetting a theorem it should embolden the part that states the theorem number and typeset the text of the theorem statement in slanted Roman typeface (as in many journals). The typist simply provides and indication that a theorem is being stated, and then types the text of the theorem without/ bothering to choose any fonts or do any formatting--all that is done by the style file. Style files exist for all manner of document--letters, articles, papers, books, proceedings, review articles, and so on.
In addition to style files, there are macro packages. A macro/ is just a definition of a new TeXcommand in terms of existing ones. Don't think small when you think of macros! When typing a document that has a lot of repetition in it, say the same expression is used again and again in different different equations, you can define a macro in your document to abbreviate that expression. But macros can teach TeX how to typeset all sorts of complicated structures, not just parts of an equation. Many macro packages (files that are just collections of definitions) have been written to teach TeX all sorts of applications. There are specialist maths packages (2 A 2 M2 S-TeX, 2 A 2 M2 S-LaTeX), general purpose packages (LaTeX), packages for setting tree diagrams, Feynmann diagrams, languages like Chinese, Arabic and Ancient Greek, orchestral scores, and many, many more. All these are freely available, a spin-off of the giant TeXcult.
Another facet of the design of TeXallows it to use practically any/ output device. In fact, TeX doesn't talk to any printers, screens, phototypesetters at all! Instead, when a document is compiled a device independent/ (.dvi) is produced--TeXdoes not compile with any particular output device in mind. Printer drivers are then invoked on this .dvi file and, in consultation with the font data for that printer, produce output suitable for the particular device. You can choose an HP Laserjet driver, or an Apple LaserWriter driver, or a dot matrix driver etc. All use the same .dvi file as input (and remember the material in there is set to enormous accuracy) and attempt to image that file on the particular device as faithfully as possible. If you are using a top of the line laser printer or phototypesetter, then TeX's massive internal precision will not be wasted. Alternatively, a dot matrix printer will give a coarse approximation of the ideal image that is suitable only for proof-reading. In addition to portability, these .dvi files help ensure that there are very few printing surprises when you move from one device to another: how many times has your favourite word-processor made you reformat a document when you wish to change printers?
There are many other motivations one could cite for the superiority of TeX. But it is time that we started to get our hands dirty. One last comment: TeXwas not designed to supplant secretaries and professional printers--it was designed to aid them in their work and, in the words of the TeXdesigner Donald Knuth, allow them to ``go forward and create masterpieces of the publishing art''.It also allows those who generate the material to be typeset--mathematicians, physicists, computer scientists, etc--to prepare their own documents in a language that is intimately linked to the language we use for writing such material.
The novice reader will still have no idea of what a TeXsource file looks like. Indeed, why do we keep referring to it as a source file? The fact of the matter is that TeXis essentially a programming language. Just as in any compiled language (e.g., Pascal, C) one prepares a source file and submits it to the compiler which attempts to produce an object file (.dvi file in the TeXcase). To learn TeXis to learn the command syntax of the commands that can be used in the source file.
Typical TeXinterfacesTeXwas designed to run on a multitude of computers. It is therefore the case that the documentation for TeXand its ``friends'' LaTeX, 2 A 2 M2 S-TeX, etc. is not computer specific. Only command syntax is described--i.e., the content of your source file--but few details of how to get from there to a printout are given. Those details are left to site-specific documents.
The average user loses little in using TeXon, say, a PC rather than on a bigger machine. Indeed, compilation times on the new PCs begin to rival those on a Sun Sparc Station 2 (no slouch). Running on top of DOS can cause memory problems when very large documents are being prepared. That aside, the quality of the document is not affected because of the careful design of TeX--whether you work on a a machine with massive floating point precision or a modest XT the .dvi files produced on compilation will be identical; and when those files are submitted to printer equivalent printer drivers (say for an HP LaserJet III attached to a Sun in one case and a PC in the other) the output will be identical because the font information they draw on is identical.
By the nature of TeXmost time is spent editing the source document (before submitting it for compilation). No special interface is necessary here, you just use your favourite text editor (perhaps customising it to enhance TeXnical typing. Thus TeXuser interfaces are usually small and simple, often even missing. One frequently uses TeXat command line level, just running the editor, compiler etc. as you need them. Sometimes a TeXshell program is present, which runs these for you when you choose various menu options.
Whatever the interface, there are just a few basic steps to preparing a document:
If you think this sounds like a lot of work, it is time that you consult with the TeXspirit! Sure your first couple of tries may be hesitant, but before long you'll find that you can take less/ time to prepare a document on TeX than on any other package.
Getting started with LaTeXTo answer this question we must say a little more about some of the macro packages we mentioned earlier.
The TeXtypesetting system was designed by the eminent Stanford computer scientist Donald Knuth, on commission from the American Mathematical Society. It was designed with enormous care, to be ultimately powerful and maximally flexible. The enormous success of Knuth's design is apparent from the vast number of diverse applications TeXhas found. In reading the following you must keep one thing clearly in mind: there is only TeXlanguage, and all the other packages whose names end in the suffix -TeX simply harness it's power via a whole lot of complicated macro definitions.
TeXproper is a collection of around 300 so called primitive/ typesetting commands. These work at the very lowest level, affording enormous power. But to make this raw power manageable, some macros must be defined to tame raw TeXsomewhat. The standard set of macros is called Plain TeX, and consists of about 600 macro definitions. It is clear that these definitions must be made in terms of TeXprimitives, or in terms of previously made definitions. Plain TeX, however, is still no place for the timid. A strong working knowledge of TeXis still required to understand the ins and outs of Plain TeX.
In the few years after the initial TeXrelease (1982), the macro packages 2 A 2 M2 S-LaTeXwere born. 2 A 2 M2 S-written by Michael Spivak, also on commission from the AMS. This package was designed to facilitate the preparation of the numerous books, journals, and review indices that fall under the auspices of the AMS and its affiliates. Married to the macro package was a style file--the AMS preprint style. This was distributed along with the macro package, so that authors submitting to journals could use it in the preparation of their articles. The given style was based on the style used by the Journal of the American Mathematical Society, i.e., it conformed to their page sizes and typographical conventions. This meant that people around the world produced papers that were all based on the same style. The clever part is this: when a source file is submitted to a journal other/ than the Journal of the AMS, the journal staff simply substitute their style file for the AMS preprint style and the paper will appear completely different with no other changes to the source code/! To create their style file, a journal just needed to tweak the standard AMS prepint style: for instance, the original preprint style places author addresses at the very end of a paper; If a journal wishes this to appear on the first page then they just modify their in-house version of the style file, and the change will be effected without having to change the file submitted by the author.
LaTeXwas written for more general usage. It lacks some of the mathematical finesse inherited by 2 A 2 M2 S-the vast experience of the AMS technical staff, but more than makes up for this in its ability to enhance the typesetting of letters, books, poetry, etc. LaTeXalso scores high points for its enhanced command syntax.
With 2 A 2 M2 S-LaTeXbeing released at around the same time (1984-1985), there were born many 2 A 2 M2 S-but LaTeXilliterate users, and conversely. LaTeXwas easier to learn because of its more friendly syntax, and also provided powerful cross-referencing commands that 2 A 2 M2 S-not. So the AMS commissioned another project to furnish LaTeXusers with the additional power of 2 A 2 M2 S-TeX while not compromising the LaTeXcommand syntax or cross-referencing commands. This resulted in the 2 A 2 M2 S-LaTeX macro package and associated style file for submission to journals.
That/ is why we will kick off our TeXcareers with LaTeX! It is easier to learn and provides many conveniences, and the user who requires additional mathematical typesetting prowess can easily move on to 2 A 2 M2 S-LaTeX. Much of what we say will be true for TeXitself, but we shall regard LaTeXas the lowest common-denominator. By far the majority of LaTeXand 2 A 2 M2 S-will never have to learn ``raw'' TeX, for they will be shielded from direct exposure by the numerous powerful macro packages. In the rare case that something way out of the ordinary is required, the local TeXguru can be consulted.
LaTeXformats, and we composeThe free form nature/ of the input file is essential to the spirit of TeX. As we type, we do not concern ourselves with linebreaks and pagebreaks so much as the content of what we are typing. In fact, we'll see that TeXwill choose nice line breaks even for bizarre looking input. This is just part of the concept of only having to describe the logical/ structure of the document to LaTeX, and not worry about nuisance-value formatting details. We inform LaTeX of the logical structure of our document by telling it when to begin a new paragraph, subsection, section, chapter, theorem, definition, remark, poem, list etc. When typing a particular element of the logical structure, we need pay little attention to how we lay our source file out.
A consequence of this is that we have to go to a bit of effort to mess things up. Starting a new line, for instance, entails more than just pressing Return because LaTeXwill just regard the next word you type as exactly that--the next word in the paragraph. You have to specifically ask for a line to be terminated. Things like this may seem to be a bit of a nuisance, but it is a small price to pay for the automatic formatting that necessitated it. Further, such small inconveniences have been localised to rare events. I have, for instance, not once forced a new line up until this point in the present document.
Document stylesWe have explained the concept of a document style during our discussion of the virtues of TeXand the discussion of 2 A 2 M2 S-TeX. It remains to name a few, and indicate where they would be used. One always/ has to choose a document style when preparing a document with LaTeX.
The basic document styles in LaTeXare letter, article, report, and book. Many more are available, but these few cover the majority of straightforward applications. This is because styles are not rigid--you can impose your own parameter choices if you want. So one chooses the style that most closely approximates the document you have in mind, and performs some minor tweaks here and there. The article style is used for documents that are to have the appearance of a journal or magazine article. The report style is usually used for larger documents than the article style. These styles really only differ in their choice of default page size, font, placement of title and author, sectional units, etc. and on how they format certain LaTeXconstructs. You use the same LaTeXcommands in each. Since the examples here will be small, we will choose to use the article document style.
There are a number of possible options with each document style. The syntax for choosing a document style follows. Don't worry if this leaves you with no idea of how to choose a document style, for we will soon be seeing some examples. Also, remember that an argument in square brackets is optional, and can omitted altogether (including the brackets).
documentstyle [options /]\{style /\}
where style/ is the main document style (eg report) and the optional argument options/ is a list of document style options chosen >from the following list:
In fact there are many, many more document style options but we won't mention any more here.
Preparing a non-mathematical documentWe assume that you have read the local guides to TeXat your site and have decided which system environment you want to work in. There you have been shown how to perform the steps required to produce a printed document from a LaTeXsource file.
Let's create our very first LaTeXdocument, which will consist of just a few paragraphs.
As mentioned above, paragraph input is free-form. You type the words and separate them by spaces so that LaTeXcan distinguish between words. For these purposes, pressing Return is equivalent to inserting a space--it does not indicate the end of a line, but the end of a word. You tell LaTeXthat a sentence has ended by typing a period followed by a space. LaTeXignores extra spaces; typing three or three thousand will get you no more space between the words that these spaces separate than typing just one space. Finally, you tell LaTeXthat a paragraph has ended by leaving one or more blank lines. In summary: LaTeXconcerns itself only with the logical concepts end-of-word, end-of-sentence, and end-of-paragraph. Sounds complicated? An example should clear things up:
\documentstyle\{article\}
\begin\{document\}
Words within a sentence are ended by spaces. One space
between words is equivalent to any number. We are only
interested in separating one word from the
next, not in formatting the space between them.
For these purposes, pressing Return
at the end of a line
and starting a new word on the next line
just serves to separate
words, not to cut a line short.
The end of a sentence is indicated by a period
followed by one or more spaces.
The end of a paragraph is indicated by leaving a blank line.
All this
means that we can type without too much regard for layout, and
the typesetter will sort things out for us.
\end\{document\}
produces the result
0.8within a sentence are ended by spaces. One space between words is equivalent to any number. We are only interested in separating one word from the next, not in formatting the space between them. For these purposes, pressing Return at the end of a line and starting a new word on the next line just serves to separate words, not to cut a line short. The end of a sentence is indicated by a period followed by one or more spaces.
The end of a paragraph is indicated by leaving a blank line. All this means that we can type without too much regard for layout, and the typesetter will sort things out for us.
Perhaps you would like to try running LaTeXon the above input. Consult your local guide for details.
Note that we have learned more than just how LaTeXrecognises words, sentences and paragraphs. We've also seen how to specify our choice of document style and how to tell LaTeXwhere our document begins and ends. Any material that is to be printed must lie somewhere between the declaration of \begin\{document\} and that of \end\{document\}. Definitions that are to apply to the entire document can be made before the declaration of the document beginning. The specification of document style must precede all other material.
In future examples we won't explicitly display the commands that select document style and delimit the start and end of the document. But if you wish to try any of the examples, don't forget to include those commands. The article document style will do for most of our examples. Of course, the preceding example looks not at all like an article because it is so short and because we specified no title or author information.
Most of what you need to know to type regular text is contained in the example above. When you consider that by far the majority of any document consists of straight text, it is obvious that LaTeXmakes this fabulously straightforward. LaTeXwill do all the routine work of formatting, and we simply get on with the business of composing.
LaTeXdoes more than simply choose pleasing line breaks and provide natural spacing when setting a paragraph. Remember we said that TeXhas inherited the knowledge of generations of professional printers--well part of that knowledge includes being on the look-out for ligatures. These are combinations of letters within words which should be typeset as a single special symbol because they will ``clash'' with each if this is not done. Have a look at these words flight, flagstaff, chaff, fixation
and compare them with these flight, flagstaff, chaff, fixation
See the difference? In the first set I let LaTeXrun as it usually does. In the second I overruled it somewhat, and stopped it from creating ligatures. Notice how the `fl', `ff', and `fi' combinations are different in the two sets--in the former they form a single symbol (a ligature) and in the latter they are comprised of two disjoint symbols. There are other combinations that yields ligatures, but we don't have to bother remembering any of them because LaTeXwill take care of these, too.
Notice, too, that LaTeXhas been taught how to hyphenate the majority of words. It will hyphenate a word if it feels that the overall quality of the paragraph will be improved. For long words it has been taught several potential hyphenation positions.
LaTeXalso goes to a lot of trouble to try to choose pleasing page breaks. It avoids ``widows'', which are single lines of a paragraph occurring by themselves at either the bottom of a page (where it would have to be the first line of a paragraph) or at the top of a page (where it would have to be the last). It also ``vertically justifies'' your page so that all pages have exactly the same height, no matter what appears on them. As testimony to the success of the pagebreaking algorithm, I have (to this point) not once chosen a page break in this document.
PunctuationTypists have a convention whereby a single space is left after a mid-sentence comma, and two spaces are left after a sentence-ending period. How do we enforce this if LaTeXtreats a string of spaces just like a single one? The answer, unsurprisingly, is that we don't.
To have a comma followed by the appropriate space, we simply type a comma follows by at least one space. To end a sentence we type a period with at least one following space. No space will be inserted if we type a comma or period followed straight away by something other than a space, because there are times when we won't require any space, i.e., we do what comes narurally.will produce
0.8have a comma followed by the appropriate space, we simply type a comma follows by at least one space. To end a sentence we type a period with at least one following space. No space will be inserted if we type a comma or period followed straight away by something other than a space, because there are times when we won't require any space, i.e., we do what comes naturally.
LaTeXwill produce suitable space after commas, periods, semi-colons and colons, exclamation marks, question marks etc. if they are followed by a space. In stretching a line to justify to the right margin, it also knows that space after a punctuation character should be more ``stretchable'' than normal inter-word space and that space after a sentence-ending period should be stretched more than space after a mid-sentence comma. TeXknows the nature of punctuation if you stick to the simple rules outlined here. As we've already said, those rules tell LaTeXhow to distinguish consecutive words, sentences, phrases, etc.
Actually, there is more to ending sentences than mentioned above. Since LaTeXcannot speak English, it works on the assumption that a period followed by a space ends a sentence unless the period follows a capital letter. This works most of the time, but can fail. To get a normal inter-word space after a period that doesn't end a sentence, follow the period by a control space--a \ (a character followed by a space or return). Very rarely, you will have to force a sentence to end after a period that follows a capital letter (remember that LaTeX assumes this doesn't end a sentence). This is done by preceding the period with a \@ command (you can guess from the odd syntax that this is rarely needed).
It's time we saw some examples of this. After all, this is our first experience of control symbols (don't worry, there are many more to come).
We must be careful not to confuse intra-sentence periods with periods that end a sentence, i.e.\ we must remember that our task is to describe the sentence structure. Periods that the typesetter requires a little help with typically result >from abbreviations, as in etc.\ and others. We have to work somewhat harder to break a sentence after a capital letter, but that shouldn't bother us to much if we keep up our intake of vitamin E\@. All this goes for other sentence-ending punctuation characters, so I could have said vitamin E\@! Fortunately, these are rare occurrences.results in
0.8must be careful not to confuse intra-sentence periods with periods that end a sentence, i.e. we must remember that our task is to describe the sentence structure. Periods that the typesetter requires a little help with typically result >from abbreviations, as in etc. and others. We have to work somewhat harder to break a sentence after a capital letter, but that shouldn't bother us to much if we keep up our intake of vitamin E. All this goes for other sentence-ending punctuation characters, so I could have said vitamin E! Fortunately, these are rare occurrences.
Quotation marks is another area where LaTeXwill do some work for us. Keyboards have the characters `, `, and " but we want to to have access to each of `, ', ``, and ''. So we proceed like this:
`\LaTeX' is no conventional word-processor, and to to get quotes, like ``this'', we type repeated ` and ' characters. Note that modern convention is that ``punctuation comes after the closing quote character''.which gives just what we want
0.8`LaTeX' is no conventional word-processor, and to to get quotes, like ``this'', we type repeated ` and ' characters. Note that modern convention is that ``punctuation comes after the closing quote character''.
Very rarely, you have three quote characters together. Merely typing those three quote characters one-after-the-other is ambiguous--how should they be grouped? You tell LaTeXhow you want them grouped by inserting a very small space called \,.
``\,`Green ham' or `Eggs?'\,'' is the question.gives the desired result
0.8``,`Green ham' or `Eggs?','' is the question.
Since we have a typesetter at our disposal, we might as well use the correct dashes where we need them. There are three types of dash: the hyphen, the endash, and the emdash. A minus sign is not a dash.
Hyphens are typed as you'd hope, just by typing a - at the point in the word that you want a hyphen. Don't forget that LaTeXtakes care of hyphenation that is required to produce pretty linebreaks. You only type a hyphen when you explicitly want one to appear, as in a combination like ``inter-college''.
An endash is the correct dash to use in indicating number ranges, as in ``questions 1-3''. To specify an endash you type two consecutive dashes on the keyboard, as in 1--3.
An emdash is a punctuation dash, used at the end of a sentence--I tend to use them too much. To specify an emdash you type three consecutive dashes on the keyboard, as in ``...a sentence---I tend to...''.
Theorems 1--3 concern the semi-completeness of our new construct---in the case that it satisfies the first axiom.yields
0.81-3 concern the semi-completeness of our new construct--in the case that it satisfies the first axiom.
TiesWhen you always remember to use ties/, you know that you are becoming TeXnically inclined. Ties are used to prevent LaTeXfrom breaking lines at certain places. LaTeXwill always choose line breaks that result in the most aesthetically pleasing paragraph as judged by its stringent rules. But because LaTeX does not actually understand the material it is setting so beautifully, it can make some poor choices.
A tie/ is the character ~. It behaves as a normal interword space in all respects except/ that the line-breaking algorithm will never break a line at that point. Thus
Dr. Seuss should be typed as Dr.~Seussfor this makes sure that LaTeXwill never leave the `Dr' at the end of one line and put the `Seuss' at the beginning of the next.
One should try to get in to the habit of typing ties first-time, not after waiting to see if LaTeXwill make a poor choice This will allow you to make all sorts of changes to your text without ever having to go back and insert a tie at a point that has migrated to the end of a line from the middle of a line as a result of those changes. Remember, of course, that the line-breaks
Here are some more examples of places where you should remember to place ties.
Chapter~10 > Donald~E. Knuth
Appendix~C > width~2
Figure~1 > function~f
Theorem~2 > 1,~2, or~3
Lemmas 3 and~4 > equals~5
# $ % & ~ _ ^ \ \{ \}
are reserved for special use. Indeed, we have seen already that and ~ are non-printing characters that perform special services (and we'll have a lot more to say about the use of ).
But what if we need one of these special symbols to appear in our document? The answer for seven of the symbols is to precede them by a character, so forming another control symbol/ (remember that followed by a space was also a control symbol).
It is not 100\% straightforward to typeset the
characters \$ \& \% \_ \{ \}, but given the
enormous convenience of the use they are normally
reserved for this is a small price to pay.
produces
0.8is not 100% straightforward to typeset the
characters
& % _ \{ \}, but given the
enormous convenience of the use they are normally
reserved for this is a small price to pay.
In typing a document, we can think of ourselves as being in one of two distinct modes. We are either typing literal text/ (which will just be set into neat paragraphs for us) or we are typing text that will be interpreted/ by LaTeXas an instruction to insert a special symbol or to perform some action. Thus we are either typing material that will go straight into the document (with some beautification), or we are giving commands to LaTeX.
Some commands are implicit, in that we don't have to do anything much extra. For instance, we command LaTeXto end the present sentence by typing a period (that doesn't follow a capital letter). These are no so much commands as part of having to describe the logical structure of a document.
A control word/ is something of the form \commandname, where the command name is a word made up only of the letters a to z and A to Z. A control symbol/ consists of a followed by single symbol that is not a letter.
Here are some examples:
$ be inserted,These examples show that control sequences can be used to access symbols not available from the keyboard, do some typesetting tricks like setting the word LaTeXthe way it does, and change the appearance of whole chunks of text as with \em. We'll be meeting many more of these type of control sequences.
Another enormously powerful class of control sequences is those that accept arguments. They tell LaTeX to take the parts of text you supply and do something with them--like make a fraction by setting the first argument over the second and drawing a line of the appropriate length between them. These are part of what makes LaTeXso powerful, and here are some examples.
a+bc+d
a+b,
like this: [5]a+b
. The 5 is in square brackets
instead of braces because it is an optional argument and
could be ommited all together (giving the default of square root),
Mandatory arguments are given enclosed by braces, and optional arguments enclosed by square brackets. Each command knows how many arguments to expect, so you don't have to provide any indication of that.
We have actually jumped the gun a little. The above examples include examples of mathematical/ typesetting, and we haven't yet seen how to tell LaTeXthat it is typesetting maths as opposed to some other random string of symbols that it doesn't understand either. We'll come to mathematical typesetting in good time.
We need to dwell on a TeXnicality for a moment. How does LaTeXknow where the name of a control sequence ends? Will it accept both \pounds3 and \pounds 3 in order to set £3, and will \emWalrus and \em Walrus both be acceptable in order to get Walrus/? The answer is easy when you remember that a control word consists only of alphabetic characters, and a control symbol consists of exactly one nonalphabetic character.
So to determine which control sequence you typed, LaTeXdoes the following:
This has one important consequence: The character in the input file immediately after a control symbol will be ``seen'' by LaTeX, but any space following a control word will be discarded and never processed. This does not affect one much if you adopt the convention of always typing a space after a control sequence name.
There is a rare circumstance where this necessitates a little extra work and thought, which we illustrate by example:
If we type a control word like \LaTeX in the running text then we must be cautious, because the string of spaces that come after it will be discarded by the \LaTeX\ system.which produces the output
0.8we type a control word like LaTeXin the running text then we must be cautious, because the string of spaces that come after it will be discarded by the LaTeXsystem.
Commands to change appearanceEach of the control words here is a directive rather than a control sequence that accepts an argument. This is because potential arguments consisting of text that wants to be emboldened or emphasised are very large, and it would be a nuisance to have to enclose such an argument in argument-enclosing braces.
To delimit the area of text over which one of these commands has effect (its scope) we make that text into what is called a group. Groups are used extensively in LaTeXto keep effects local to an area, rather than affecting the whole document. Apart from enhancing usability, this also in a sense protects distinct parts of a document from each other.
The LaTeXcommands for changing type style are given in table 2.1, and those for changing type size are given in table 2.2. Commands for selecting fonts other than these are not discussed here.
Table 2.1: Commands for selecting type styles
Each of the type style selection commands selects the specified style but does not change the size of font being used. The default type style is roman (you are reading a roman style font now). To change type size you issue one of the type size changing commands in table 2.2, which will select the indicated size in the currently active style. The release of LaTeX 3.0 (the present version is 2.09) will see the New Font Selection Scheme in place as a standard feature. This makes font matters much easier to deal with.
Table 2.2: LaTeXsize-changing commands.
The point-size option referred to in table 2.2 is that specified in the \documentstyle command issued at the beginning of the input file. Through it you select that base (or default) font for your document to be 10, 11, or 12 point Roman. If no options are specified, the default is 10-point Roman. The table shows, for instance, that if I issue a \large in this document for which I chose the 12pt document style option the result will be a 14-point Roman typeface.
We mentioned that to restrict the scope of a type-changing command we will set the text to be affected off in a group. Let's look at an example of this.
When we want to \{\em emphasise\/\} some text we
use the \{\tt em\} command, and use grouping to
restrict the scope. We can change font \{\large sizes\}
in much the same way. We can also obtain \{\it italicised\},
\{\bf emboldened\}, \{\sc Capitals\} and \{\sf sans serif\} styles.
0.8we want to emphasise/ some text we use the em command, and use grouping to restrict the scope. We can change font sizes in much the same way. We can also obtain italicised, emboldened, CAPITALS and sans serif styles.
Notice how clever grouping allows us to do all that without once having to use \rm or \normalsize.
One more thing slipped into that example--and italic correction/ \/. This is a very small amount of additional space that we asked to be inserted to allow for the change from sloping emphasised text to upright text, because the interword space has been made to look less substantial from the terminal sloping character. One has to keep an eye open for circumstances where this is necessary. See the effect of omitting an italic correction after the emphasised text earlier in this paragraph.
One might expect, by now, that LaTeXwould insert an italic correction for us. But there are enough occasions when it is not wanted, and there is no good rule for LaTeXto use to decide just when to do it for us. So the italic correction is always left up to the typist.
AccentsLaTeXprovides accents for just about all occasions. They are accessed through a variety of control symbols and single-letter control worlds which accept a single argument--the letter to be accented. These control sequences are detailed in table 2.3.
Table 2.3: Control sequences for accents
Thus we can produce 'o by typing \'\{o\}, a by typing \v\{a\}, and P'al Erdös by typing P\'\{a\}l Erd\"\{o\}s. Take special care when accenting an i or a j, for they should lose their dots when accented. Use the control words \i and \j to produce dotless versions of these letters. Thus the best way to type to type exigent is SPMquotexigent".
Over-ruling some of TeX's choicesWe've seen that ties can be used to stop linebreaks occurring between words. But how can we stop LaTeXfrom hyphenating a particular word? More generally, how can we stop it from splitting any given group of characters across two lines. The answer is to make that group of characters appears as one solid box/, through use of an \mbox command.
For instance, if we wanted to be sure that the word
\{\em currentitem\/\} is not split across lines
then we should type it as \mbox\{\em currentitem\}.
If for some reason we wish to break a line in the middle of nowhere, preventing LaTeX >from justifying that line to the prevailing right margin, the we use the \newline command. One can also use the abbreviated form \\.
We start with a short line.\newline And now we continue with the normal text, remembering that where we press Return in the input file probably won't correspond to a line break in the final document. More short lines\\ are easy, too.will produce the line breaks we want
0.8start with a short line.
And now we continue with the normal
text, remembering that where we press
Return in the input file probably won't
correspond to a line break in the final
document. More short lines
are easy, too.
A warning is in order: \newline must only end part of a line that is ``already set''. It cannot be used to add additional space between paragraphs, nor to leave space for a picture you want to paste in. This is not to be awkward, but is just part of LaTeXholding up its end of the deal by making you have to specially request additional vertical space. This prevents unwanted extra space from entering your document.
Later we shall see how to impose our own choice of page size, paragraph indentation, etc. For now we will continue to accept those declared for us in the document style.
Commenting your documentIt is handy to be able to make comments to yourself in the source file for a document. Things like ``I must rewrite this section'' and ``This is version 3 of the document'' are likely. It would also be useful to be able to make the compiler ignore certain parts of the document at times. For this purpose we can use the % character, for all text on an input line that is after a % which is not part of an occurrence of the control symbol \% is discarded by the compiler. Here is an example:
There was a 100\% turnout today, an all-time record. %perhaps I should check this claim! %Indeed, there are lots of unsubstantiated claims here! This made for an extremely productive session.will yields
0.8was a 100% turnout today, an all-time record. This made for an extremely productive session.
Footnotes
Inserting footnotes is easy--LaTeXwill position and
number them for you. You just indicate exactly/
where the footnote marker should go, and provide the
text of the footnote. The footnote text will be
placed at the bottom of the present page in a somewhat
smaller font, and be separated from the main text by
a short horizontal rule
to conform with
convention. The footnote in the last line was typed
like this:
...rule\footnote\{See for yourself! It's easy ...work.\} to conform
No space was typed between the rule and the
\footnote, because we want the footnote
marker to appear right next to the last letter of the word.
Multiple footnotes
are
obtained just by using the \footnote command
again and again.
As part of our task of describing the logical structure of the document, we must indicate to LaTeXwhere to start sectional units. To do this we make use of the sectioning commands shown in table 2.4.
Table 2.4: LaTeXsectioning commands
Each sectioning command accepts a single argument--the section heading that is to be used. LaTeXwill provide the section numbering (and numbering of subsections within sections, etc.) so there is no need to include any number in the argument. LaTeXwill also take care of whatever spacing is required to set the new logical unit off from the others, perhaps through a little extra space and using a larger font. It will also start a new page in the case that a new chapter is begun.
The \part command is used for major subdivisions of substantial documents. The \paragraph and \subparagraph commands are, unfortunately confusing. They are used to section off a modest number of paragraphs of text--they don't start new paragraphs (remember that that was done by leaving a blank line in our input file). The names were retained for historical reasons.
It is always a good idea to plan/ the overall sectional structure of a document in advance, or at least give it a little thought. Not that it would be difficult to change your mind later (you could use the global replace feature of an editor, for instance), but so that you have a good idea of the structure that you have to describe to LaTeX.
The sectioning command that began the present sectional unit of this document was
\subsection\{Sectioning commands\}
and that was all that was required to get the numbered
section name and the table of contents entry.
There are occasions when you want a heading to have all the appearance of a particular sectioning command, but shouldn't be numbered as a section in its own right or produce a table of contents entry. This can be achieved through using the *-form/ of the command, as in \section*\{...\}. We'll see that many LaTeXcommands have such a *-form which modify their behaviour slightly.
Not only will LaTeXnumber your sectional units for you, it will compile a table of contents too. Just include the command \tableofcontents after the \begin\{document\} command and after the topmatter that should precede it.
LaTeXenvironmentsPerhaps the most powerful and convenient concept in the LaTeX syntax is that of an environment. We will see most of the ``heavy'' typesetting problems we will encounter can be best tackled by one or other of the LaTeXenvironments.
Some environments are used to display/ a portion of text, i.e. to set it off from the surrounding text by indenting it. The quote and verse environments are examples of these. The center environment allows us to centre portions of text, while the flushright environment sets small portions of text flush against the right margin.
But the true power of LaTeXbegins to show itself when we look at environments such as those that provide facilities for itemised or enumerated lists, complex tabular arrangements, and for taking care of figure and table positioning and captioning. What we learn here will also be applicable in typesetting some complicated mathematical arrangements in the next chapter.
All the environments are begun by a begin\{name\}
command and ended by an end\{name\}, where
name/ is the environment name. These commands also
serve as begin-group and end-group
markers, so that all commands are local to the present environment--they
cannot affect text outside the environment.
We can also have environment embedded within environment within environment and so on, limited only by memory available on the computer. We must, however, be careful to check that each of these nested/ environments is indeed contained within the one just outside of it.
em environmentWe start with a very simple environment, one which provides an alternative to the \em command. Remember that \em does not accept an argument; it applies to everything within its scope as dictated by the group within which it is used. This can be tricky if we wish to emphasise a large amount of text, for we may forget a group-delimiting brace and so upset the entire grouping structure of our document. In cases where we fear this might happen, we can proceed as follows.
\begin\{em\}
We must always be careful to match our group-delimiting
braces correctly. If the braces in a document are unevenly
matched then \LaTeX\ will become confused because we will
have, in effect, indicated different scopes than we
intended for commands.
\end\{em\}
which will give
0.8 We must always be careful to match our group-delimiting braces correctly. If the braces in a document are unevenly matched then LaTeXwill become confused because we will have, in effect, indicated different scopes than we intended for commands.
Although LaTeXdoesn't care too much for how we format our source file, it is obviously a good idea to lay it out logically and readably anyway. This helps minimise errors as well as aids in finding them. For this reason I have adopted the convention of always placing the environment \begin and \end commands on lines by themselves.
quote and quotation environmentsThis environment can be used to display a part of a sentence or paragraph, or even several paragraphs, in such a manner that the material stands out from the rest of the text. This can be used to enhance readability, or to simply emphasise something. Its syntax is simple:
0.05
Horace smiled and retaliated:
\begin\{quote\}
\em You can mock the non-WYSIWYG nature of \TeX\
all you like. You don't understand that that is
precisely what makes \TeX\ enormously more powerful
than that lame excuse for a typesetter you use.
And I'll bet that from start to finish of preparing
a document I'm quicker than you are, even if you
do type at twice the speed and have the so-called
advantage of WYSIWYG. In your case, what you see
is \{\em all\/\} you get!
\end\{quote\}
and then continued with composing his masterpiece of the
typesetting art.
produces the following typeset material:
0.05
0.8Horace smiled and retaliated:
You can mock the non-WYSIWYG nature of TeX all you like. You don't understand that that is precisely what makes TeXenormously more powerful than that lame excuse for a typesetter you use. And I'll bet that from start to finish of preparing a document I'm quicker than you are, even if you do type at twice the speed and have the so-called advantage of WYSIWYG. In your case, what you see is all/ you get!and then continued with composing his masterpiece of the typesetting art.
That is a much more readable manner of presenting Horace's piece of mind than embedding it within a regular paragraph. The quote environment was responsible for the margins being indented on both sides during the quote. This example has also been used to show how the commands that begin and end an environment restrict the scope of commands issued within that environment: The \em at the beginning of the quote did not affect the text following the quote. We have also learned here that if we use \em within already emphasised text, the result is roman type--and we don't require an italic correction here because the final letter of `all' was not sloping to the right.
The quotation environment is used in just the same way as the quote environment above, but it is intended for setting long quotations of several paragraphs. It would be suitable for quoting a few paragraphs from the text of some speech, for instance. LaTeXtreats the given text just like normal text that it has to set into paragraphs, except that it indents the margins a little.
verse environmentThis is provided to facilitate the setting of poetry. When within the verse environment, we use \newline (or \\) to end a line; and what would normally signify a new paragraph serves to indicate the start of a new stanza. Let's have a shot at some cheap poetry.
\begin\{verse\}
Roses are red\\
Violets are blue\\
I think \TeX\ is great\\
And so will you!
Roses are still red\\
Violets are still blue\\
I'm schizophrenic\\
And so am I.
\end\{verse\}
will produce the following stunningly-creative ``poem'':
0.8
Roses are red Violets are blue I think TeXis great And so will you!
Roses are still red Violets are still blue I'm schizophrenic And so am I.
center environmentThis environment allows the centring of consecutive lines of text, new lines being indicated by a \\. If you don't separate lines with the \\ command then you'll get a centred paragraph the width of the page, which won't look any different to normal. If only one line is to be centred, then no \\ is necessary.
The \{\tt center\} environment takes care of the vertical
spacing before and after it, so we don't need to leave any.
\begin\{center\}
If we leave no blank line after the\\
\{\tt center\} environment\\
then the ensuing text will not\\
be regarded as part of a new\\
paragraph, and so will not be indented.\\
\end\{center\}
In this case we left a blank line after the environment,
so the new text was regarded as starting a new paragraph.
gives the following text
0.8center environment takes care of the vertical spacing before and after it, so we don't need to leave any. If we leave no blank line after the center environment then the ensuing text will not be regarded as part of a new paragraph, and so will not be indented.
In this case we left a blank line after the environment, so the new text was regarded as starting a new paragraph.
flushright and flushleft environmentsThe flushright environment causes each line to be set with its last character against the right margin, without trying to stretch the line to to current text width. The flushleft environment is similar.
We can stop \LaTeX\ from justifying each line to both the
left and the right margins.
\begin\{flushright\}
The \{\tt flushright\} environment is\\
used for text with an even right margin\\
and a ragged left margin.
\end\{flushright\}
\begin\{flushleft\}
and the \{\tt flushleft\} environment is\\
used for text with an even left margin\\
and a ragged right margin.
\end\{flushleft\}
gives the desired display
0.8can stop LaTeXfrom justifying each line to both the left and the right margins. The flushright environment is used for text with an even right margin and a ragged left margin.
and the flushleft environment is used for text with an even left margin and a ragged right margin.
One must be wary not to lapse into ``word-processing'' mode when using these environments. Remember that pressing return at the end of a line in the input file does not serve to end the current line there, but just to indicate the end of another word. We have to use the \\ command to end a line.
verbatim environmentWe can simulate typed text using the verbatim environment. The \tt (typewriter text) type style can be used for simulating typed words, but runs into trouble if one of the characters in the simulated typed text is a specially reserved LaTeXcharacter. For instance, \{\tt type \newline\} would not have the desired effect because LaTeXwould interpret the \newline is an instruction to start a new line.
The verbatim environment allows the simulation of multiple typed lines. Everything/ within the environment is typeset in typewriter font exactly as it appears in our source file--obeying spaces and line breaks as in the source file and not recognising the existence of any special symbols.
begin\{verbatim\}
In the verbatim environment we can type anything
we like.
So we don't need to look out for uses of %,
, & etc,
nor will control sequences like newline have any
effect.
end\{verbatim\}
In the verbatim environment we can type anything we like. So we don't need to look out for uses of %, $, & etc, nor will control sequences like \newline have any effect.
The only thing that cannot be typed in the verbatim environment is the sequence \end\{verbatim\}. You might notice that I still managed to simulate that control sequence above. One can always get what you want in TeX, perhaps with a little creativity.
If we want only to simulate a few typed words, such as when I say to use \newline to start a new line, then the \verb command is used. This command has a slightly odd syntax, pressed upon it by the use for which it was intended. It cannot accept an argument, because we may want to simulate typed text that is enclosed by \{braces\}. What one does is to choose any character that is not/ in the text to be simulated, and use a pair of these characters as ``argument delimiters''. I usually use the SPMquot@" or " charachters, as I rarely have any other uses for them. Thus
0.8use SPMquot%" to obtain a % sign
is typed as
use \verb"\%" to obtain a \% signitemize, enumerate, description environments
LaTeXprovides three predefined list-making environment, and a ``primitive'' list environment for designing new list environments of your own. We shall just describe the predefined ones here.
There is delightfully little to learn in order to be able to create lists. The only new command is \item which indicates the beginning of a new list item (and the end of the last one if this is not the first item). This command accepts an optional argument (which means you'd enclose it in square brackets) that can be used to provide an item label. If no optional argument is given, then LaTeXwill provide the item label for you; in an itemize list it will bullet the items, in an enumerate list it will number the items, and in a list of descriptions the default is to have no label (which would look a bit odd, so you're expected to use the optional argument there).
Remember that \item is used to separate list items; it does not accept the list item as an argument.
\begin\{itemize\}
\item an item is begun with \verb@\item@
\item if we don't specify labels, then
\LaTeX\ will bullet the items for us
\item I indent lines after the first in the
input file, but that is just to keep things
readable. As always, \LaTeX\ ignores additional
spaces.
\item a blank line between items is ignored, for
\LaTeX\ is responsible for spacing items.
\item \LaTeX\ is in paragraph-setting mode when
it reads the text of an item, and so will
perform all the usual functions
\end\{itemize\}
produces the following itemised list:
0.8
Lists can also be embedded within one another, for they are just environments and we said that environments have this property. Remember that we must nest them in the correct order. We demonstrate with the following list, which also shows how to use the enumerate environment.
\noindent I still have to do the following things:
\begin\{enumerate\}
\item Sort out LAN accounts for people on the course
\begin\{itemize\}
\item Have new accounts created for those not already
registered on the LAN
\item Make sure all users have a personal directory
on the data drive
\item Give read and scan rights to users in the \TeX\
directories
\item Add users to the appropriate LAN print queues
\end\{itemize\}
\item Have a \TeX\ batch file added to a directory that
is on a public search path
\item Finish typing these course notes and proof-read them
\item Photocopy and bind the finished notes
\end\{enumerate\}
will give the following list
0.8 I still have to do the following things:
See how I lay the source file out in a readable fashion. This is to assist myself, not LaTeX.
The description environment is, unsurprisingly, for making lists of descriptions.
\begin\{description\}
\item[\tt itemize] an environment for setting itemised lists.
\item[\tt enumerate] an environment for setting numbered lists.
\item[\tt description] an environment for listing descriptions.
\end\{description\}
will typeset the following descriptions:
0.8
Note that the scope of the \tt commands used in the item labels was restricted to the labels.
tabbing environmentThis environment simulates tabbing on typewriters. There one chose the tab stops in advance (analysing the material to be typed for the longest item in each column) and typed entries consecutively, hitting the tab key to move to the next tab stop and return to move to the next line.
In the tabbing environment, we proceed similarly. We look for the worst-case line (that which will determine the desired tab stops) and use it to set the tabs by inserting \= control symbols at the points where we want tab stops. We then discard that line using \kill, since the worst-case line might not be the first line in the material we have to type. We then type each line, using \> to move to the next tab stop and \\ to end a line.
\begin\{tabbing\}
Cheddar cheese \= Recommended \= \$2.00 \kill
Green Ham \> Recommended \> \$2.00
Eggs \> 1 a week \> \$1.50
Cheddar cheese \> Hmmm \> \$0.80
Yak cheese \> Avoid \> \$0.05
\end\{tabbing\}
gives the following uniformly-tabbed table
0.8
Cheddar cheese = Recommended =2.00 Eggs > 1 a week > 1.50 Cheddar cheese ;SPMgt; Hmmm ;SPMgt; 0.80 Yak cheese > Avoid >
0.05
In the format line I chose the longest entry >from each of the prospective columns. I lined some of the \> commands up in the source just to keep things readable.
Remember that excess spaces are ignored. LaTeX sets the \killed line normally and sees where the tab stops requested will be needed in the typeset text. Note also that commands given within the tabbing environment are local to the current item.
Actually, we use the above approach in the case that we require uniformly tabbed columns. The format line is not compulsory, and we can define tab stops dynamically. See if you can make sense of the following.
\begin\{tabbing\}
Entry in position 1,1 \= Entry 1,2 \= Entry 1,3\\
Entry in position 2,1 \> Entry 2,2 \> Entry 2,3\\
Entry 3,1 \= Entry 3,2 \> Entry 3,3\\
Entry 4,1 \> Entry 4,2 \> Entry 4,3
\end\{tabbing\}
which produces
0.8
Entry in position 1,1 = Entry 1,2 = Entry 1,3 Entry in position 2,1 > Entry 2,2 > Entry 2,3 Entry 3,1 = Entry 3,2 > Entry 3,3 Entry 4,1 > Entry 4,2 > Entry 4,3
The are additional commands that can be used within the tabbing environment to achieve special effects, but we won't be discussing them here.
tabular environmentThe tabular environment is used to produce tables of items, particularly when the table is predominantly rectangular and when line drawing is required. LaTeXwill make most decisions for us; for instance it will align everything for us without having to be told which are the longest entries in each column.
This environment is the first of many that use the TeX``tabbing character'' &. This character is used to separate consecutive entries in a row of a table, array, etc. The end of a row is indicated in the usual manner, by using \\. In this way the individual cells of the table, or array, are clearly described to LaTeX, and it can analyse them to make typesetting decisions. Commands issued within a cell so defined are, again, local to that cell.
The tabular environment is also our first example of an environment with arguments. The arguments are given, in braces as usual, just after the closing brace after the environments name. In the case of tabular there is a single mandatory argument giving the justification of the entries in each column: l for left justified, r for right justified, and c for centred. There must be an entry for each column of the table, and there is no default. Let's start with a simple table.
\begin\{tabular\}\{llrrl\}
\bf Student name & \bf Number & \bf Test 1 & \bf Test 2 & \bf Comment\\
F. Basset & 865432 & 78 & 85 & Pleasing\\
H. Hosepipe & 829134 & 5 & 10 & Improving\\
I.N. Middle & 853931 & 48 & 47 & Can make it
\end\{tabular\}
will produce the following no-frills table
0.8
Note that a \\ was not necessary at the end of the last row. Also note that, once again, the alignment of the & characters was for human readability. It is conventional to set columns of numbers with right justification. The \bf directives apply only the entries in which they are given.
A | typed in the tabular environment's argument
causes a vertical line to be drawn at the indicated position
and extending for the height of the entire table. An
\hline given in the environment draws a horizontal
line extending the width of the table to be drawn at the
vertical position at which the command is given.
A \cline
-
draws a line spanning columns
i to j, at the vertical position at which the
command is given. A repeated line-drawing command
causes a double line to be drawn. We illustrate line
drawing in tables by putting some lines into our first
table. We will type this example in a somewhat expanded
form, trying to make it clear why the lines appear where they
do.
\begin\{tabular\}\{|l|l|r|r|l|\}
\hline
\bf Student name & \bf Number & \bf Test 1 & \bf Test 2 & \bf Comment\\
\hline
F. Basset & 865432 & 78 & 85 & Pleasing\\
\hline
H. Hosepipe & 829134 & 5 & 10 & Improving\\
\hline
I.N. Middle & 853931 & 48 & 47 & Can make it\\
\hline
\end\{tabular\}
which will give
0.8
That way of laying out the source file makes it clear where the lines will go. As we (by now) well know, the returns that we pressed after the \\s in typing this table might as well have been spaces as far as LaTeXis concerned. Thus it is common to have the \hline commands following the \\s on the input lines. We will do this in future examples.
The \multicolumn column can be used to overrule the overall format of the table for a few columns. The syntax of this command is
multicolumn
\{n /\}\{pos /\}\{item /\}
where n is the number of columns
of the original format that item/
is to span, and pos/ specifies the justification
of the new argument.
\begin\{tabular\}\{||l|c|c|c||\} \hline
\multicolumn\{4\}\{|c|\}\{\LaTeX\ size changing commands\}\\ \hline
Style option & 10pt (default) & \tt 11pt & \tt 12pt\\ \hline
\tt\bs footnotesize & 8pt & 9pt & 10pt\\ \hline
\tt\bs small & 9pt & 10pt & 11pt\\ \hline
\tt\bs large & 12pt & 12pt & 14pt\\ \hline
\end\{tabular\}
produces the following table:
Figures (diagrams, pictures, etc.) and tables (perhaps created with the tabular environment) cannot be split across pages. So LaTeXprovides a mechanism for ``floating'' them to a nearby place where there is room for them. This may mean that your figure or table may appear a little later in the document than its declaration in the source file might suggest. You can suggest to LaTeXthat it try to place the figure or table at the present position if there is room or, failing that, at the top or bottom of the present or following page. You can also ask for it to be presented by itself on a ``page of floats''.
You suggest these options to LaTeXthrough an optional argument to the environment. One lists a combination of the letters h, t, b, and p where
A combination of these indicates decreasing order of preference. The default is tbp. In this document I have tended to use htbp.
LaTeXwill also number and caption a figure or table for you, and compile a list of tables and a list of figures. Just include \listoffigures and \listoftables next to your \tableofcontents command at the beginning of the document. To caption a table of figure, include \caption\{caption text\} just before the \end\{table\} or \end\{figure\} command. Here's a sample source file.
\begin\{table\}[htbp]
\begin\{tabular\}\{lrll\}
...
\end\{tabular\}
\caption\{Mark analysis\}
\end\{table\}
To leave space for a figure that will inserted by some other means at a later date, we can use the \vspace command:
\begin\{figure\}[htbp]
\vspace\{9.5cm\}
\caption\{An artists impression\}
\end\{figure\}
Including graphics files prepared with drawing packages is possible, but beyond the scope of this introduction.
| Return to front |