Sei sulla pagina 1di 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 . . . . . . . . . . . . . . . . . . . . .

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

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

7 Bibliography 26 7.1 thebibliography Environment . . . . . . . . . . . . . . . . . . 26 7.2 Example 12: . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

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. O ers 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/).

Chapter 2 Document Structure


2.1

A Required Components of a L T EX Document

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

A The following classes are distributed with L TEX:

ndocumentclassfarticleg ndocumentclassfbookg ndocumentclassfreportg ndocumentclassfletterg


7

ndocumentclassfslidesg ndocumentclassfprocg
2.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.2.2

a4paper

legalpaper etc.

twocolumn

Example 1

ndocumentclassfarticleg nbeginfdocumentg

This is my rst document prepared in LaTeX. I typed it on today. nendfdocumentg


Example 2

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 speci ed 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 de ned by packages, which are loaded by the nusepackage[options]fpackage nameg command. nusepackageflatexsymg - loads the latexsym package, which de nes commands to produce certain special math symbols.
Standard Packages

The standard packages include:

nusepackagefciteg nusepackagefgraphicxg nusepackagefamsmathg nusepackageflatexsymg nusepackagefmakeidxg


2.4 Page Style

The command npagestyle controls page numbering and headings.

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

you can choose a text \shape" with various \text" commands:


\textit{italics text} \textsl{slanted text} \textsc{small caps text} \textup{upright}
2.5.2 Font Weight

you can also choose text \weight" with \text" commands:


\textmd{medium weight} \textbf{boldface weight}
2.5.3 Font Types

you can also choose font types with \text" commands:


\textrm{Roman family} \textsf{Sans serif family} \texttt{Typewriter/teletype family}

Also, 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

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

ntitlefdocument nameg nauthorfauthor namesg ndatefdate textg nmaketitle


Note that after specifying the arguments of ntitle, nauthor and ndate, we must issue the command nmaketitle for this part to be typeset.

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

Dividing the Document

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

Chapter 3 Text Formatting


3.1 Text Positioning

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 di erence 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

Chapter 4 Tables and Arrays


4.1 Constructing Tables

To construct a table, surround the entries with a nbeginftabulargfjusti cationg 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 nbeginfarraygfjusti cationg 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:

$$ \left( \begin{array}{rcl} \alpha&\beta&\gamma\\ \delta&\epsilon&\zeta\\ \eta&\theta&\iota\\ \end{array} \right) $$

will produce

0 1 @  A
  

18

Chapter 5 Including Graphics


5.1 Graphics Package
A While L TEXcan import virtually any graphics format, Encapsulated PostScript A (EPS) is the easiest graphics format to import into L TEX.

Graphics Package:

Place nusepackagefgraphicxg in the preamble.


5.2 Including Graphics Within Your Document

Use nincludegraphicsfgraphic leg command to include your graphic le in your document. You can also specify the height and width: nincludegraphics[height = 2in, width = 3in] fgraphic leg. 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

Optional argument which allows users to specify possible 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 gure on a page containing only oats)

If no optional arguments are given, the placement options default to [tbp].


5.2.2 Example 9:

\begin{figure}[htb] \centering \includegraphics{ketan.jpg} \caption{Hi! Recognized, this is me} \label{fig1} \end{figure}

will produce

20

Figure 5.1: Hi! Recognized, this is me

21

Chapter 6 Mathematical Typesetting


6.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 rst letter of the Greek alphabet.


is produced by $nalpha$ is the rst letter of the Greek alphabet. The other way is to have them appear in a separate paragraph. For example
n1 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

6.2

Exponents and Subscripts

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

(m + n)! (m + n)(m + n 1) (n + 1) = = m!n! m(m 1) 1

}| {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

(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.7 Text in Math

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

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

produces the following output:


A It is hard to write unstructured and disorganised documents using L TEX[1].It is interesting to typeset one equation[1, Sec 3.3] rather than setting ten pages of running matter[2, 3].

27

Bibliography
ATEX|A Document Preparation System|Users [1] Leslie Lamport, 1985. L Guide and Reference Manual, Addision-Wesley, Reading.

[2] Donald E. Knuth, 1989. 10(1):31-36.

Typesetting Concrete Mathematics

, TUGBoat,

[3] Ronald L. Graham, Donald E. Knuth, and Ore Patashnik, 1989. Concrete Mathematics: A Foundation for Computer Science, Addison-Wesley, Reading.

28

Potrebbero piacerti anche