Latex Vtu Ws

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

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 Provide basics of the Latex environment and guide through practical sessions Develop enough confidence in using Latex

1/4/2010

What You Need .


REDHAT LINUX OS Ver 4 Any PC ( PIV, PV, ,,,,) Latex Manual

1/4/2010

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 Thesis tex file Hands on
Dr S.K.Padma

1/4/2010

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

Why not MS Word?

1/4/2010

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, which specify the logical structure of a document.

1/4/2010

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 basic LaTeX, there exist free add-on packages LaTeX is highly portable and free

1/4/2010

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.
Templates help you here

1/4/2010

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.
Spaces Special Characters LaTeX Commands Comments

1/4/2010

10

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.

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 or several spaces after a word. An empty line starts a new paragraph. It does not matter whether you enter one of several spaces after a word. An empty line starts a new paragraph. 11

1/4/2010

Spaces
It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph. It does not matter whether you enter one of several spaces after a word. An empty line starts a new paragraph.

1/4/2010

12

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 (escape character):
$ & % # _ { } \$ \& \% \# \_ \{ \}

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

1/4/2010

13

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

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 \TeX perts. Today is \today.

1/4/2010

15

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 [ ]. The next example uses some LaTeX commands.

1/4/2010

16

LaTeX Commands (4)


This is \emph{emphasized} text. Please start a new line right here!\linebreak Thank you! This is emphasized text. Please start a new line right here! Thank you!

1/4/2010

17

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 version.
This text is processed. % A comment isnt

This text is processed.


1/4/2010 18

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

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

1/4/2010

19

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. 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
1/4/2010 20

Parts of a LaTeX Document:

\documentclass
{article} {report} {book} {letter}
Basic Classes

First line of all LaTeX documents specifies the {type} of the document and the [stylesheet] used.
\documentclass[ieee]{article}

1/4/2010

21

A Simple LaTeX Document

\documentclass{article} \begin{document} This is some sample text. \end{document}

1/4/2010

22

A more realistic LaTeX file


\documentclass[a4paper,11pt]{article} \usepackage{latexsym} \author{XYZ} \title{Dependable Nanocomputing Lab} \begin{document} \maketitle \tableofcontents \section{Introduction} Here begins my first article \ldots \section{Conclusions} \ldots{} and here it ends. \end{document}

1/4/2010

23

Sections
\section{Section Title} \subsection{Title} \subsubsection{Title}

1/4/2010

24

Font size
\tiny \scriptsize \footnotesize

\small \normalsize

\large \Large

\LARGE \huge

\Huge

1/4/2010

25

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

1/4/2010

26

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
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$. Its as easy as that! 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 . Its as easy as that!

1/4/2010

27

Typesetting Mathematics
Greek Symbols \alpha, \beta, \gamma Superscript, Subscript x^y x_y Calculus \int_0^\infty \frac{\partial u}{\partial x}

x_y^z \int{\int}

1/4/2010

28

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_{\infty}^{\infty}f_{xy}({\frac{\partial Qx}{\partial Qy}})^{\Im_{\pi}^ \prime} $$ \\ }

1/4/2010

30

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} \epsilon > 0. \label{eq:eps} \end{equation} From Equation~\ref{eq:eps} it follows that \ldots

From Equation 1 it follows that ...

(note that \label and \ref are used with figures and tables too)
1/4/2010 31

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

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|.\]
1/4/2010 32

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,


\begin{figure}[ht] \begin{center} \includegraphics[width=140mm]{mypic.ps} \end{center} \caption{An example of a figure.} \label{fig:example} \end{figure}
1/4/2010 33

Figures and Tables


Figures & Tables cannot be broken between pages They are floated \begin{figure} \includegraphics{sample} \caption{A sample figure.} \end{figure}
1/4/2010 34

Tabular
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

\begin{tabular}{|||} \end{tabular}

Rows
& - Split text into columns \\ - End a row \hline - Draw line under row e.g. 123123 & 34.00\\ \hline

1/4/2010

35

Example of table
\begin{tabular}{|l|r|c|} \hline Date & Price & Size \\ \hline Yesterday & 5 & Big \\ \hline Today & 3 & Small \\ \hline \end{tabular}

