Вы находитесь на странице: 1из 38

By

Dr. J. Upendar, PhD (IIT )


Assistant Professor,
Electrical Engineering Department,
University College of Engineering
Osmania University, Telangana
India, PIN 500007
Outline
1) Introduction
2) Structure of a LATEX File
3) Documentclass
4) Preamble
5) The Document
6) Cross-References
7) Adding a Graphics Image
8) Tables
9) Arrays
10) LaTeX Advantages
11) LaTeX Disadvantages

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 2
Introduction
LATEX (pronounced either Lay-tech or Lah-tech) is
a portable document

Formatting system based on TEX (pronounced


tech),

A typesetting language originally designed especially


for math and science.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 3
Structure of a LATEX File
\documentclass[options, options, options]{class}
\usepackage{packagename} (Preamble -for LATEX commands only)
\pagestyle{style option}

\begin{document}
Document text (text with embedded LATEX commands)

\end{document}

(Any thing which follows this command will be ignored by LATEX.)

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 4
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 5
\documentclass[options]{article}
Document class - Determines the overall layout of
the document.
Commonly-used classes:
 article - for simple or short documents, including journal
articles, and short reports.
 report for small books, for longer documents containing
chapters
 thesis for writing an RPI thesis
 book for books
 letter for letters
 slides for making transparencies

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 6
Document Class Options
A document class can be modified by using options:
\documentclass[options,options,options]{class}
Commonly-used options :
 selecting font size10pt, 11pt, 12pt
 Default 10pt
 11pt Prints document in 11pt type
 specifying paper sizea4paper, letterpaper, legalpaper,
executivepaper,
 page formats onecolumn, twocolumn etc.

Example:
a) \documentclass[11pt]{article}
b) \documentclass[12pt]{report}
c) \documentclass[a4paper,11pt,twocolumn]{article}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 7
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 8
Preamble - Packages
LATEX Packages Contain extra definitions that provide
additional formatting features.
(To load a package, include in the preamble command)
\usepackage{packagename}

Commonly-used packages:
 setspace -Provides easy way to change line spacing
 graphicx- Provides commands to include graphics files
 fancyhdr -Customizes headers and footers
 rotating -Provides rotations, especially for figures & tables
 color -Provides a way to use colors
 epstopdf -

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 9
Preamble - Pagestyle
Preamble can also contain the header/footer style
\pagestyle{style option}

Commonly-used style options:


 empty - (header and footer empty, no page number )
 plain - (page number in the footer alone, no header)
 headings- (chapter heading in odd header and section heading in
even header, no footers)
 myheadings -(user defined text in odd and even headers,
no footers)

(You can also define your own custom headers and footers with fancied text, boxes, graphic,
etc.)

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 10
Example:

a) \documentclass[a4paper,11pt,twocolumn]{article}
b) \usepackage{amsmath,times}
c) \pagestyle{headings}
d) \pagestyle{empty} % no pagenumbers
e) \begin{document}
Document text (text with embedded LATEX commands)
---------------------
\end{document}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 11
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 12
The Document
Document text has three parts : i) frontmatter
ii)mainmatter
iii)backmatter

i)Frontmatter :
It contains the title of the article, its authors name, affiliations and
an optional date.
\title{Title text}
\author{Author names and addresses}
\date{Date text}
\maketitle

(The \maketitle command will trigger the typesetting of the frontmatter part.)

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 13
i)Frontmatter :(conti...)
Abstract : Abstract is produced with the command:
\begin{abstract}
Text for the abstract
\end{abstract}

In report - Abstract appears on a separate page without a page number,


In article- Abstract comes after the title heading on the first page.
In book- Abstract is not possible.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 14
ii)Mainmatter
It contains the main body of the document.
Sectioning Commands :
\chapter{..} \section{..} \subsection{..} \subsubsection{..}
\part{..} \paragraph {..} \subparagraph {..}

In book,report class It contains \chapter, \section, \subsection and \subsubsection.


\chapter{chapter title-1}
\section{title-1}
text for title-1
\subsection{title-2}
text for title-2
\subsubsection{title-3}
text for title-3
\paragraph{Paragraph title}
This is sample paragraph.
In article class It contains the rest except the \chapter command

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 15
ii)Mainmatter: (conti...)
\subsection*{section name}
It only adds an entry in the navigation bars, not the table of contents.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 16
iii)Backmatter
It contains the References, or bibliography, that are referred
to within the text appear.

