You are on page 1of 30

ATEX?

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 . . . . . . . . . . . . . . . . . . . . .

1

. . . . . .4 Sums and Integrals . . . . . . . . . . . . . 3. . . .1 Figure Placement . . . . . . . . . . . . . . . . . . . . . . . . 26 7. . . . . .1 Example 5: . . . . . 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. . . . . . . .3. . . . . . . 27 2 . . 4. . . . . . . . . . .2 Extended Quotation 3. . . . . . . . . . . . . . . . . . . . . . 6 Mathematical Typesetting 6. . . . .5 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Example 7: . . . .1.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5. . . . . . . . . . . . 6. .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5. . . . . . . . .1 Graphics Package . . . . . . . . . . . . . . . . . . . . . . . . . . . 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . 6. . . . . .2 Example 12: . . . . . . .1 thebibliography Environment . . . . . .1 Constructing Tables 4. . . . . . . . . . .4 Numbered Lists . . . . . . .6 Multi-line Equations . . . . . . . 6. . . .2 Including Graphics Within Your Document . . . . . . . . . . . . . . . . . . 3. . . . .1 Example 6: . . . . .6. . . 6. . . . . . . . . . . . . . . . . 4 Tables and Arrays 4. . . . . . . . . .1 Example 10: . . 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. . . . . . . . .2 Example 9: . .3. . . . . . . . . . . . . . . .1 Text Positioning . . . . . . . . . . . .2 Constructing Arrays 4. . . .2. . . . . . . . . . . . . . . . . . .1 Example 11: . . . . . . . . . .3 Bulleted Lists . . . . . . . . . . . . . . . . . . . . 7 Bibliography 26 7. . .3 Text Formatting 3.1 Example 4: . . . . . .1 Example 8: . . . . . .7 Text in Math . .1.3 Above and Below . . . . . . . 6. . 5. . . . . . .1 Mathematical Formulas . . . . . 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. . . . . . . . . . . . .2 Exponents and Subscripts 6. . . . . . .

. . . this is me . . . .List of Figures 5. .1 Hi! Recognized. . . . 21 3 . . . . . . . . . .

. . . . . . . . . . . . .1 Observed values of x and y .List of Tables 4. . 17 4 . . . . . .

1 A What is L T EX? A L TEX is a typesetting program. 1. 1. However in L TEX. designed to produce publication-quality typeset documents. Very easy to create documents containing lot of mathematics. we type the text and the formatting commands in a text editor and then compile it.Chapter 1 Introduction 1. Even for ordinary text. It is an extension of the original program TEX written by Donald Knuth.3 What is TeXworks? A A A text editor for L TEX to create documents with L TEX and to typeset them to PDF. if you want A your document to look really beautiful then L TEX is the natural choice. O ers at .2 A Why L T EX? Creates beautifully typeset technical documents. In most word processors (like MS Word) all operations are integrated into A a single package.

5 .rst sight only some limited tools for text editing. Runs on Linux. Mac OS as well as Windows.

a bunch of programmes and other necessary .1.4 Installation One needs to install a TEX distribution.

org/). 6 .les which will be automatically called by TeXworks during its work.miktex. For Windows: an often used distribution is MiKTeX (http://www.

2 Document Classes A The following classes are distributed with L TEX: ndocumentclassfarticleg ndocumentclassfbookg ndocumentclassfreportg ndocumentclassfletterg 7 . Enter all commands in lower case unless explicitly directed to do otherwise. Everything else is optional even text. ndocumentclass[options]fclassg Further optional global commands and options.1 A Required Components of a L T EX Document A Every L TEX document must contain the following three components. 2. such as nusepackagefpackagenameg nbeginfdocumentg text mixed with typesetting commands nendfdocumentg A NOTE: L TEX is case sensitive.Chapter 2 Document Structure 2.

2 a4paper legalpaper etc.2.2. twocolumn Example 1 ndocumentclassfarticleg nbeginfdocumentg This is my .ndocumentclassfslidesg ndocumentclassfprocg 2.1 Document Class Options Following options are available with document class: Font Size 10pt 11pt 12pt For example: ndocumentclass[11pt]farticleg Paper Size letterpaper Page Formats onecolumn 2.

3 A We have seen that to typeset something in L TEX.rst document prepared in LaTeX.2. nendfdocumentg Example 2 2. Words must be separated by spaces (does not matter how many) and lines maybe broken arbitrarily. I typed it on today. The end of a paragraph is speci. we type in the text to be A typeset together with some LTEX commands.

In other words. 8 . whenever you want to start a new paragraph. just leave a blank line and proceed.ed by a blank line in the input.

3 Packages Additional structures are de.2.

which are loaded by the nusepackage[options]fpackage nameg command.loads the latexsym package. nusepackageflatexsymg . which de.ned by packages.

npagestylefheadingsg will provide page numbers and headings from any nsections that you are using. Standard Packages The standard packages include: nusepackagefciteg nusepackagefgraphicxg nusepackagefamsmathg nusepackageflatexsymg nusepackagefmakeidxg 2. npagestylefplaing is the default.4 Page Style The command npagestyle controls page numbering and headings. Moreover. npagestylefmyheadingsg will provide page numbers and custom headings. which puts the page number at the center of the bottom of the page and provides no headings.nes commands to produce certain special math symbols. npagestylefemptyg provides neither page numbers nor headings. 9 . we can customize the style for the current page by using the command nthispagestylefstyleg.

5.5 2.3 Font Types you can also choose font types with \text" commands: \textrm{Roman family} \textsf{Sans serif family} \texttt{Typewriter/teletype family} Also.2.5.1 Font Style Font Shape you can choose a text \shape" with various \text" commands: \textit{italics text} \textsl{slanted text} \textsc{small caps text} \textup{upright} 2. you can use nusepackageffont typeg to specify a font type: \usepackage{avant} \usepackage{bookman} \usepackage{chancery} \usepackage{charter} \usepackage{courier} \usepackage{newcent} \usepackage{palatino} 10 .5.2 Font Weight you can also choose text \weight" with \text" commands: \textmd{medium weight} \textbf{boldface weight} 2.

11 .6.1 Title The \title" part of a document usually consists of the name of the document. we make use of the commands ntitlefdocument nameg nauthorfauthor namesg ndatefdate textg nmaketitle Note that after specifying the arguments of ntitle.6 Parts of a Document Documents (especially longer ones) are divided into chapters.2. 2.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. we must issue the command nmaketitle for this part to be typeset. sections and so on. the name of author(s) and sometimes a date.5. To produce a title. There may be a title part (sometimes even a separate title page) and an abstract. nauthor and ndate.

and List of Tables A table of contents is a special list which contains the section numbers and corresponding headings.6.2.6. together with the page numbers on which they begin. ntableofcontents produces a table of contents. nlistogures and nlistoftables A produce a list of . Year} \maketitle 2.3 Table of Contents.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. List of Figures.