Date Yesterday Today

Price 5 3

Size Big Small

1/4/2010

36

Cross-referencing
\label{marker} \ref{marker} \pageref{marker} Example: \section{Introduction} \label{intro}
As mentioned in section \ref{intro} in page pageref{intro}

1/4/2010

37

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 file and generates the required bibliography

1/4/2010

38

Types of Documents BibTex can handle


ARTICLE BOOK BOOKLET INBOOK INCOLLECTION INPROCEEDINGS MANUAL MISC PHDTHESIS PROCEEDINGS TECHREPORT UNPUBLISHED

1/4/2010

39

Each Document type can have the following entries


address author booktitle chapter crossref edition editor howpublished institution journal key language
1/4/2010

month note number organization pages publisher school series title type=Ph.D. dissertation volume year
40

Sample BibTex Book Entry (mybib.bib)


@BOOK{Press, author="W.H. Press", title="Numerical Recipes in C: The Art of Scientific Computing", publisher="Cambridge University Press", year=1992, }
1/4/2010 41

Sample BibTex Technical Report Entry


@TECHREPORT{Berk, author="Lex A. Berk and L.S. Bernstein and D.C. Robertson", title="MODTRAN: a moderate resolution model for LOWTRAN 7", number="GL-TR-89-0122", institution="Spectral Science", address = "Burlington, MA", year = 1989 }
1/4/2010 42

Sample BibTex Ph.D. Dissertation Entry


@PHDTHESIS{Kuo, author="Jan-Tai Kuo", title="The Influence of Hydrodynamic Transport on Phytoplankton Dynamics in Homogeneous Lakes", school="Cornell University", address="Ithaca, NY", year=1981, }
1/4/2010 43

Sample BibTex Masters Thesis Entry


@MASTERSTHESIS{Knobelspiesse, author="Kirk D. Knobelspiesse", title="Atmospheric Compensation for SeaWIFS Images of Lake Superior Utilizing Spatial Information", school="Rochester Institute of Technology", addess="Rochester, NY", month=Sep, year=2000, }

1/4/2010

44

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", journal="Limnology and Oceanography", volume=40, number=2, year=1995, pages="411--415", }

1/4/2010

45

Sample BibTex Booklet Entry


@BOOKLET{Sherwood, author="D.A. Sherwood", title="Phosphorus Loads Entering Long Pond, A Small Embayment of Lake Ontario near Rochester, New York", howpublished="USGS Fact Sheet 128-99", pages=4, month="November", year=1999, }

1/4/2010

46

Sample BibTex Proceedings Entry


@INPROCEEDINGS{Stoermer, author="E.F. Stoermer", title="Nearshore phytoplankton populations in the Grand Haven, Michigan vicinity during thermal bar conditions", booktitle="Proceedings of the 11th Conference on Great Lakes Research", pages="137--150", year=1968, }

1/4/2010

47

Commands to Build and View Document


To use xdvi viewer % % % % % latex bib.tex bibtex bib.aux latex bib.tex latex bib.tex xdvi bib.dvi

1/4/2010

48

Running LaTeX
The simplest way to run LaTeX on a source document is to do so at the UNIX command line:
>latex test.tex

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 run test.dvi # the DeVice Independent output file. This is the typeset document, ready for conversion to postscript or other printable formats
1/4/2010 49

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 to see the typeset document It is important to realise that LaTeX sometimes needs to be run several times to resolve all references.
1/4/2010 50

Creating Latex Files


Your Latex File (a text file) Latex compile x3 Bibtex compile x2 Latex compile x3 Device independent output .dvi dvips compile x1 Your Postscript File
1/4/2010 51

Your Bibtex File

Output Formats
.dvi .ps .pdf .rtf .html .xml Device Independent Post Script PDF Rich Text Format HTML XML

1/4/2010

52

How to run LaTeX


myfile.tex Edit myfile Resolve crossreference latex myfile Resolve compile error myfile.dvi

xdvi myfile (UNIX)

yap myfile (Windows)

dvips myfile print


1/4/2010

myfile.ps

53

THANK YOU

1/4/2010

54

You might also like