\section*{References}
\begin{thebibliography}{9}

\bibitem{iopartnum} Book W.J, Maizzo-Neto O and Whiteny D.E


1975 Feedback control of two beam, two joint systems with
distributed flexibility {\it ASME J of Dynamics systems
Measurements and Control}{\bf 0} 00

\end{thebibliography}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 17
iii)Backmatter : (conti...)
\cite{ref1} --- (References are cited in the body of the document)

\begin{thebibliography}{00}
\bibitem{ref1} This is sample bibitem one.
\bibitem{ref2} This is sample bibitem two.
\bibitem{ref3} This is sample bibitem three.

\bibitem{iopartnum}This is sample bibitem three.333


\bibitem{iopartnum}This is sample bibitem three.333
\bibitem{iopartnum}This is sample bibitem three.333
\end{thebibliography}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 18
Cross-References
It cross-references section number in a document

 \label{name}-label the point in your document with some


mnemonic,
 \ref{name}- includes the number of the section, figure, etc. of
that point.
 \pageref{name} includes the page number of of that point.

(As with your bibliography citations, you will need to run LaTeX twice to
generate these references.)

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 19
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 20
Adding a Graphics Image
graphics package - \usepackage{graphics}
graphics package supports - .pdf, .jpg, .jpeg, .png formats

figure environment take care of numbering and positioning


\begin{figure}[h!]

\end{figure}

Location of image :
h(here)- Same location t(top)-top of page
p(page)- on extra page b(bottom)-bottom of page
!(0ver ride)- force the specified location

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 21
Graphics Image (conti..)
To include the image
\includegraphics[height=3cm]{iitb.pdf}
\includegraphics[width=\linewidth]{iitb.pdf}
\includegraphics[width=14pc,height=6pc,scale=2,angle=90]{iitb.pdf}

Caption:
\caption{image title}

Cross-referring the image :


\label{tag}
\ref{tag}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 22
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 23
Tables
tabular environment
\begin{center}
\begin{tabular}{column specifications}
row 1\\
row 2\\
\end{tabular}
\end{center}

column specifications: c -center,


l left justified,
r right justified

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 24
Tables (conti..)
& -separates the column entries in a row
\\ -terminates the row
\hline -creates the horizontal line in a row
| - vertical bar in column specification, creates
vertical lines
|| -Double vertical rule column
p{width} -a left-justied column of the given width
@{text} -inserts the given text between columns

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 25
Tables (conti..)
Example:
\begin{tabular}{|c|lr|}
\hline
Column 1 & Column 2 & Column 3\\
\hline
This & is & a row\\
\hline
And this & will be & another row\\
\hline
\end{tabular}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 26
Tables (conti..)
*{num}{str} - string str repeats num times
\\[6pt] - separates two rows of the table by 6 points
of blank
\cline{3-5} -produces a horizontal line spanning
columns 3, 4 and 5 in the table.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 27
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 28
Equations
Four environments for formatting equations are :
1) Display Math : (for unnumbered equations)
\begin{displaymath} ... \end{displaymath}

Example :

 The quadratic equation$ax^2+bx+c=0$ has 2 roots:


 \[ x=\frac{-b \pm \sqrt{b^2-4ac}}{2a} \]
 \[ax^2+bx+c=0\]
 $$ ax^2+bx+c=0 $$
 $ ax^2+bx+c=0 $

$...$: dollar sign surrounds the equations in inline mode

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 29
Equations (conti..)
2) Equation Environment : (for numbered equations)
\begin{equation}. . . \end{equation}
Example 1:
\begin{equation}
\frac{a^2 - b^2}{a + b} = a - b
\end{equation}

