Latex Vtu Ws

Preview:

Citation preview

A tutorial on

Prof T.N.Nagabhushan M.E(IISc), Ph.D(IISc)

Special Officer

VTU Elearning Center

Objectives of this workshop

� To empower all researchers use Latex for preparing technical reports, papers and thesis.

� Improve the quality of presentation in a well structure format

1/4/2010 2

structure format

� Provide basics of the Latex environment and guide through practical sessions

� Develop enough confidence in using Latex

What You Need ….

� REDHAT LINUX OS Ver 4

� Any PC ( PIV, PV, ,,,,)

� Latex Manual

1/4/2010 3

COVERAGE

� Basic structure and essentials of Latex

� Syntax and Symantics of Latex –

� Dr T.N.Nagabhushan

� Generating Figure/Graphs,

� Structure of the VTU template,

� Actual compilation, Running through the

1/4/2010 4

Running through the Thesis tex file

� Hands on � Dr S.K.Padma

Preface

� LaTeX is a typesetting system (not a word processor).

� It is most suited to producing scientific and mathematical documents of high typographical quality.

1/4/2010 5

typographical quality.

Why not MS Word?

1/4/2010 6

Advantages and Disadvantages (1)

� Advantages of LaTeX over WYSIWYG:

� professionally crafted layouts are available

� the typesetting of mathematical formulae is supported in a convenient way

users need only to learn a few simple commands,

1/4/2010 7

� users need only to learn a few simple commands, which specify the logical structure of a document.

Advantages and Disadvantages (2)

� Advantages of LaTeX

� complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily

� for many typographical tasks not directly supported by

1/4/2010 8

for many typographical tasks not directly supported by basic LaTeX, there exist free add-on packages

� LaTeX is highly portable and free

Advantages and Disadvantages (3)

� LaTeX also has some disadvantages:� What you see is not what you get.

� Is this really a disadvantage? Why are you thinking about layout instead of content?

� The design of a whole new layout is difficult and takes a lot of time.

1/4/2010 9

a lot of time.� Templates help you here

LaTeX Input Files

� The input for LaTeX is a plain ASCII text file.

� You can create it with any text editor.

� It contains� the text of the document

� commands which tell LaTeX how to typeset the text.

1/4/2010 10

� commands which tell LaTeX how to typeset the text.

� Spaces

� Special Characters

� LaTeX Commands

� Comments

Spaces

� Whitespace characters (e.g. blank, tab, single

line break) are treated uniformly as “space” by LaTeX.

� Several consecutive whitespace characters are treated as one “space”.

1/4/2010 11

� An empty line between two lines of text defines the end of a paragraph.

� Several empty lines are treated in the same way as one empty line.

It does not matter whether you

enter one of several spaces after a

word.

An empty line starts a new

paragraph.

It does not matter whether you enter one or several spaces after a word.

An empty line starts a new paragraph.

Spaces

It does not

matter whether

you enter one of

several spaces

It does not matter whether you enter one or several spaces after a word.

1/4/2010 12

after a word.

An empty line

starts a new

paragraph.

An empty line starts a new paragraph.

Special Characters� The following symbols are reserved

characters, that� have a special meaning in LaTeX

$ & % # _ { } ~ ^ \� Some of these characters can be used in

your documents by adding a prefix backslash

1/4/2010 13

your documents by adding a prefix backslash (escape character):$ & % # _ { } \$ \& \% \# \_ \{ \}

� The other symbols (and many more!) can be printed with special commands in mathematical formulae.

LaTeX Commands (1)

� LaTeX commands are case sensitive and take one of two formats:� They start with a backslash \ and have a name

consisting only of letters.

� They consist of a backslash and exactly one special character.

1/4/2010 14

character.

LaTeX Commands (2)

I read that Knuth divides

people working with TeX

into TeXnicians and

TeXperts. Today is March

25th, 2004.

I read that Knuth

divides people

working with

\TeX{} into

\TeX{}nicians and

1/4/2010 15

\TeX perts. Today

is \today.

LaTeX Commands (3)

� Some commands take a parameter which has to be given between curly braces { } after the command name.

� Some commands support optional parameters which are added after the command name in square brackets [ ].

1/4/2010 16

