1. Document Preparation using LATEX
Document Processor not a Word Processor
A.B. Raju and Satish Annigeri
B.V.B. College of Engineering & Technology
Hubli 580 031
20 Sep, 2014
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 1 / 23
2. LATEXversus MS Word
Microsoft Word is good for
short documents, such as cover
pages, letters, or documents
with about 100 pages. Basic
features are easy to learn and
GUI is useful for normal users.
If you are writing a long
document like a Technical
paper, Project report, an article,
or a review, you are better o
with LATEX. Initial learning curve
is steep, but persist with it and
you will be rewarded.
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 2 / 23
3. Document Preparation
Document Preparation is concerned with creating documents for print or
electronic distribution.
Typical document structure for long documents
Front matter
Main matter
Back matter
Mathematical equation typesetting
Lists
Tables
Reference citation
Cross referencing within the document
LATEX lets the author take care of logical structure while it takes
care of visual structure
Word processors require the author to take care of both logical and
visual structure
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 3 / 23
4. LATEX History
Donald Knuth
Professor Emeritus, Stanford
University
Author of the multi-volume The
Art of Computer Programming
Creator of TEX computer
typesetting system and
METAFONT font de
5. nition
language
TEX was developed in late 1970s
by Donald Knuth Donald Knuth
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 4 / 23
6. LATEX History contd
Leslie Lamport
Initially developed the LATEX
system as a document
preparation system
Developed when Leslie Lamport
was working at SRI International
Currently works at Microsoft
Research
LATEX was
7. rst released in the
year 1985
Current version is LATEX2
Leslie Lamport
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 5 / 23
8. Installing LATEX
Microsoft Windows
MiKTeX is a popular LATEX distribution for Microsoft Windows
Has a package manager to install additional packages or remove
installed packages
Has an update manager to update installed packages
Can be downloaded from http://miktex.org
GNU/Linux
TeXLive is a LATEX distribution for GNU/Linux
Installation and package management is done through the system
package manager - one of apt-get, yum, zypper depending on your
GNU/Linux distribution
LATEX editors
TeXstudio - Windows and GNU/Linux
http://texstudio.sourceforge.net/
TeXMaker - Windows and GNU/Linux
http://www.xm1math.net/texmaker/
TeXnicCenter - Windows http://www.texniccenter.org/
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 6 / 23
9. LATEX Document Preparation Work
ow
1 Write the LATEX source document in a text editor
2 Compile the LATEX source document to your preferred output format
3 View the document
4 Repeat this loop to modify the document
Popular output formats
DVI { DVI viewer (xdvi on GNU/Linux, YAP in MiKTeX)
PDF { Acrobat reader or other PDF viewers (xpdf or evince on
GNU/Linux, Sumatra on Windows)
Postscript (PS) { Ghostview viewer (Ghostscript)
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 7 / 23
11. Structure of a Document
A document can be structured into the following
Part part Book
Chapter chapter Book, Report
Section section Book, Report, Article
Sub Section section Book, Report, Article
Sub Sub Section section Book, Report, Article
Paragraph subsection Book, Report, Article
Sub Paragraph subsubsection Book, Report, Article
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 9 / 23
12. Choosing the Right Document Class
Book
Title page on a separate page by itself
Can contain parts, chapters, sections, subsections, subsubsections and
paragraphs
New chapters begin on a new page, on the right side by default
Document is two sided by default, can be changed to one sided
Can optionally have appendices.
Report
Title page on a separate page by itself
Can contain chapters, sections, subsections, subsubsections, paragraphs
New chapters begin on a new page
Document is one sided by default. Two sided is optional
Article
No separate page for title page
Can contain sections, subsections, subsubsections, paragraphs
Document is one sided by default. Two sided is optional
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 10 / 23
13. Adding Sections
documentclass{article}
begin{document}
section{Word} label{sec:word}
I prefer using LaTeX{} to using Microsoft Word or
other word processors.
section{Latex}label{sec:tex}
I love LaTeX. As I mentioned in Section~ref{sec:word},
I do not like word processors.
end{document}
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 11 / 23
14. Some Tips for Beginners
Words are separated by spaces. Number of spaces doesn't matter,
one is as good as 100.
Paragraphs are separated by empty lines. Number of empty lines
doesn't matter, one is as good as 100.
LATEX is a markup language. To make something to be printed in
bold in the document, you mark it in the source with
textbf{this will be in bold}.
Following characters are reserved for use by LATEX {
# $ % ~ _ ^ { }. To print these characters in your document,
you will have to escape tem. For example to print .
The characters that can appear in your text are:
Alphabets: a-z, A-Z
Digits: 0-9
Punctuation: . : ; , ? ! ` ' ( ) [ ] - / * @
Mathematical symbols: + =
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 12 / 23
15. Some More Tips
A soft return is introduced with two backslashes:
A non-breaking space is: ~ as in Chapter~1
LATEX automatically hyphenates words where necessary
Beginners must look out for some common errors:
A misspelled command or environment name
Improperly matching braces
Trying to use one of the ten special characters # $ % _ { } ~ ^ ,
as an ordinary printing symbol without escaping them
Improperly matching formula delimiters { for example, ( without a
matching )
The use in ordinary text of a command like ^ that can appear only in a
mathematical formula
A missing end command
A missing command argument
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 13 / 23
16. All the Fuss about Spaces
Space after a sentence is longer than a normal space. Can you see it
just before this sentence begins?
Sometimes the period does not represent end of a sentence, such as,
Prof. Donald Knuth. The period after Prof. does not end a sentence.
You can tell this to LATEX. prints a normal space. Compare the
following in the printed document:
Prof. Donald Knuth { Prof. Donal Knuth
Prof. Donald Knuth { Prof. Donald Knuth
Non-breaking space is introduced with ~
Prof. Donald Knuth { Prof. Donal Knuth
Prof. Donald Knuth { Prof. Donald Knuth
Prof. Donald Knuth { Prof.~Donald Knuth
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 14 / 23
17. Equation Example
documentclass{article}
begin{document}
begin{equation} label{eq:sum}
s = sum_{i=1}^{n}x_{i}
end{equation}
end{document}
Mathematical equations can be displayed in displaymath or
equation environment, with or without numbers.
Displaymath mode without numbering: [ x' + y^2 = z_i ] or
use the begin{equation*} x' + y^2 = z_i end{equation*}
environment
Inline math mode: Mathematical expressions within running
sentences: radius of a circle is $r^2 = x^2 + y^2$ or
radius of a circle is ( r^2 = x^2 + y^2 ), which will
print as: radius of a circle is r 2 = x2 + y2
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 15 / 23
18. documentclass{article}
begin{document}
begin{equation} label{eq:mean}
bar{x} = frac{sum_{i=1}^{n}x_{i}} {n}
end{equation}
The equation for mean is given in Equation ref{eq:mean}.
end{document}
x =
Pn
i=1 xi
n
(1)
The equation for mean is given in Equation 1.
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 16 / 23
21. documentclass{report}
title{Learn LaTeX}
author{A.B. Raju}
begin{document}
maketitle
tableofcontents
include{chapter_1}
include{chapter_2}
include{chapter_3}
end{document}
In the above example, each chapter is typed in a separate
22. le, and
included into the main document in the right sequence.
Filenames usually have the .tex extension, but it is not included in
the include{filename} command
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 19 / 23
23. Including Graphics
Convert images into .jpg/.eps or .pdf format
Include package graphicx
Use the includegraphics{filename} command
Filename is case sensitive on some GNU/Linux and Mac OS X
To specify options, use the
includegraphics[options]{filename} command
Options may include [width=2.5cm], [height=5cm] etc
LATEX understand several standard length units such as:
in for inch, cm for centimeter, pt for point. 1 inch is 72 points
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 20 / 23
24. An example
documentclass{article}
usepackage{graphicx}
begin{document}
begin{figure}
includegraphics{MyBat}
caption{This is My Bat} label{fig:bat}
end{figure}
In Figure ref{fig:bat}
end{document}
A.B. Raju (BVBCET, Hubli) Document Preparation using LATEX 20 Sep, 2014 21 / 23