Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
How to use L
Assistant Professor Department of Electronics & Telecommunication VIIT, Pune February 2012
Ketan J. Raut
Abstract
A A Welcome to L TEX 2", the new standard version of the L TEX Document Preparation System. A This document describes how to use L TEX. However, this document is A only a brief introduction of the features of the L TEX. It is not a reference A A manual for LTEX 2" nor is it a complete introduction to L TEX.
Contents
1 Introduction A 1.1 What is L TEX? . . A 1.2 Why LTEX? . . . . 1.3 What is TeXworks? 1.4 Installation . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . . . . . . . . . . . . . . . . . . . .
5 5 5 5 6 7 7 7 8 8 8 9 9 10 10 10 10 11 11 11 12 12 12 13
2 Document Structure A 2.1 Required Components of a L TEX Document . . . . . . . . . 2.2 Document Classes . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Document Class Options . . . . . . . . . . . . . . . . 2.2.2 Example 1 . . . . . . . . . . . . . . . . . . . . . . . . 2.2.3 Example 2 . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Page Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5 Font Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.1 Font Shape . . . . . . . . . . . . . . . . . . . . . . . 2.5.2 Font Weight . . . . . . . . . . . . . . . . . . . . . . . 2.5.3 Font Types . . . . . . . . . . . . . . . . . . . . . . . 2.5.4 Font Sizes . . . . . . . . . . . . . . . . . . . . . . . . 2.6 Parts of a Document . . . . . . . . . . . . . . . . . . . . . . 2.6.1 Title . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6.2 Example 3 . . . . . . . . . . . . . . . . . . . . . . . . 2.6.3 Table of Contents, List of Figures, and List of Tables 2.6.4 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . 2.7 Dividing the Document . . . . . . . . . . . . . . . . . . . . .
3 Text Formatting 3.1 Text Positioning . . . 3.2 Extended Quotation 3.3 Bulleted Lists . . . . 3.3.1 Example 4: . 3.4 Numbered Lists . . . 3.4.1 Example 5: . 4 Tables and Arrays 4.1 Constructing Tables 4.1.1 Example 6: . 4.1.2 Example 7: . 4.2 Constructing Arrays 4.2.1 Example 8: .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
14 14 14 14 15 15 15 16 16 16 17 17 18 19 19 19 20 20 22 22 23 23 23 24 24 24 24 25
5 Including Graphics 5.1 Graphics Package . . . . . . . . . . . . . . . 5.2 Including Graphics Within Your Document . 5.2.1 Figure Placement . . . . . . . . . . . 5.2.2 Example 9: . . . . . . . . . . . . . . 6 Mathematical Typesetting 6.1 Mathematical Formulas . . 6.2 Exponents and Subscripts 6.3 Above and Below . . . . . 6.3.1 Example 10: . . . . 6.4 Sums and Integrals . . . . 6.5 Limits . . . . . . . . . . . 6.6 Multi-line Equations . . . 6.6.1 Example 11: . . . . 6.7 Text in Math . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
List of Figures
5.1 Hi! Recognized, this is me . . . . . . . . . . . . . . . . . . . . 21
List of Tables
4.1 Observed values of x and y . . . . . . . . . . . . . . . . . . . . 17
Chapter 1 Introduction
1.1
A What is L T EX?
A L TEX is a typesetting program, designed to produce publication-quality typeset documents. It is an extension of the original program TEX written by Donald Knuth. In most word processors (like MS Word) all operations are integrated into A a single package. However in L TEX, we type the text and the formatting commands in a text editor and then compile it.
1.2
A Why L T EX?
Creates beautifully typeset technical documents. Very easy to create documents containing lot of mathematics. Even for ordinary text, if you want A your document to look really beautiful then L TEX is the natural choice.
1.3 What is TeXworks?
A A A text editor for L TEX to create documents with L TEX and to typeset them to PDF. Oers at rst sight only some limited tools for text editing. Runs on Linux, Mac OS as well as Windows.
1.4
Installation
One needs to install a TEX distribution; a bunch of programmes and other necessary les which will be automatically called by TeXworks during its work. For Windows: an often used distribution is MiKTeX (http://www.miktex.org/).
A Every L TEX document must contain the following three components. Everything else is optional even text.
ndocumentclass[options]fclassg Further optional global commands and options, such as nusepackagefpackagenameg nbeginfdocumentg text mixed with typesetting commands nendfdocumentg
A NOTE: L TEX is case sensitive. Enter all commands in lower case unless explicitly directed to do otherwise.
2.2
Document Classes
ndocumentclassfslidesg ndocumentclassfprocg
2.2.1 Document Class Options
11pt
12pt
For example:
ndocumentclass[11pt]farticleg
Paper Size letterpaper Page Formats onecolumn
2.2.2
a4paper
legalpaper etc.
twocolumn
Example 1
ndocumentclassfarticleg nbeginfdocumentg
2.2.3
A We have seen that to typeset something in L TEX, we type in the text to be A typeset together with some LTEX commands. Words must be separated by spaces (does not matter how many) and lines maybe broken arbitrarily. The end of a paragraph is specied by a blank line in the input. In other words, whenever you want to start a new paragraph, just leave a blank line and proceed.
2.3
Packages
Additional structures are dened by packages, which are loaded by the nusepackage[options]fpackage nameg command. nusepackageflatexsymg - loads the latexsym package, which denes commands to produce certain special math symbols.
Standard Packages
npagestylefplaing is the default, which puts the page number at the center of the bottom of the page and provides no headings. npagestylefemptyg provides neither page numbers nor headings. npagestylefheadingsg will provide page numbers and headings from any nsections that you are using. npagestylefmyheadingsg will provide page numbers and custom headings.
Moreover, we can customize the style for the current page by using the command nthispagestylefstyleg.
2.5
2.5.1
Font Style
Font Shape
10
2.5.4
Font Sizes
You can use the following commands to modify the current font size:
\tiny \scriptsize \footnotesize \normalsize \large \Large \LARGE \huge \Huge
2.6
Parts of a Document
Documents (especially longer ones) are divided into chapters, sections and so on. There may be a title part (sometimes even a separate title page) and an abstract.
2.6.1 Title
The \title" part of a document usually consists of the name of the document, the name of author(s) and sometimes a date. To produce a title, we make use of the commands
11
2.6.2
Example 3
\title{Title} \author{Author 1\\ Address line 1\\ Address line 2\\ Address line 3 \and Author 2\\ Address line 1\\ Address line 2\\ Address line 3} \date{Month Date, Year} \maketitle
2.6.3 Table of Contents, List of Figures, and List of Tables
A table of contents is a special list which contains the section numbers and corresponding headings, together with the page numbers on which they begin. ntableofcontents produces a table of contents. nlistogures and nlistoftables A produce a list of gures and list of tables respectively. Standard L TEX can automatically create these three contents lists.
2.6.4 Abstract
In the document classes article and report, an abstract can be produced by the commands
nbeginfabstractg
Abstract Text nendfabstractg The abstract should come immediately after your nmaketitle command, but before any ntableofcontents command.
12
2.7
A book is usually divided into chapters and chapters are divided into sections, sections into subsections and so on. Sectioning commands in the book, report, and article class:
\chapter (not in article class) \section \subsection \subsubsection \paragraph \subparagraph
13
The command nbeginfcenterg ... nendfcenterg typesets the text between them exactly at the center of the page. The command nbeginf
ushrightg ... nendf
ushrightg typesets text
ush with the right margin. The command nbeginf
ushleftg ... nendf
ushleftg places the enclosed text ush with the left margin.
3.2 Extended Quotation
If you are going to include an extended quotation from another source, it is important to indicate the dierence between the quotation and your words. A In L TEX, surround the quotation with nbeginfquoteg and nendfquoteg
3.3 Bulleted Lists
To create a bulleted list, surround the information with a nbeginfitemizeg and an nendfitemizeg, and begin each item with an nitem.
14
3.3.1
Example 4:
\begin{itemize} \item A bulleted item. \item Another bulleted item. \begin{itemize} \item A nested bulleted item. \item Another nested bulleted item. \end{itemize} \item You get the idea. \end{itemize}
3.4
Numbered Lists
To create a numbered list, surround the information with a nbeginfenumerateg and an nendfenumerateg, and begin each item with an nitem.
3.4.1 Example 5:
\begin{enumerate} \item A numbered item. \item Another numbered item. \begin{enumerate} \item A nested numbered item. \item Another nested numbered item. \end{enumerate} \item You get the idea. \end{enumerate}
15
To construct a table, surround the entries with a nbeginftabulargfjusticationg command and an nendftabularg command. The justication should consist of `l' for left justication, `c' for centered justication, or `r' for right justication. Separate column entries by a &, and end each line with a nn. Use nhline to construct a horizontal line, and separate the l, c, and rs by a l wherever you want a vertical line.
4.1.1 Example 6:
\begin{tabular}{|r|c|l|} \hline Right & Center & Left\\ \hline alpha&beta&gamma\\ delta&epsilon&zeta\\ eta&theta&iota\\ \hline \end{tabular}
Right Center Left alpha beta gamma will produce delta epsilon zeta eta theta iota 16
4.1.2
Example 7:
\begin{table}[h] \begin{center} \caption{Observed values of $x$ and $y$} \label{tabxy} \begin{tabular}{|c|c|c|c|} \hline Value of $x$ & 1 & 2 & 3\\ \hline Value of $y$ & 1 & 8 & 27\\ \hline \end{tabular} \end{center} \end{table}
will produce Table 4.1: Observed values of x and y Value of x 1 2 3 Value of y 1 8 27 Two possible relations betweeen x and y satisfying the data in Table 4.1 are y = x3 and y = 6x2 11x + 6.
4.2 Constructing Arrays
To construct an array, surround the entries with a nbeginfarraygfjusticationg command and an nendfarrayg command. The justication should consist of `l' for left justication, `c' for centered justication, or `r' for right justication. Separate column entries by an &, and end each line with a nn. If your array is a matrix, you can surround it with large parentheses nleft( and nright).
17
4.2.1
Example 8:
will produce
0 1
@ A
18
Graphics Package:
Use nincludegraphicsfgraphicleg command to include your graphic le in your document. You can also specify the height and width: nincludegraphics[height = 2in, width = 3in] fgraphicleg. The nDeclareGraphicsExtensions comA mand tells L TEXwhich extensions to try if a le with no extension is specied in the nincludegraphics command. For example:
nDeclareGraphicsExtensionsf.pdf,.jpeg,.pngg
19
5.2.1
Figure Placement
h (Place the gure in the text where the gure command is located) t (Place the gure at the top of the page) b (Place the gure at the bottom of a page) p (Place the gure on a page containing only oats)
will produce
20
21
There are two ways to insert mathematical formulas into your document with A L TEX. One is to have it appear in a paragraph with text. For example
is produced by
$$ \frac{x^n-1}{x-1} = \sum_{k=0}^{n-1}x^k $$
22
6.2
Use the ^character (shift-6), known as a caret, to create exponents: $x^2$ produces x2 If you have an exponent containing more than one character, group the exponent characters inside braces $x^21 nne x^f21g$ produces x2 1 T= x21 Similarly, subscripts are created using the (underscore character) $x 21 nne x f21g$ produces x2 1 T= x21
6.3 Above and Below
It is useful to be able to draw horizontal lines and braces above and below parts of a formula. We can use noverline, noverbrace, nunderline, and nunderbrace commands to do this.
6.3.1 Example 10:
$$ \left( \begin{array}{c} m+n\\ m \end{array} \right) = \frac{(m+n)!}{m!n!} = \frac {\overbrace{(m+n)(m+n-1)\cdots(n+1)}}{\underbrace{m(m-1)\cdots 1}} $$ \\[0.5cm] \begin{center} $\overline{x+\overline{y}} = \overline{x}+y$ \end{center}
produces 23
m+n m
}| {z
x+y =x+y
6.4 Sums and Integrals
$$ \sum_{k=0}^\infty\frac{(-1)^k}{k+1} = \int_0^1\frac{dx}{1+x} $$
Produces
I X (1)k
k=0
k+1
Z
0
1+x
dx
6.5
Limits
x}{x} = 1
$$ \lim_{x\rightarrow 0} \frac{\sin $$
Produces
x30
lim
sin x
=1
6.6
6.6.1
Multi-line Equations
Example 11:
\begin{equation*} \begin{split}
24
Use the command nmboxfyour text hereg to include short phrases in a formula. For example
$$ \int_0^{2\pi}\cos(mx)\,dx = 0 \hspace{1cm} \mbox{if and only if} \hspace{1cm} m \ne 0 $$
produces
Z
0
2
cos(mx) dx = 0
if and only if
m T= 0
25
Chapter 7 Bibliography
Bibliography is the environment which helps the author to cross-reference one A publication from the list of sources at the end of the document. L TEXhelps authors to write a well structured bibliography.
7.1 thebibliography Environment
Use the command nbibitem to separate the entries in the bibliography and use ncite to refer to a specic entry from this list in the document. Width of the widest label is mandatory in nbeginfthebibliographygfwidestlabelg command. If you know you would have between 10 and 99 citations, you should start with
nbeginfthebibliographygf99g
Each entry in the environment should start with 26
nbibitemfkey1g
If the author name is Alex and year 1991, the key can be coded as a le91. This key is used to cite the publication within the document text. However, the argument to ncite can also be two or more keys, separated by commas. For example
ncitefkey1,key2g
You may also add a note to your citation, such as page number, chapter number etc. For example
ncite[page 25]fkey1g
7.2 Example 12:
It is hard to write unstructured and disorganised documents using nLaTeX~ncitefles85g. It is interesting to typeset one equation~ncite[Sec 3.3]fles85g rather than setting ten pages of running matter~ncitefdon89,rondon89g.
\begin{thebibliography}{9} \bibitem{les85}Leslie Lamport, 1985. \emph{\LaTeX---A Document Preparation System---Users Guide and Reference Manual}, Addision-Wesley, Reading. \bibitem{don89}Donald E. Knuth, 1989. \emph{Typesetting Concrete Mathematics}, TUGBoat, 10(1):31-36. \bibitem{rondon89}Ronald L. Graham, Donald E. Knuth, and Ore Patashnik, 1989. \emph{Concrete Mathematics: A Foundation for Computer Science}, Addison-Wesley, Reading. \end{thebibliography}
27
Bibliography
ATEX|A Document Preparation System|Users [1] Leslie Lamport, 1985. L Guide and Reference Manual, Addision-Wesley, Reading.
, TUGBoat,
[3] Ronald L. Graham, Donald E. Knuth, and Ore Patashnik, 1989. Concrete Mathematics: A Foundation for Computer Science, Addison-Wesley, Reading.
28