Latex Basics for Students

  1. INTRODUCTION
    Students often need to convert their reports into a polished document (perhaps for publication). Tex/LaTeX is widely regarded as a great software (besides being free) for accomplishing this; If you have mathematical notations, then there is nothing else that I consider its equal. To avoid repeating myself to students, here is a primer for getting started. Please send me your comments at email.

    Other links:

    1. Homepage for LaTeX
    2. Download LaTeX
    3. The UK TeX Archive
    4. Book ``Learning Latex'' by Griffiths and Higham from SIAM publications.
  2. FIRST STEPS
    LaTeX (simply written ``latex'' in the following) is a macro package based on Knuth's typesetting language called TeX. Most users find it easier and sufficient to learn latex. Also, note that there are several variants of LaTeX, but we recommend the variant known as LaTeX2e.

    Unlike "WYSIWYG" typesetters which are bundled into the editor (as is typical in a PC platform), TeX/LaTeX is a language-based approach. You prepare a latex file by interspersing latex commands with your texts, in order to produce the desired output. E.g., in the output sequence ``Hello World!'', if you wish the word ``Hello'' to be in bold font, your latex file will contain the sequence

    {\bf Hello} World!
    Note that \bf is a latex command to change the font to bold face. The curly brackets {...} is latex's way of isolating the context of the bold face.

    The advantage of this approach is that you are in greater control of your output. The disadvantage is that you need to run latex on your file, whose output is a binary file in the so-called dvi-format, which can be viewed by using a viewer such as xdvi. In any case, this is the dominant approach in the Unix world and in academic computer science. By most accounts, TeX (and therefore latex) produces superior output. This is especially so for mathematical typography.

    Another introduction from the latex homepage.

  3. HOW TO PRODUCE AN OUTPUT FROM A LATEX FILE
  4. WHAT DOES THE FILE REPORT.TEX LOOK LIKE?
    Here is a typical outline:
    	% This is a comment line
    
    	\documentclass{article}
    
    	\begin{document}
    
    	% Note to self:
    	%    I must change this title later!
    	\title{Hello World}
    
    	\author{Your Name\\
    		Department of Computer Science\\
    		Courant Institute, NYU}
    	\maketitle
    
    	\begin{abstract}
    		...put your abstract here...
    	\end{abstract}
    
    	\section{First Section}
    		...text...
    	\subsection{First subsection}
    		...text...
    	\subsection{Second subsection}
    		...text...
    	\section{Second Section}
    		...text...
    
    	...and so on...
    	\end{document}
    	
    NOTES:
    I. Latex commands are in red font.
    II. Notice the three comment lines that are preceded by %.
    III. You can literally type the above text into a file called report.tex, and latex it as suggested above.
  5. Remember, newlines and empty spaces (including tabs) do not mean much to latex. Latex will convert a sequence of empty spaces into (essentially) a single space.
  6. USEFUL FACTS
    1. The percentage character (%) indicates that the rest of the input line is to be ignored (treated as a comment)
    2. (a) Include files: if you have some texts in another file (say, report1.tex), you can ask latex to insert it into your current file by issuing the latex command
      		\input{report1}
      	
    3. (b) Fonts: you can have bold font, italics font, etc as follows:
      		{\bf This is in bold} and 
      		{\it this is in italics}
      		and this is in default roman 
      		{\rm as is this}.
      	
    4. (c) If you want something to appear "as is" you can enclose it within the following:
      		\begin{verbatim}
      		...text, e.g., VRML nodes...
      		\end{verbatim}
      	
    5. (d) There are kinds of lists. Here is one:
      		\begin{enumerate}
      		\item First item...
      		\item Second item...
      		...
      		\end{enumerate}
      	
      The numbers 1, 2, etc, are automatically generated for each item.
      Instead of the "enumeration" list above, you can use a "description" list instead:
      		\begin{description}
      		\item[(a)] First item...
      		\item[(b)] Second item...
      		\end{description}
      	
      Note that the main difference is that "\item" now takes an argument (enclosed in square brackets), and these are used as the labels for your items.
  7. MORE ADVANCED FEATURES
    You can quickly pick up the following:
  8. BASIC MATH TYPOGRAPHY
    1. TO typeset math, you need to enclose your math typography within special brackets: either
      $ ...math typography... $
      or
      \begin{equation}
      ...math typography...
      \end{equation}
      The difference between the former and the latter is that the former is ``inline'' while the latter is typeset in its own (center) lines.
    2. Math symbols are typeset in italics. So variables like ``x'' should be written as ``$x$''.
    3. Greek symbols: these have obvious names like
      \alpha, \Alpha, \beta, \Beta, \gamma, \Gamma, ...
    4. Subscripting and superscripting:
      You type this To get this
      x_i: "x sub i"
      x_{i,j} "x sub i,j"
      x^i "x sup i"
      x^{i,j} "x sup i,j"
      x_i^j (equivalently, x^j_i) "x sub i sup j"
    5. Here is how you typeset a 3x3 matrix with (i,j)-th entry of $a_{i,j}$:
      \left(
      -- this is the left paren of the matrix
      \begin{array}{ccc} -- this declares the matrix to have 3 columns (c=centered)
      a_{1,1} & a_{1,2} & a_{1,3} \\ -- the first row
      a_{2,1} & a_{2,2} & a_{2,3} \\ -- the second row
      a_{3,1} & a_{3,2} & a_{3,3} \\ -- the third row
      \end{array} -- finish declaring matrix entries
      \right) -- this is the right paren of matrix
  9. FIGURES
    Latex has some figure drawing capabilities which can even be integrated into the text. But for stand-alone figures, my favorite tool is xfig. One very important feature that I exploit in xfig is the ability to include text that are processed as LaTeX commands. This is critical when the figure has labels with subscripts/superscripts or other mathematical symbols. In any case, you want these labels in the figure to look exactly like in the rest of the text.
  10. BEYOND TEX/LATEX


Last Update: September 1997.