LATEX Intro
Introduction to LATEX
A document preparation system
V. Sasi Kumar
Free Software Foundation of India
Prepared using LATEX
LATEX Intro
LATEX is a document preparation system
It helps you to:
• typeset a document
• create ToC, table of figures, index, etc.
• create good-looking equations
• cite references properly and list them
• manage cross-references
and more ...
LATEX Intro
LATEX is not an application, like a Word processor
It is more like a programming language
You prepare a text file and then compile it
LATEX Intro
LATEX is not an application, like a Word processor
It is more like a programming language
You prepare a text file and then compile it
LATEX Intro
LATEX is not an application, like a Word processor
It is more like a programming language
You prepare a text file and then compile it
LATEX Intro
LATEX is really a set of macros for the TEX system cre-
ated by Prof. Donald Knuth
LATEX was created by Leslie Lamport
There are other similar systems also, such as ConTeXt,
XeTeX and LuaTeX.
LATEX Intro
LATEX files are simply text files with commands
embedded along with the content
LATEX could be compared with a Markup language like
HTML
Let us look at a sample document ......
LATEX Intro
LATEX files are simply text files with commands
embedded along with the content
LATEX could also be compared to a Markup language
like HTML
Let us look at a sample document ......
LATEX Intro
LATEX files are simply text files with commands
embedded along with the content
LATEX could also be compared to a Markup language
like HTML
Let us look at a sample document ......
LATEX Intro
Here is how we can write a simple LATEX file:
\documentclass[a4paper,12pt]{article}
\begin{document}
The true spirit of delight, the exaltation, the sense of being
more than man, which is the touchstone of the highest excellence, is
to be found in Mathematics as surely as in poetry...
\end{document}
LATEX Intro
Let us save this file as, say, mydoc.tex
We can then compile this file using the command
latex mydoc.tex
The result will be a file called mydoc.dvi
LATEX Intro
Let us save this file as, say, mydoc.tex
We can then compile this file using the command
latex mydoc.tex
The result will be a file called mydoc.dvi
LATEX Intro
Let us save this file as, say, mydoc.tex
We can then compile this file using the command
latex mydoc.tex
The result will be a file called mydoc.dvi
LATEX Intro
Let us save this file as, say, mydoc.tex
We can then compile this file using the command
latex mydoc.tex
The result will be a file called mydoc.dvi
LATEX Intro
The .dvi file can be converted to a postscipt or pdf file
using simple commands.
Alternatively, we could simply do
pdflatex mydoc.tex
and get a pdf file.
LATEX Intro
A LATEX document normally has two parts:
1. a preamble — what comes before the \begin{document} com-
mand
2. the body — what comes between \begin{document} and
\end{document}
LATEX Intro
The preamble contains document specifications and list
of packages used. Example:
\documentclass[a4paper,12pt]{article}
\usepackage[hmargin=1in,vmargin=1in]{geometry}
\usepackage{color}
\usepackage{graphicx}
\usepackage{fancyhdr}
\cfoot{}
\rhead{\thepage}
LATEX Intro
Packages make it easier to do things.
For instance, the geometry package makes it easy to set
margins:
\usepackage[vmargin=2cm,hmargin=1in]{geometry}
LATEX Intro
Packages make it easier to do things.
For instance, the geometry package makes it easy to set
margins:
\usepackage[vmargin=2cm,hmargin=1in]{geometry}
LATEX Intro
There are several document classes:
• article
• report
• book
• letter
• beamer (for pre-
sentations)
...... and so on. And one can create one’s own class too.
Each has its own features.
LATEX Intro
There are several document classes:
• article
• report
• book
• letter
• beamer (for pre-
sentations)
...... and so on. And one can create one’s own class too.
Each has its own features.
LATEX Intro
There are several document classes:
• article
• report
• book
• letter
• beamer (for pre-
sentations)
...... and so on. And one can create one’s own class too.
Each has its own features.
LATEX Intro
LATEX commands start with a backslash (\). They are
of the form:
command [options]{arguments}
For example:
\includegraphics[scale]path/filename
LATEX Intro
LATEX commands start with a backslash (\). They are
of the form:
command [options]{arguments}
For example:
\includegraphics[scale]{path/filename}
LATEX Intro
Just as in a programming language, there are special
characters in LATEX too. These are:
\backslash, used for commands
{}braces, used for command arguments
% percent, to mark comments
$dollar sign, to denote math typesetting
ˆmath superscript
math subscript
& ampersand, to separate columns in tables
# hash, macro parameters
˜ non-breaking space
They cannot be used directly in the body
LATEX Intro
Just as in a programming language, there are special
characters in LATEX too. These are:
\backslash, used for commands
{}braces, used for command arguments
% percent, to mark comments
$dollar sign, to denote math typesetting
ˆmath superscript
math subscript
& ampersand, to separate columns in tables
# hash, macro parameters
˜ non-breaking space
They cannot be used directly in the body
LATEX Intro
To get these characters in your LATEX document, use:
To get: Use:
\ \textbackslash
{} \{ \}
% \%
$ \$
ˆ \textasciicircum
\
& \&
# \#
˜ \textasciitilde
LATEX Intro
LATEX is especially good for structured documents. It
supports commands like
• \part
• \chapter
• \section
• \subsection
depending on the documentclass
LATEX Intro
LATEX uses environments for different purposes:
• lists
• quotations
• figures
• tables
• equations
LATEX Intro
Environments begin with a \begin command and end
with an \end command:
\begin{tabular}{rlp{3cm}}
\hline\hline\\
& {\bf Planet} & {\bf Atmosphere}\\
\hline \hline
1 & Mercury & No atmosphere\\
2 & Venus & Heavy atmosphere \\
\hline\hline
\end{tabular}
LATEX Intro
This is how the table would look
No. Planet Atmosphere
1 Mercury No atmo-
sphere
2 Venus Heavy
atmosphere
LATEX Intro
Long Table
A table like this will not flow beyond a page
If you need a table that goes beyond a page,
you need to use a longtable
LATEX Intro
The Figure environment is another example:
\begin{figure}
\includegraphics[scale=scale]{\path\filename.ps}
\captionThis is the figure caption.
\end{figure}
LATEX Intro
The Figure environment is another example:
\begin{figure}
\includegraphics[scale=scale]{\path\filename.ps}
\caption{This is the figure caption.}
\end{figure}
LATEX Intro
To insert a graphics file in your document, add the state-
ment \usepackage{graphicx} in the preamble and use
the command pdflatex <filename> to directly get a pdf
file. In this case, you can use graphics files in different
formats, such as jpeg, png, pdf, etc.
LATEX Intro
A LATEX document can be created using any text editor.
But, there are editors that facilitate this. Examples are:
GNU/Linux:
• GNU Emacs
• Kile
• Gedit
• TEXmacs
MS Windows:
• WinEdit
LATEX Intro
A LATEX document can be created using any text editor.
But, there are editors that facilitate this. Examples are:
GNU/Linux:
• GNU Emacs
• Kile
• Gedit
• TEXmacs
MS Windows:
• WinEdit
LATEX Intro
A LATEX document can be created using any text editor.
But, there are editors that facilitate this. Examples are:
GNU/Linux:
• GNU Emacs
• Kile
• Gedit
• TEXmacs
MS Windows:
• WinEdit
LATEX Intro
This is just an introduction to basic LATEX .
There is a lot more to learn
But, hopefully, you will find it interesting and conve-
nient as we move on
In the next sessions, we will see how to create lists and
boxes, prepare question papers and write mathematics
in LATEX like the statement:
R x sin x π
Thus, lim dx = and so, by definition,
x→∞ 0 x 2
Z ∞
sin x π
dx =
0 x 2
LATEX Intro
Thank You
Merci
Danke
Grazie
(This presentation is distributed under the Creative Commons Attribution Share Alike
Licence. Anyone may use this presentation anywhere in its original or modified form
provided this note is also included. Details about the licence may be seen at
http://creativecommons.org/about/licenses/by-sa/2.0.)
This presentation was created using LATEX . The source code can be obtained from the
author (sasi.fsf@gmail.com).
LATEX Intro