gures and list of tables respectively. 2.4 Abstract In the document classes article and report. Standard L TEX can automatically create these three contents lists.6. an abstract can be produced by the commands nbeginfabstractg Abstract Text nendfabstractg The abstract should come immediately after your nmaketitle command. 12 . but before any ntableofcontents command.

2. sections into subsections and so on. and article class: \chapter (not in article class) \section \subsection \subsubsection \paragraph \subparagraph 13 . Sectioning commands in the book.7 Dividing the Document A book is usually divided into chapters and chapters are divided into sections. report.

surround the information with a nbeginfitemizeg and an nendfitemizeg. and begin each item with an nitem... nendf ushrightg typesets text ush with the right margin.3 Bulleted Lists To create a bulleted list. A In L TEX. 3.2 Extended Quotation If you are going to include an extended quotation from another source.Chapter 3 Text Formatting 3. The command nbeginf ushleftg .1 Text Positioning The command nbeginfcenterg . surround the quotation with nbeginfquoteg and nendfquoteg 3.. it is important to indicate the di erence between the quotation and your words.. The command nbeginf ushrightg . nendf ushleftg places the enclosed text ush with the left margin.. 14 . nendfcenterg typesets the text between them exactly at the center of the page..

1 Example 4: \begin{itemize} \item A bulleted item. \end{itemize} 3. \end{enumerate} \item You get the idea. \item Another nested numbered item. 3.4. \item Another numbered item.1 Example 5: \begin{enumerate} \item A numbered item. \item Another bulleted item. \end{enumerate} 15 . surround the information with a nbeginfenumerateg and an nendfenumerateg.3.4 Numbered Lists To create a numbered list. \begin{enumerate} \item A nested numbered item. and begin each item with an nitem. \begin{itemize} \item A nested bulleted item. \end{itemize} \item You get the idea. \item Another nested bulleted item.3.

surround the entries with a nbeginftabulargfjusti.Chapter 4 Tables and Arrays 4.1 Constructing Tables To construct a table.

4. and separate the l.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 . The justication should consist of `l' for left justication. Separate column entries by a &. and end each line with a nn.cationg command and an nendftabularg command. c. `c' for centered justication. or `r' for right justication. and rs by a l wherever you want a vertical line. Use nhline to construct a horizontal line.

1 are y = x3 and y = 6x2   11x + 6.2 Constructing Arrays To construct an array.1. 4.4.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. surround the entries with a nbeginfarraygfjusti.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.

you can surround it with large parentheses nleft( and nright). `c' for centered justication. Separate column entries by an &. The justication should consist of `l' for left justication. If your array is a matrix. 17 .cationg command and an nendfarrayg command. or `r' for right justication. and end each line with a nn.

1 Example 8: $$ \left( \begin{array}{rcl} \alpha&\beta&\gamma\\ \delta&\epsilon&\zeta\\ \eta&\theta&\iota\\ \end{array} \right) $$ will produce 0 1 .4.2.

@  A    18 .

