handout latex
TRANSCRIPT
-
7/31/2019 Handout Latex
1/19
An Introduction to LATEX
Dr. Abhijit Sarkar
Machine Design SectionDepartment of Mechanical EngineeringIndian Institute of Technology Madras
Chennai - 600 036, TN, India.
October 11, 2012
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 1 / 19
-
7/31/2019 Handout Latex
2/19
Outline & Objective
1 Introduction
2 Basic LATEXcommands
3 Bibtex
ObjectiveAppreciation of the features in LATEX.Preparation of documents and presentations in LATEX
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 2 / 19
-
7/31/2019 Handout Latex
3/19
Introduction
What is LATEX?
LA
TEXis a typesetting program.The user prepares an input file which is compiled by LATEXtogenerate an output pdf file.
The input file contains different LATEXcommands and the text
material.Typical commands - formatting, inserting mathematical symbolsand equations, inserting pictures, etc.
High quality technical documents can be generated efficiently
using LA
TEX.Most reputed journals, international conferences, universitythesis encourage documentation through LATEX.
Learning curve for LATEXis steep in the begining but with someexperience the user grows comfort in the usage.
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 3 / 19
-
7/31/2019 Handout Latex
4/19
Introduction
Installing LATEX
LATEXis a freeware.
Various installations of LATEXare available depending on theOperating System, 32bit/64 bit, etc. Example - Miktex 2.9
A front end text editor with special formatting for the latexcommands is also helpful. MikTex 2.9 comes with the frontendtexworks. Others can be downloaded separately such asTexniccenter, Texmaker, gvim, etc.
Variants are available for compiling e.g. - Latex, pdflatex, Tex,XeLatex, etc.
Exercise: Install LATEXin your system. You will get a lot of helpon this from the web.
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 4 / 19
B i LAT X d
-
7/31/2019 Handout Latex
5/19
Basic LATEXcommands
Structure of a LATEXinput file\documentclass[a4paper, 12pt]{article}
% This is a comment% Every document should begin with
% a document class specification
\usepackage{amsmath}
\usepackage{graphicx,subfigure}
% additional packages to be included during the% compilation process
\newcommand{\drop}[1]{}
\begin{document}
\section{Introduction}This is the introduction
\section{Conclusion}
This is the conclusion
\end{document}
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 5 / 19
B i LAT X d
-
7/31/2019 Handout Latex
6/19
Basic LATEXcommands
Sectioning and Subsectioninng
\section{Introduction}
\label{sect:intro}This is introduction
\section{Method}
\label{sect:method}
This is the method.\section{Results}.
Using the method described in
section \ref{sect:method},
following results are obtained.
\subsection{Validation}Old Results Reproduced
\subsection{Novel Results}
New Results
\section{Conclusion}
1. Introduction
This is introduction2. Method
This is the method3. Results
Using the method de-scribed insection 2, followingresults are obtained.3.1 Validation
Old Results Repro-duced3.2 Novel Results
New Results
4. ConclusionA. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 6 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
7/19
Basic LATEXcommands
Setting the margins
\topmargin0.1inThe top margin of the page is set as 0.1in.
\textheight9.5in
The text portion contained in the page is of height 9.0in .
\textwidth6.5inThe text portion contained in the page is 6.5in wide.
\oddsidemargin0.1in
For odd pages a margin of 0.1in is given on the left side.
\evensidemargin0.1inFor even pages a margin of 0.1in is given on the left side.
Negative values may also be used in topmargin, oddsidemargin,evensidemargin to reduce the margin.
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 7 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
8/19
Basic LATEXcommands
Fonts
\textbf{Bold}
\textit{Italics}
\textsl{Slanted}
\textsc{SmallCaps}
\textsf{Sans Serif}
\texttt{Typewriter}\textcolor{red}{Red}
\underline{Underline}
\underline{\textbf{Important}}
\fbox{boxed}
Bold
ItalicsSlanted
SmallCaps
Sans Serif
TypewriterRedUnderlineImportant
boxed
Font size can be changed by the following commands
\small{}, \tiny{}, \large{}, \Large{}, \Huge{}
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 8 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
9/19
Basic LATEXcommands
Math environment
Mathematical symbols and formulae are typeset in math environmentText. $\alpha + 1 = \beta$
This is a equation
\begin{equation}
\nabla^2 \phi = 0\label{laplace}
\end{equation}
Refer equation (\ref{laplace}).
This is an unnumbered equation
\begin{displaymath}
\nabla^2 \psi + k^2 \psi = 0
\end{displaymath}
Text. + 1 = This is a equation
2 = 0 (1)
Refer equation (1)
This is an unnumberedequation
2 + k2 = 0
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 9 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
10/19
Basic LTEXcommands
Typesetting Mathematical Formulae
Input Command
\alpha + \beta = \gamma
Output: + =
Input Command
\frac{D f}{D t} = \frac{\partial f}{\partial t} +
u \frac{\partial f}{\partial x}
Output: DfDt
= ft
+ ufx
Input command
\int_0^1 x^2 \, dx = \frac{1}{3}
Output:1
0x2 dx = 1
3
Input command
\tau_{ij} n_j = T_i
Output: ijnj = Ti
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 10 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
11/19
E
More Mathematical Formulae
Input Command:
\sum_{n=1}^{N} n = \frac{n(n+1)}{2}
Output:N
n=1 n =n(n+1)
2
Input Command:
\frac{D u}{D t} =\overbrace{\frac{\partial u}{\partial t}}^{\mbox{
Local}} +
\underbrace{u \frac{\partial u}{\partial x}}_{\mbox{
Convective}}
Output: DuDt
=
Localu
t+ u
u
x
ConvectiveA. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 11 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
12/19
E
More Mathematical Formulae
Input Command:
\left(\stackrel{\rightarrow}{a} \otimes
\stackrel{\rightarrow}{b} \right)
\stackrel{\rightarrow}{c}
= \left( \stackrel{\rightarrow}{b}
\cdot \stackrel{\rightarrow}{c}\right) \stackrel{\rightarrow}{a}
Output:(
a
b
)
c=(
b
c)
a
Input Command:
\int_V \nabla \cdot \stackrel{\rightarrow}{v} \, dV
=
\oint_S \stackrel{\rightarrow}{v} \cdot \hat{n} \, dS
Output: V
v dV = S
v n dS
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 12 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
13/19
Long EquationsInput Command:
\begin{gather}
\mathcal{A} = a + b + \ldots z \\ \nonumber\alpha + \beta + \ldots
\end{gather}
Output:A = a + b+ c. . . + (2)
+ + + . . .
Input Command:
\begin{eqnarray}
x + y & = & 3 \\ x - y & = & 1 \\
\Rightarrow x = 2 & \& & y = 1 \nonumber
\end{eqnarray}
Outputx + y = 3 (3)
xy = 1 (4)
x = 2 & y = 1A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 13 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
14/19
Typesetting Matrices
Input Command:
\begin{displaymath}\left[
\begin{array}{cc}
\alpha & \beta \\
\gamma & \delta
\end{array}\right]
\left\{
\begin{array}{c}
x_1 \\x_2
\end{array}
\right\}
\end{displaymath}
Output[
]{x1x2
}
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 14 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
15/19
Typesetting Tables
\begin{table}[htbp]
\begin{tabular}{||l|c|c||} \hline\textbf{Name} & Dept & CGPA \\ \hline \hline
Abc & ME & x.y \\ \hline
Pqr & ME & y.x \\ \hline
\end{tabular}\caption{Caption}
\label{tab1}
\end{table}
Table \ref{tab1} can be
refered in this way
Name Dept CGPA
Abc ME x.yPqr ME y.x
Table: Caption
Table 1 can berefered in thisway
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 15 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
16/19
Inserting Pictures
It is best to insert picture files in the form of .eps (latex) or .jpg
(pdflatex) formatLATEXcommand for inserting a picture file
\begin{figure}
\includegraphics[width=0.5in]{iitm2.eps}
\caption{IITM Logo}\label{figlogo}
\end{figure}
The figure \ref{figlogo} can be refered in this way.
Output
Figure: IITM Logo
The figure 1 can be refered in this way.A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 16 / 19
Basic LATEXcommands
-
7/31/2019 Handout Latex
17/19
New commands
Input:\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\drop}[1]{}
\begin{document}
bla bla
\be
\alpha \beta = \gamma
\ee
\drop{This is rejected .}\end{document}
Output: bla bla = (1)
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 17 / 19
-
7/31/2019 Handout Latex
18/19
References
1 LATEXA Docment Preparation System Users Guide andReference Manual - L. Lamport, Pearson Education, 2009.
2 The not so short introduction to LATEX- T. Oetiker, et. al. 2006(available on net).
3 The LATEXcompanion - M. Goosens, F. Mittelbach and A.Samarin, Addison Wesley, 1994.
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 18 / 19
-
7/31/2019 Handout Latex
19/19
Thank You
A. Sarkar (Mech Engg. @IITM) ID6020 Mar 2012 19 / 19