square brackets [ ].

� The next example uses some LaTeX commands.

LaTeX Commands (4)

This is emphasized

text.

Please start a new line

right here!

This is \emph{emphasized} text.

Please start a new line right here!\linebreak

1/4/2010 17

Thank you!

right here!\linebreak Thank you!

Comments

� When LaTeX encounters a % character while processing an input file, it ignores the rest of the present line.

� This is useful for adding notes to the input file, which will not show up in the printed

1/4/2010 18

file, which will not show up in the printed version.

This text is

processed.

This text is processed. % A comment isn’t

Input File Structure (1)

� When LaTeX2e processes an input file it expects it to follow a certain structure. Every input file starts with the command:

\documentclass{...}

� This specifies what sort of document you intend to write (article, letter, book, thesis, etc.)

1/4/2010 19

(article, letter, book, thesis, etc.)

� After that, you can include global style commands or you can load packages which add new features to the LaTeX system. To load a package you use the command:

\usepackage{...}

Input File Structure (2)

� When all the setup work is done, you start the body of the text with the command:

\begin{document}

� Now you enter the text mixed with some useful LaTeX commands.

1/4/2010 20

useful LaTeX commands.

� At the end of the document you use the

\end{document}

command, which tells LaTeX to finish. Anything which follows this command will be ignored by LaTeX

Parts of a LaTeX Document:

\documentclass

� First line of all LaTeX documents specifies

{article}{report}{book}{letter}

Basic Classes

1/4/2010 21

� First line of all LaTeX documents specifies the {type} of the document and the [stylesheet] used.

\documentclass[ieee]{article}

A Simple LaTeX Document

\documentclass{article}

\begin{document}

1/4/2010 22

This is some sample text.

\end{document}

A more realistic LaTeX file\documentclass[a4paper,11pt]{article}

\usepackage{latexsym}

\author{XYZ}

\title{Dependable Nanocomputing Lab}

\begin{document}

\maketitle

\tableofcontents

1/4/2010 23

\tableofcontents

\section{Introduction}

Here begins my first article \ldots

\section{Conclusions}

\ldots{} and here it ends.

\end{document}

Sections

\section{Section Title}

\subsection{Title}

\subsubsection{Title}

1/4/2010 24

\subsubsection{Title}

Font size

\tiny \scriptsize \footnotesize

\small \normalsize

\large \Large

\LARGE \huge

1/4/2010 25

\huge

\Huge

Page Styles

� LaTeX supports three predefined header/footer combinations. These are known as page styles.

� The style parameter of the \pagestyle{style}command defines which one to use:� plain prints the page numbers on the bottom of the page

in the middle of the footer (default page style)

1/4/2010 26

in the middle of the footer (default page style)

� headings prints the current chapter heading and the page

number on each page. Footer is empty

� empty - both header and footer empty

� More elaborate headers and footers can be created using the fancyheadings package

Typesetting Mathematics

� LaTeX has a special mode for typesetting mathematics, called “math mode”.

� Within a paragraph, math mode is entered between $ characters, or by using the \begin{math} and \end{math} commands

1/4/2010 27

To find the square of

the hypotenuse, add a

squared to b squared

to find c squared,

e.g. .

It’s as easy as that!

\begin{math} and \end{math} commands

To find the square of the hypotenuse, add a squared to b squared to find c squared, e.g. $a^2 + b^2 = c^2$. It’s as easy as that!

222cba =+

Typesetting Mathematics

Greek Symbols

\alpha, \beta, \gamma

Superscript, Subscript

x^y x_y x_y^z

Calculus

1/4/2010 28

Calculus

\int_0^\infty \int{\int}

\frac{\partial u}{\partial x}

Typesetting Mathematics

x = \frac{-b \pm \sqrt{b^2-4ac} } {2a}

1/4/2010 29

Some more Math equations\begin{center}