Example 2:
\begin{equation}
\int_0^{\infty} e^{-\rho} \rho^{2l}\left[ L_{n+l}^{2l+1} \left(\rho
\right) \right]^2 \rho^2 d\rho = \frac{2n \left[\left(n+l\right)!
\right]^3}{(n-l-1)!}
\end{equation}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 30
Equations (conti..)
3) Eqnarray Environment : (for multiline equations)
\begin{eqnarray}. . . \end{eqnarray}
Example :
\begin{eqnarray}
\frac{a^2 - b^2}{a + b} * \frac{a^2 +b^2}{a+ b}= a-b\nonumber\\
\frac{a^2 - b^2}{a + b} * \frac{a^2 +b^2}{a+ b}= a - b\\
\frac{a^2 - b^2}{a + b} * \frac{a^2 - b^2}{a - b}= a - b
\end{eqnarray}

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 31
Equations (conti..)
4) Array Environment : (for matrices, etc.)
\[
\begin{array}{justification}
data
\end{array}
\]
It must be inside a math environment.
Example : \[
\begin{array}{rcl}
\alpha&\beta&\gamma\\
\delta&\epsilon&\zeta\\
\eta&\theta&\iota\\
\end{array}
\]

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 32
Dr.J.Upendar,Asst.Prof, EED,UCE,OU 33
Font Size
In addition to font size available in \documentclass,
the font size within your text can be changed
with the following commands :

 tiny {\tiny }
 scriptsize {\scriptsize }
 footnotesize {\footnotesize }
 small {\small }
 normalsize {\normalsize }
 large{\large }
 Large {\Large }
 Huge {\Huge }

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 34
LaTeX Advantages
1) LATEX provides an easy-to-use method for producing high-quality typeset
math.
2) LATEX provides very high quality typeset output which pays attention to fine
typographical details such as math typesetting, ligatures (i.e. ` instead of
`fi'), advanced font handling (with both slanted and italics text, which are
slightly different), and hyphenation that are often handled poorly in
WYSIWYG programs.
3) The LATEX markup language lends itself to writing well-structured
documents that are easy to modify.
4) The user only needs to learn a few easy commands, and generally does not
need to tinker with the actual layout of the document.
5) Even complicated structures such as footnotes, cross-references, indices,
tables of contents, and bibliographies are easily generated.
6) The basic functionality of LATEX can be enhanced by using free add-on
packages that provide features such as graphics, endnotes, etc.
7) LATEX is freely available for almost every computer platform in existence.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 35
LaTeX Disadvantages
1. LATEX is not WYSIWYG you have to run latex on
your file before you can see your changes.
2. If you are trying to produce a document for which
there is no pre-defined layout, it requires a fair bit of
knowledge to design a new layout.
3. You cannot easily exchange LATEX files with
colleagues that are unfamiliar with it.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 36
Thank You
You have already taken your first step by attending this
session.

Enjoy writing with LaTeX

Final Words: Try it

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 37
References:
[1]. On-line Tutorial on LATEX, The Tutorial Team, Indian TEX Users Group, sjp Buildings, Cotton Hills,
Trivandrum 695014, india, 2000.
[2]. A Beamer Tutorial in Beamer, by Charles T. Batts, Department of Computer Science, The University
of North Carolina, 2013.
[3]. A PPT on LaTeX Short Course, by Blake Larson, @me.umn.edu.
[4] Getting Started with LATEX, by David R. Wilkins, 2nd Edition, 1995.
[5]. LaTeX Tutorial, by Je Clark, 2002.
[6]. A PPT on A Very Short Introduction to LaTeX, Dept. of Applied Math & Statistics, School of
Engineering, University of California
[7]. Introduction to LaTeX, by Arun K. Subramaniyan, @purdue.edu
[8].LATEX Tutorial, by William Hicklin
[9]. Introduction to LATEX, Joe Struss, 2010
[10]. Beginner's LaTeX Guide
[11]. A Beginners Guide to LATEX, by David Xiao, @cs.princeton.edu, 2005
[12]. A quick start to LATEX, by Claudio Vellage, 2013
[13]. A LATEX Tutorial, by Jim Alexander, 2002
[14]. LATEX Mini-Tutorial
[15]. A brief LATEX tutorial., by Henri P. Gavin, Department of Civil and Environmental Engineering,
Duke University, 2002
[16]. LATEX2" for authors , LATEX3 Project Team., 2001.

Dr.J.Upendar,Asst.Prof, EED,UCE,OU 38

Вам также может понравиться