Latex program reads from input text (.tex) file and several other (e.g. jpg, eps etc.) files to produce a .dvi file. .dvi files encode information on fonts and formatting and are machine independent. DVI files can be then converted to many formats like pdf, postcript, etc. .tex files are created as “What You See Is What You Get.” Text formats are not displayed in input file but rather formatted display would be generated in the output .dvi file.

Preparing the Editor:

Emacs is the best editor that one can use for editing almost any form of documents/texts. It is better to configure Emacs for Latex mode. For enhancing the use, you can install packages like TeXLive, Auctex (for preview) and GNUPlot (for plotting graphs). You can use this command for installing these packages :

$sudo apt-get install texlive texlive-latex-extra emacs auctex gnuplot

Emacs use its own Lisp language to configure its behaviour. When you open a Latex file Emacs goes to Latex mode and changes the colour of standard strings, i.e. syntax highlighting. Go to the home directory of the user and create an file named ‘.emacs’ if it has not already been there. Now you can put your commands there to change the behaviour of Emacs. We can add these lines in that file:

(setq tex-dvi-view-command “xdvi”)

  1. Spell check: M-x flyspell-mode
  2. Compiling tex file: C-c-C-f / C-c C-c RET
  3. view the DVI file from last compile: C-c C-v

Latex Formatting:

An empty sample Latex input file looks like:

\documentclass[a4paper,12pt]{article}
\begin{document} 
\end{document}

’\’ is used for escape sequences. For giving double quotation 2 single quotations have to be provided in the input file. \, separates 2 subsequent quotations such as ‘\,’’ for printing ‘” in the output file. # $ % & _ { }are active characters in Latex. So, to produce these characters in dvi, you have to give one ‘\’ before these characters in the tex file, such as \& will produce &. For numbered section headings, \section{Section Headings}. For unnumbered section, write \section*{Section Headings}. \emph{text} will emphasize (mainly italics) the text. Size of text can be varied as \tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge and \HUGE.

To place horizontal and vertical space place \hspace and \vspace respectively. You can place the amount of space to leave within {} after this command as \vspace{10 mm}. Space can be provided in any of these units: pt, inch, cm, mm, etc. For listing some items, place them in anyone of these environments: \enumerate (numbered list), \itemize (unnumbered list) or \description (description list). Each item in the list should be preceded with control sequence \item in order to generate the number properly. To display program code in fixedwidth typewrite font, place it within \begin{verbatim} and \end{verbatim}.

Mathematical Formulas:

To incur Mathematics mode within a text/paragraph, single $ is provided before and after the formula. To display a formula in a separate line, place the formula in between [ and ] . To display automatic numbering of an equation, put the equation in between \begin{equation} and \end{equation}. ’~’ is provided to put a blank space. \backslash produces “". Subscript and superscript can be done by giving _ and ^ before the text respectively. When formatting multiple characters, place them inside {}.

Greek alphabets can be generated using: \alpha, \Alpha, \beta, \Beta, \gamma, \Gamma, \pi, \Pi, \phi, \varphi, \Phi, etc. Here upper case in the starting string will generate upper case symbols. Complete list of mathematical symbols can be found here. Standard functions such as sin, cos, etc. can be written as \sin, \cos, etc. For displaying text inside an equation, use \mbox{embeded text} or \text{}. Fraction and Square root are obtained by \frac{numerator}{denominator} and \sqrt{expression}. To place lim, format it as \lim_{x \to +\infty}. For summetion symbol put \sum_{i=1}^{2n}. Integration is generated by \int_a^b f(x)\,dx.

To denote ordered root, place \sqrt[n]{expression} where n is the order of the root. Three consecutive dots are obtained by placing \ldots (baseline), and \cdots (centreline). Alphabets can be formatted as: \underline{a}, \overline{a}, \tilde{a}, \dot{a}, \vec{a}, etc. in order to get desired effect in the dvi file. To get { or } in dvi, you have to place { or } in the tex file. to get   in dvi, place | in tex. To place equation inside big parenthesis, place the equation in between \left and \right. In order to allign = signs in a row, formulas are typeseted using eqnarray* environment and then = is placed in between & and &. To denote next line, place \\.