Encapsulated PostScript A (EPS) is the easiest graphics format to import into L TEX.1 Graphics Package A While L TEXcan import virtually any graphics format.2 Including Graphics Within Your Document Use nincludegraphicsfgraphic. Graphics Package: Place nusepackagefgraphicxg in the preamble. 5.Chapter 5 Including Graphics 5.

leg command to include your graphic .

You can also specify the height and width: nincludegraphics[height = 2in.le in your document. width = 3in] fgraphic.

.pdf..leg.pngg 19 . For example: nDeclareGraphicsExtensionsf.jpeg. The nDeclareGraphicsExtensions comA mand tells L TEXwhich extensions to try if a le with no extension is specied in the nincludegraphics command.

5.1 Figure Placement Optional argument which allows users to specify possible .2.

gure locations:     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 .

2 Example 9: \begin{figure}[htb] \centering \includegraphics{ketan. 5.gure on a page containing only oats) If no optional arguments are given.2. the placement options default to [tbp]. this is me} \label{fig1} \end{figure} will produce 20 .jpg} \caption{Hi! Recognized.

1: Hi! Recognized.Figure 5. this is me 21 .

1 Mathematical Formulas 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 the .Chapter 6 Mathematical Typesetting 6.

rst letter of the Greek alphabet. is produced by $nalpha$ is the .

The other way is to have them appear in a separate paragraph. For example n 1 xn   1 X = xk x   1 k=0 is produced by $$ \frac{x^n-1}{x-1} = \sum_{k=0}^{n-1}x^k $$ 22 .rst letter of the Greek alphabet.

3.2 Exponents and Subscripts Use the ^character (shift-6).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 . and nunderbrace commands to do this.3 Above and Below It is useful to be able to draw horizontal lines and braces above and below parts of a formula. nunderline. known as a caret. 6.6. We can use noverline. to create exponents: $x^2$ produces x2 If you have an exponent containing more than one character. noverbrace. 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.

 m+n m  (m + n)! (m + n)(m + n   1) ¡ ¡ ¡ (n + 1) = = m!n! m(m   1) ¡ ¡ ¡ 1 z }| {z { | } x+y =x+y 6.6 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 1+x dx 6.6.5 Limits x}{x} = 1 $$ \lim_{x\rightarrow 0} \frac{\sin $$ Produces x30 lim sin x x =1 6.1 Multi-line Equations Example 11: \begin{equation*} \begin{split} 24 .

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 .(a+b)^2 & = (a+b)(a+b)\\ & = a^2+ab+ba+b^2\\ & = a^2+2ab+b^2 \end{split} \end{equation*} Produces (a + b)2 = (a + b)(a + b) = a2 + ab + ba + b2 = a2 + 2ab + b2 6. For example $$ \int_0^{2\pi}\cos(mx)\.7 Text in Math Use the command nmboxfyour text hereg to include short phrases in a formula.

1 thebibliography Environment To produce bibliography. one has to use \begin{thebibliography}{widest-label} \bibitem{key1} \bibitem{key2} \end{thebibliography} 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. L TEXhelps authors to write a well structured bibliography. Width of the widest label is mandatory in nbeginfthebibliographygfwidestlabelg command. 7.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. you should start with nbeginfthebibliographygf99g Each entry in the environment should start with 26 . If you know you would have between 10 and 99 citations.

2 Example 12: It is hard to write unstructured and disorganised documents using nLaTeX~ncitefles85g. 1989. \emph{Typesetting Concrete Mathematics}. chapter number etc. 1989. 1985. Sec 3. \emph{\LaTeX---A Document Preparation System---Users Guide and Reference Manual}. \begin{thebibliography}{9} \bibitem{les85}Leslie Lamport. 27 . \end{thebibliography} produces the following output: A It is hard to write unstructured and disorganised documents using L TEX[1]. separated by commas.3] rather than setting ten pages of running matter[2. and Ore Patashnik. For example ncite[page 25]fkey1g 7. the key can be coded as a le91. \emph{Concrete Mathematics: A Foundation for Computer Science}.It is interesting to typeset one equation[1. It is interesting to typeset one equation~ncite[Sec 3. such as page number. Reading.rondon89g. Addison-Wesley. For example ncitefkey1. Knuth. Reading. However. the argument to ncite can also be two or more keys.3]fles85g rather than setting ten pages of running matter~ncitefdon89. Donald E. \bibitem{rondon89}Ronald L. Addision-Wesley.key2g You may also add a note to your citation.nbibitemfkey1g If the author name is Alex and year 1991. \bibitem{don89}Donald E. Knuth. This key is used to cite the publication within the document text. 3]. 10(1):31-36. TUGBoat. Graham.

[2] Donald E. Knuth. Addision-Wesley. Reading. [3] Ronald L. Graham. 1989. 10(1):31-36. TUGBoat.Bibliography ATEX|A Document Preparation System|Users [1] Leslie Lamport. Concrete Mathematics: A Foundation for Computer Science. Reading. 1989. and Ore Patashnik. Addison-Wesley. Typesetting Concrete Mathematics . 28 . Donald E. Knuth. 1985. L Guide and Reference Manual.