{\large

$$ y=\frac{a^3+2c_{x}}{1+\sqrt{b_{x}}} $$ \\

\vspace{0.2in}

$$ Q=\sum_{i=1}^{j}\int_{\mu}^{\infty}f(x_{j})dx $$ \\

\vspace{0.2in}

$$ \Psi = \oint_{-

1/4/2010 30

$$ \Psi = \oint_{-\infty}^{\infty}f_{xy}({\frac{\partial

Qx}{\partial Qy}})^{\Im_{\pi}^ \prime} $$ \\ }

Typesetting Mathematics� In a research paper or thesis, you will often want to number

equations and refer to them in the text

� This is done using the equation environment, and the commands \label and \ref

… it is clear that

ε > 0. (1)

\ldots it is clear

that

\begin{equation}

1/4/2010 31

� (note that \label and \ref are used with figures and tables too)

ε > 0. (1)

From Equation 1 it follows that

...

\begin{equation}

\epsilon > 0.

\label{eq:eps}

\end{equation}

From

Equation~\ref{eq:eps}

it follows that

\ldots

Typesetting Mathematics

� Matrices are produced using the \textbf{array} environment. Example:

1/4/2010 32

The \emph{characteristic polynomial} $\chi(\lambda)$ of the

$3 \times 3$~matrix

\[ \left( \begin{array}{ccc}

a & b & c \\

d & e & f \\

g & h & i \end{array} \right)\]

is given by the formula

\[ \chi(\lambda) = \left| \begin{array}{ccc}

\lambda - a & -b & -c \\

-d & \lambda - e & -f \\

-g & -h & \lambda - i \end{array} \right|.\]

Including Graphics

� LaTeX2e includes a standard package for including PostScript graphics in your document. Load it using

\usepackage{graphics}

� A figure can be included using, for example,

1/4/2010 33

� A figure can be included using, for example,

\begin{figure}[ht]

\begin{center}

\includegraphics[width=140mm]{mypic.ps}

\end{center}

\caption{An example of a figure.}

\label{fig:example}

\end{figure}

Figures and Tables

� Figures & Tables cannot be broken between pages

� They are “floated”

1/4/2010 34

\begin{figure}

\includegraphics{sample}

\caption{A sample figure.}

\end{figure}

� Columns� \begin{tabular}{|…|…|}

� \end{tabular}

� Rows� & - Split text into columns

Two Columns

l = automatically adjust

size, left justify

r = automatically adjust

size, right justify

p = set size

e.g p{4.7cm}

c = centre text

Tabular

1/4/2010 35

& - Split text into columns

� \\ - End a row

� \hline - Draw line under row

� e.g. 123123 & 34.00\\ \hline

c = centre text

Example of table\begin{tabular}{|l|r|c|} \hline

Date & Price & Size \\ \hline

Yesterday & 5 & Big \\ \hline

Today & 3 & Small \\ \hline

\end{tabular}

Date Price Size

1/4/2010 36

Date Price Size

Yesterday 5 Big

Today 3 Small

Cross-referencing

\label{marker}

\ref{marker}

\pageref{marker}

� Example:

1/4/2010 37

� Example:

\section{Introduction}

\label{intro}

As mentioned in section \ref{intro} in page pageref{intro}

Bibliographies

� Articles can be referred to in the text using the \cite command

� The details of the cited articles are stored in BibTeX format, in a “.bib” file.

� BibTeX resolves the citations in the LaTeX

1/4/2010 38

� BibTeX resolves the citations in the LaTeX file and generates the required bibliography

Types of Documents BibTex can handle

� ARTICLE

� BOOK

� BOOKLET

� INBOOK

� INCOLLECTION

� MISC

� PHDTHESIS

� PROCEEDINGS

� TECHREPORT

� UNPUBLISHED

1/4/2010 39

� INCOLLECTION

� INPROCEEDINGS

� MANUAL

� UNPUBLISHED

Each Document type can have the following

entries

� address

� author

� booktitle

� chapter

� crossref

� month

� note

� number

� organization

� pages

1/4/2010 40

� crossref

� edition

� editor

� howpublished

� institution

� journal

� key

� language

� pages

� publisher

� school

� series

� title

� type=“Ph.D. dissertation”

� volume

� year

Sample BibTex

Book Entry

(mybib.bib)

@BOOK{Press,

author="W.H. Press",

1/4/2010 41

author="W.H. Press",

title="Numerical Recipes in C: The Art of

Scientific Computing",

publisher="Cambridge University Press",

year=1992,

}

Sample BibTex

Technical Report Entry

@TECHREPORT{Berk,

author="Lex A. Berk and L.S. Bernstein and D.C. Robertson",

title="MODTRAN: a moderate resolution

1/4/2010 42

title="MODTRAN: a moderate resolution model for LOWTRAN 7",

number="GL-TR-89-0122",

institution="Spectral Science",

address = "Burlington, MA",

year = 1989

}

Sample BibTex

Ph.D. Dissertation Entry

@PHDTHESIS{Kuo,

author="Jan-Tai Kuo",

title="The Influence of Hydrodynamic Transport on Phytoplankton Dynamics

1/4/2010 43

Transport on Phytoplankton Dynamics in Homogeneous Lakes",

school="Cornell University",

address="Ithaca, NY",

year=1981,

}

Sample BibTex

Master’s Thesis Entry

@MASTERSTHESIS{Knobelspiesse,

author="Kirk D. Knobelspiesse",

title="Atmospheric Compensation for SeaWIFS Images

1/4/2010 44

title="Atmospheric Compensation for SeaWIFS Images of Lake Superior Utilizing Spatial Information",

school="Rochester Institute of Technology",

addess="Rochester, NY",

month=Sep,

year=2000,

}

Sample BibTex

Article Entry@ARTICLE{Vodacek,

author="Anthony Vodacek and F.E. Hoge and R.N. Swift and J.K. Yungel and E.T. Peltzer and N.V. Blough",

title="The use of in situ and airborne fluorescence measurements to determine UV absorption coefficients and DOC concentrations in surface waters",

1/4/2010 45

waters",

journal="Limnology and Oceanography",

volume=40,

number=2,

year=1995,

pages="411--415",

}

Sample BibTex

Booklet Entry

@BOOKLET{Sherwood,

author="D.A. Sherwood",

title="Phosphorus Loads Entering Long Pond, A Small Embayment of Lake Ontario near

1/4/2010 46

Small Embayment of Lake Ontario near Rochester, New York",

howpublished="USGS Fact Sheet 128-99",

pages=4,

month="November",

year=1999,

}

Sample BibTex

Proceedings Entry

@INPROCEEDINGS{Stoermer,

author="E.F. Stoermer",

title="Nearshore phytoplankton populations in the Grand Haven, Michigan vicinity during

1/4/2010 47

the Grand Haven, Michigan vicinity during thermal bar conditions",

booktitle="Proceedings of the 11th Conference on Great Lakes Research",

pages="137--150",

year=1968,

}

Commands to Build and

View Document

To use xdvi viewer

% latex bib.tex

1/4/2010 48

% latex bib.tex

% bibtex bib.aux

% latex bib.tex

% latex bib.tex

% xdvi bib.dvi

Running LaTeX

� The simplest way to run LaTeX on a source document is to do so at the UNIX command line:

� There will be:

>latex test.tex

1/4/2010 49

� There will be:

test.aux # the auxiliary file that LaTeX will use in subsequent passes to resolve references to figures, tables, citations etc.test.log # a log file that contains information about the LaTeX runtest.dvi # the DeVice Independent output file. This is the

typeset document, ready for conversion to postscript or other printable formats

Running LaTeX

� We can view the document we have created using a DVI viewer. The most common one under UNIX is xdvi. Type

>xdvi test

1/4/2010 50

>xdvi test

to see the typeset document

� It is important to realise that LaTeX sometimes needs to be run several times to resolve all references.

Your Latex File Your Bibtex File

Latex compile x3

Bibtex compile x2

(a text file)

Creating Latex Files

1/4/2010 51

Bibtex compile x2

Latex compile x3

Your Postscript File

dvips compile x1Device independentoutput .dvi

Output Formats

� .dvi Device Independent

� .ps Post Script

� .pdf PDF

� .rtf Rich Text Format

.html HTML

1/4/2010 52

� .html HTML

� .xml XML

1

How to run LaTeX

latex myfile

Edit myfile

Resolve

cross-

reference

Resolve

compile

error

myfile.tex

myfile.dvi

1/4/2010 53

xdvi myfile

(UNIX)

yap myfile

(Windows)

myfile.dvi

dvips myfile myfile.ps

print

THANK YOU

1/4/2010 54

Recommended