


















Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!



















Jon Warbrick
Bibliography........................................ 26
List of Tables
1 Greek letters..................................... 20 2 Binary operation symbols.............................. 20 3 Relation symbols.................................. 20 4 Large delimiters................................... 21 5 Delimiters...................................... 21 6 Arrow symbols................................... 21 7 Miscellaneous symbols............................... 21 8 Log-like symbols.................................. 22 9 Math mode accents................................. 22 10 Variable-sized symbols............................... 22 11 LATEX math constructs................................ 22 12 AMS miscellaneous symbols............................ 22 13 AMS Greek and Hebrew.............................. 23 14 AMS delimiters................................... 23 15 AMS arrows..................................... 23 16 AMS negated arrows................................ 23 17 AMS binary operators................................ 23 18 AMS binary relations................................ 24 19 AMS negated binary relations........................... 24
1 Introduction
This document is an attempt to give you all the essential information that you will need in or- der to use the LATEX document preparation system[1].^1. Only basic features are covered, and a vast amount of detail has been omitted. In a document of this size it is not possible to include everything that you might need to know, and if you intend to make extensive use of the program you should refer to a more complete reference. Attempting to produce complex documents using only the information found below will require much more work than it should, and will probably produce a less than satisfactory result. The main reference for LATEX is The LATEX User’s guide and Reference Manual by Leslie Lamport[1]. This contains all the information that you will ever need to know about the program, and you will need access to a copy if you are to use LATEX seriously. Both the Manual and this document avoid mentioning anything that depends on the particular computer system that you are using. This is because LATEX is available on a number of systems and they all differ in one way or another. Instead, they both refer to a local guide for their particular system.
2 How Does LATEX Work?
In order to use LATEX, you generate a file containing both the text that you wish to typeset and instructions to tell LATEX how you want it to appear. You will normally create this file using your system’s text editor. You can give the file any name you like, but it should end “.tex” to identify the file’s contents. You then get LATEX to process the file, and it creates a new file of typesetting
(^1) For those readers who have some familiarity with LATEX, this document assumes the LATEX 2ε release of January 1994 or later
1: % This is a small sample LaTeX input file (Version of 10 April 1994) 2: % 3: % Use this file as a model for making your own LaTeX input file. 4: % Everything to the right of a % is a remark to you and is ignored by LaTeX. 5: 6: % The Local Guide tells how to run LaTeX. 7: 8: % WARNING! Do not type any of the following 10 characters except as directed: 9: % & $ # % _ { } ˆ ˜
10: 11: \documentclass{article} % Your input file must contain these two lines 12: \begin{document} % plus the \end{document} command at the end. 13: 14: 15: \section{Simple Text} % This command makes a section title. 16: 17: Words are separated by one or more spaces. Paragraphs are separated by 18: one or more blank lines. The output is not affected by adding extra 19: spaces or extra blank lines to the input file. 20: 21: Double quotes are typed like this: ‘‘quoted text’’. 22: Single quotes are typed like this: ‘single-quoted text’. 23: 24: Long dashes are typed as three dash characters---like this. 25: 26: Emphasized text is typed like this: \emph{this is emphasized}. 27: Bold text is typed like this: \textbf{this is bold}. 28: 29: \subsection{A Warning or Two} % This command makes a subsection title. 30: 31: If you get too much space after a mid-sentence period---abbreviations 32: like etc.\ are the common culprits)---then type a backslash followed by 33: a space after the period, as in this sentence. 34: 35: Remember, don’t type the 10 special characters (such as dollar sign and 36: backslash) except as directed! The following seven are printed by 37: typing a backslash in front of them: $ & # % _ { and }. 38: The manual tells how to make other symbols. 39: 40: \end{document} % The input file ends with this command.
Figure 1: A Sample LATEX File
1 Simple Text
Words are separated by one or more spaces. Paragraphs are separated by one or more blank lines. The output is not affected by adding extra spaces or extra blank lines to the input file. Double quotes are typed like this: “quoted text”. Single quotes are typed like this: ‘single- quoted text’. Long dashes are typed as three dash characters—like this. Italic text is typed like this: this is italic text. Bold text is typed like this: this is bold text.
If you get too much space after a mid-sentence period—abbreviations like etc. are the common culprits)—then type a backslash followed by a space after the period, as in this sentence. Remember, don’t type the 10 special characters (such as dollar sign and backslash) except as directed! The following seven are printed by typing a backslash in front of them: $ & # % { and }. The manual tells how to make other symbols.
Figure 2: The Result of Processing the Sample File
There are a number of words in the file that start with ‘\’ (see lines 9, 10 and 13). These are LATEX commands and they describe the structure of your document. There are several things that you should realize about these commands:
\command{text}
In this case, text is called the “argument” of the command. The \section command is like this (see line 13). Sometimes you have to use curly brackets ‘{}’ to enclose the argument, sometimes square brackets ‘[]’, and sometimes both. There is method behind this apparent madness, but for the time being you should be sure to copy the commands exactly as given.
12pt prints the document using twelve-point type for the running text rather than the ten-point type normally used. Twelve-point type is about twenty percent larger than ten-point.
twoside causes documents in the article or report styles to be formatted for printing on both sides of the paper. This is the default for the book style.
twocolumn produces two columns of text on each page.
titlepage causes the \maketitle command to generate a title on a separate page for docu- ments in the article style. A separate page is always used in both the report and book styles. There is further option which is very useful in European countries. The a4paper option causes the output in all of the standard styles to be adjusted to fit correctly on A4 paper. (LATEX was designed in America where the standard paper is shorter and slightly wider than A4; without this option you will find that your output looks a little strange.)
5 Environments
We mentioned earlier the idea of identifying a quotation to LATEX so that it could arrange to typeset it correctly. To do this you enclose the quotation between the commands \begin{quotation} and \end{quotation}. This is an example of a LATEX construction called an environment. A number of special effects are obtained by putting text into particular environments.
There are two environments for quotations: quote and quotation. quote is used either for a short quotation or for a sequence of short quotations separated by blank lines:
US presidents have been known for their pithy remarks:
The buck stops here. I am not a crook.
US presidents have been known for their pithy remarks: \begin{quote} The buck stops here.
I am not a crook. \end{quote}
Use the quotation environment for quotations that consist of more than one paragraph. Para- graphs in the input are separated by blank lines as usual:
Here is some advice to remember:
Environments for making quotations can be used for other things as well. Many problems can be solved by novel ap- plications of existing environments.
Here is some advice to remember: \begin{quotation} Environments for making quotations can be used for other things as well.
Many problems can be solved by novel applications of existing environments. \end{quotation}
Text can be centred on the page by putting it within the center environment, and it will appear flush against the left or right margins if it is placed within the flushleft or flushright en- vironments. Notice the spelling of center—unfortunately LATEX doesn’t understand the British English spelling.
Text within these environments will be formatted in the normal way; in particular, the ends of the lines that you type are regarded as spaces. To indicate a new line, you type the \ command. For example:
one two three four five
\begin{center} one two three \ four \ five \end{center}
There are three environments for constructing lists. In each one, each new item is begun with an \item command. In the itemize environment, the start of each item is given a marker, while, in the enumerate environment, each item is marked by a number. These environments can be nested within each other, in which case the amount of indentation used and the marker are adjusted accordingly:
\begin{itemize} \item Itemized lists are handy. \item However, don’t forget \begin{enumerate} \item The ‘item’ command. \item The ‘end’ command. \end{enumerate} \end{itemize}
The third list-making environment is description. In a description you specify the item labels inside square brackets after the \item command. For example:
Three animals that you should know about are:
gnat A small animal that causes no end of trouble.
gnu A large animal that causes no end of trouble.
armadillo A medium-sized animal.
Three animals that you should know about are: \begin{description} \item[gnat] A small animal that causes no end of trouble. \item[gnu] A large animal that causes no end of trouble. \item[armadillo] A medium-sized animal. \end{description}
Sometimes you will want to include text exactly as it appears on a terminal screen. For example, you might want to include part of a computer program. Not only do you want LATEX to stop playing around with the layout of your text, you also want to be able to type all the characters on
7 Sectioning Commands and Tables of Contents
Technical documents, like this one, are often divided into sections. Each section has a heading containing a title and a number for easy reference. LATEX has a series of commands that will allow you to identify different sorts of sections. Once you have done this, LATEX takes on the responsibility of laying out the title and of providing the numbers. The commands that you can use are: \chapter \subsection \paragraph \section \subsubsection \subparagraph
The naming of these last two is rather unfortunate, since they do not really have anything to do with ‘paragraphs’ in the normal sense of the word: they are just lower levels of section. In most document styles, headings made with \paragraph and \subparagraph are not numbered. \chapter is not available in document style article. The commands should be used in the order given, since sections are numbered within chapters, subsections within sections, etc.. A seventh sectioning command, \part, is also available. Its use is always optional, and it is used to divide a large document into series of parts. It does not alter the numbering used for any of the other commands. Including the command \tableofcontents in your document will cause a contents list to be included, containing information collected from the various sectioning commands. You will notice that each time your document is run through LATEX the table of contents is always made up of the headings from the previous time you ran LATEX on it. This is because LATEX collects information for the table as it processes the document, and then includes it the next time it is run. This can sometimes mean that the document has to be processed through LATEX twice to get a correct table of contents.
8 Producing Special Symbols
You can include in your LATEX document a wide range of symbols that do not appear on your keyboard. For a start, you can add an accent to any letter:
o ` \‘{o} o˜ \˜{o} oˇ \v{o} o¸ \c{o} o´ \’{o} ¯o ={o} o ˝ \H{o} o. \d{o} oˆ \ˆ{o} o ˙ .{o} oo \t{oo} o ¯
\b{o} o ¨ "{o} o˘ \u{o} Several other symbols are available and are generated using the following commands: † \dag § \S ©c \copyright ‡ \ddag ¶ \P £ \pounds œ \oe Œ \OE æ \AE Æ \AE a˚ \aa A˚ \AA ø \o Ø \O ł \l Ł \E ß \ss ¿ ?‘ ¡ !‘... \ldots LATEX \LaTeX
There is also a \today command that prints the current date. When you use these commands remember that LATEX will ignore any spaces that follow them, so that you can type ‘\pounds 20 ’ to get ‘£20’. However, if you type ‘\LaTeX is wonderful’ you will get ‘LATEXis wonderful’— notice the lack of space after LATEX. To overcome this problem you can follow any of these
commands by a pair of empty braces and then any spaces that you wish to include, and you will see that \LaTeX{} really is wonderful! (LATEX really is wonderful!). Finally, LATEX ‘math’ mode, normally used to layout mathematical formulae, gives access to an even larger range of symbols, including the upper and lower case greek mathematical alphabet, calligraphic letters, mathematical operators and relations, arrows and a whole lot more. This will be discussed in Section 13.
9 Titles
Most documents have a title. To title a LATEX document, you include the following commands in your document, usually just after \begin{document}.
\title{required title} \author{required author} \date{required date} \maketitle
If there are several authors, then their names should be separated by \and in the \author com- mand; they can also be separated by \ if you want them to be centred on different lines. If the \date command is left out, then the current date will be printed.
\title{Essential \LaTeX} \author{Jon Warbrick \and A N Other} \date{14th February 1988} \maketitle
Essential LATEX
J Warbrick A N Other
14th February 1988 The exact appearance of the title varies depending on the document style. In the report and book styles, the title appears on a page of its own. In the article style, it normally appears at the top of the first page; use the class option titlepage to alter this (see Section 4).
10 Tabular Material
Because LATEX will almost always convert a sequence of spaces into a single space, it can be rather difficult to lay out tables. See what happens in this example
Income Expenditure Result 20s 0d 19s 11d happiness 20s 0d 20s 1d misery
\begin{flushleft} Income Expenditure Result \ 20s 0d 19s 11d happiness \ 20s 0d 20s 1d misery \end{flushleft}
The tabbing environment overcomes this problem. Within it, you set tab-stops and tab to them much as you would do on a typewriter. Tab-stops are set with the = command, and the > command moves to the next stop. The \ command is used to separate each line. A line that ends in \kill produces no output, and can be used to set tab-stops:
Income Expenditure Result 20s 0d 19s 11d Happiness 20s 0d 20s 1d Misery
\begin{tabbing} Income =Expenditure = \kill Income >Expenditure >Result \ 20s 0d >19s 11d >Happiness \ 20s 0d >20s 1d >Misery \end{tabbing}
page with not enough space left? Similarly, what do you do when you want to leave space for a photograph to be pasted in? When you are typing the text, you do not know where LATEX will start a new page, so it is often very difficult to leave space just where you want. LATEX solves this by a system of ‘floats’, objects that will be placed in a nice position on the page, but not necessarily exactly where you put it in your file. They will often be placed at the bottom of the current page, or at the top of the next, or on a page by themselves, if they need that much space. LATEX lets you specify two sorts of float, namely tables and figures ; in each of them you can specify a caption. The following shows how you would set up space for a figure in which you wanted to leave 3 inches of space, followed by a caption:
\begin{figure} \vspace{3in} \caption{A Photograph of my Subject} \end{figure}
Figures and tables are automatically numbered, like sections; just as \tableofcontents lists your sections, subsections, etc. with their page numbers, \listoffigures and \listoftables will list the figures and tables with their captions.
12 Cross-References and Citations
One of the most useful things LATEX can do for you is to to automatically generate a section, page, figure, table, or equation number in a cross-reference. For example, to refer to Section 4 of this report (on document styles) and Figure 2 (the output of processing sample.tex) in this sentence, the commands used were:
to refer to Section˜\ref{sec:styles} of this report (on document styles) and Figure˜\ref{fig:result} (the output of processing
You will see that the \ref command inserted the cross-references number into the printed docu- ment. The ˜ simply inserts a space while prohibiting LATEX from breaking a line. Of course, to refer to a cross-reference, there must be an indication in the LATEX input file of the point being referred to. This is done via the \label command. The label for a section is most conveniently done immediately after the section heading, as in:
\section{Document Classes and Options} \label{sec:styles}
and that for a figure or table in or immediately following the \caption command:
\caption{The Result of Processing the Sample File} \label{fig:result}
Any text may be used in \label and \ref commands, though the convention impled above is a good one to follow. Page references use \label in the same way, but are referred to using \pageref instead of \ref. In much the same way that you can refer to other parts of your document from the LATEX file symbolically, you may cite other documents. To do this, you include the \cite command in your text, as in
The book by Lamport \cite{Lamport-LaTeX} is the principal reference work on \LaTeX.
The argument to the \cite command, known as the citation key , is used to uniquely identify a paper, book, or other document that has been described in a bibliographic database. Having cited other work from your document, you can generate a list of references by includ- ing the commands
\bibliographystyle{plain} \bibliography{mybib1,mybib2}
where you want the list to appear. The \bibliographystyle command tells LATEX how you want the citations to appear, the standard ones being:
plain Citations are sorted alphabetically in the list, with each entry being assigned a number; entries in the text are indicated in square brackets.
unsrt Citations are ordered in the reference list in the order of their first appearance and as- signed a number; entries in the text are indicated in square brackets.
alpha Citations are sorted alphabetically in the list but have labels like “Lam86” instead of a number; the same label appears in the text in square brackets.
abbrev Citations are similar to alpha but are more compact (e.g., by abbreviating month and journal names).
The argument of the \bibliography command is a comma-separated list of filenames, which should end in .bib (i.e., mybib1.bib and mybib2.bib in the example above). These files contain the expanded references referred to by the \cite commands. A full description of the format of these .bib files and how the citations are converted to a LATEX-compatible form are beyond the scope of this (introductory) guide; details are given in Appendix B of Lamport’s book.
13 Mathematical Typesetting
Mathematics is treated by TEX completely differently from ordinary text. There are two special modes for mathematics, known as math mode and display math mode.
Math mode commands are surrounded by (... ) or by $... $.
Some mathematics set inline 2 × 3 = 6. Note that spaces in the input file are ignored in math mode.
Some mathematics set inline ( 2\times 3 = 6 ). Note that spaces in the input file are ignored in math mode.
Display math mode commands are surrounded by [... ].
A larger equation to be displayed on a line by itself.
f ( x ) =
∞ ∑ i = 0
f ( i )( x ) i!
A larger equation to be displayed on a line by itself. [ f(x) = \sum_{i=0}ˆ{\infty}\frac{fˆ{(i)}(x)}{i!} ]
There is a variant of display math mode, the equation environment, which automatically gener-
\mathbf produces bold face roman letters. If you wish to have bold f ace math italic letters, and bold face Greek letters and mathematical symbols, use the \boldmath command before going into math mode. This changes the default math fonts to bold.
x = 2 π ⇒ x ' 6. 28 x = 2 π ⇒ x ' 6. 28 x = 2 π ⇒ x ' 6. 28 (^ x = 2\pi^ \Rightarrow^ x \simeq^ 6.28 ) (\mathbf{x} = 2\pi \Rightarrow x \simeq 6.28 ) {\boldmath (x = \mathbf{2}\pi \Rightarrow x \simeq{\mathbf{6.28}} )}
There is also a calligraphic font for upper case letters; these are produced by the \mathcal com- mand:
14 What about $’s?
there has been no mention of $ and $$. In these systems math mode is surrounded by $’s and display math mode is surrounded by $$. This has certain drawbacks over the LATEX system as it is difficult for your text editor to match $’s as it is hard to tell which ones are starting math mode and which are ending it. TEX will also get confused if you miss a $ out. The (incorrect) input
let (a,b,c)$ be a Pythagorean triple, i.e.\ three integers such that $aˆ{2}+bˆ{2}=cˆ{2}$.
produces the slightly mysterious error message
! Missing $ inserted.
Note that it reports the wrong error and in the wrong place, the use of the ˆ command out of math mode. TEX has typeset ‘be a... such that’ in math mode and exited math mode at the $ after ‘such that’. If you had made the equivalent LATEX error, LATEX has a better idea of what you indended:
let (a,b,c)) be a Pythagorean triple, i.e.\ three integers such that (aˆ{2}+bˆ{2}=cˆ{2})
The error message may still be unintelligable, but at least it reports the error in the right place, you have used ) to end math mode when you were not in math mode (as you omitted the ( which should have been before the (a,b,c)).
LaTeX error. See LaTeX manual for explanation. Type H
)...ifinner $\else @badmath \fi \else @badmath \fi l.56 let (a,b,c)) be a Pythagorean triple, i.e.\ three integers such that ...
?
The single dollar is sometimes useful for small sections of math.
Let G be a p -group Let^ $G$ be a^ $p$-group
The double dollar is not always equivalent to [ ... ], and so should not be used if you want your LATEX file to be compatible with different styles and options (try the fleqn class option).
The following tables show most of the symbols available from the standard LATEX symbol fonts. Negations of the relational symbols can be made with the \not command:
G 6 ≡ H $G^ \not\equiv^ H$
In the appendix we have brought together a set of tables regrouping all standard LATEX symbols
when you specify the amssymb package.
15 Letters
Producing letters is simple with LATEX. To do this you use the document style letter. You can make any number of letters with a single input file. Your name and address, which are likely to be the same for all letters, are given once at the top of the file. Each letter is produced by a letter environment, having the name and address of the recipient as its argument. The letter itself begins with an \opening command to generate the salutation. The letter ends with a \closing command. You can use the commands \encl and \cc to generate lists of enclosures and people to whom you are sending copies. Any text that follows the \closing must be proceeded by a \ps command. This command produces no text—you’ll have to type “P.S.” yourself—but is needed to format the additional text correctly. An example will make this clearer: \documentstyle{letter} \begin{document}
\address{1234 Avenue of the Armadillos \ Gnu York, G.Y. 56789} \signature{R. (Ma) Dillo \ Director of Cuisine}
\begin{letter}{G. Natheniel Picking \ Acme Exterminators \ Illinois}
\opening{Dear Nat,}
I’m afraid that the armadillo problem is still with us. I did everything ... ... and I hope that you can get rid of the nasty beasts this time.
Chapter 6 of Lamport’s book: it contains a list of all of the error messages that you are likely to encounter, together with some suggestions as to what may have caused them. Some of the most common mistakes that cause errors are:
A single error can get LATEX so confused that it reports a series of spurious errors as a result. If you have an error that you understand, followed by a series that you don’t, then try correcting the first error—the rest may vanish as if by magic. Sometimes LATEX may write a * and stop without an error message. This is normally caused by a missing \end{document} command, though other errors can cause it. If this happens type \stop and press the return key. Finally, LATEX will sometimes print warning messages. They report problems that were not bad enough to cause LATEX to stop processing, but nevertheless may require investigation. The most common problems are ‘overfull’ and ‘underfull’ lines of text. A message like: Overfull \hbox (10.58649pt too wide) in paragraph at lines 172-- []\tenrm Mathematical for-mu-las may be dis-played. A dis-played
indicates that LATEX could not find a good place to break a line when laying out a paragraph. As a result, it was forced to let the line stick out into the right-hand margin, in this case by 10.6 points. Since a point is 1/ 72 .27 inches, this may be rather hard to see, but it will be there nonetheless. This particular problem happens because LATEX is rather fussy about line breaking, and it would rather generate a line that is too long than generate a paragraph that doesn’t meet its high standards. The simplest way around the problem is to enclose the entire offending paragraph between \begin{sloppypar} and \end{sloppypar} commands. This tells LATEX that you are happy for it to break its own rules while it is working on that particular bit of text. Alternatively, messages about “Underfull \hboxes” may appear. These are lines that had to have more space inserted between words than LATEX would have liked. In general there is not much that you can do about these. Your output will look fine, even if the line looks a bit stretched. About the only thing you could do is to re-write the offending paragraph!
17 A Final Reminder
You now know enough LATEX to produce a wide range of documents. But this document has only scratched the surface of the things that LATEX can do. This entire document was itself produced with LATEX (with no sticking things in or clever use of a photocopier) and even it hasn’t used all the features that it could. From this you may get some feeling for the power that LATEX puts at your disposal. Please remember what was said in the introduction: if you do have a complex document to produce then go and read Lamport’s book. You will be wasting your time if you rely only on what you have read here. Once you have used LATEX for some time, you might want to know how to use the many style file extensions, which have been developed to aid LATEX users to typeset their documents. This and much else (like how to use MakeIndex , for generating indices, or BIBTEX, for managing your bibliographies) is covered in The LATEX Companion [3]. Finally the final word about TEX is Knuth’s TEX book [2]. And one other warning: having dabbled with LATEX your documents will never be the same again...
A Mathematical symbols
α \alpha β \beta γ \gamma δ \delta ε \epsilon ε \varepsilon ζ \zeta η \eta θ \theta ϑ \vartheta ι \iota κ \kappa λ \lambda μ \mu ν \nu ξ \xi o o π \pi ϖ \varpi ρ \rho ρ \varrho σ \sigma ς \varsigma τ \tau υ \upsilon φ \phi ϕ \varphi χ \chi ψ \psi ω \omega Γ \Gamma ∆ \Delta Θ \Theta Λ \Lambda Ξ \Xi Π \Pi Σ \Sigma ϒ \Upsilon Φ \Phi Ψ \Psi Ω \Omega
Table 1: Greek letters
± \pm ∩ \cap \diamond ⊕ \oplus ∓ \mp ∪ \cup 4 \bigtriangleup \ominus × \times ] \uplus 5 \bigtriangledown ⊗ \otimes ÷ \div u \sqcap / \triangleleft \oslash ∗ \ast t \sqcup. \triangleright \odot ? \star ∨ \vee \lhd a^ © \bigcirc ◦ \circ ∧ \wedge \rhd a^ † \dagger
Table 2: Binary operation symbols
≤ \leq ≥ \geq ≡ \equiv |= \models ≺ \prec \succ ∼ \sim ⊥ \perp \preceq \succeq ' \simeq | \mid \ll \gg \asymp ‖ \parallel ⊂ \subset ⊃ \supset ≈ \approx ./ \bowtie ⊆ \subseteq ⊇ \supseteq ∼= \cong 1 \Join < \sqsubset = \sqsupset 6 = \neq ^ \smile v \sqsubseteq w \sqsupseteq . = \doteq _ \frown ∈ \in 3 \ni ∝ \propto = = ` \vdash a \dashv < < > >
Table 3: Relation symbols