LaTeX Tutorial
Updated 1/25/2006
LaTeX is a big set of macros that allow authors to spend less time worrying about page layout and other formatting issues. When you use LaTeX it's very similar to creating a computer program which you can compile with a .pdf output. LaTeX is the mot common wordprocessing tool used in mathematics and it is especially nice when typing equations and mathematical symbols. I believe the best way to learn LaTeX is trial and error so I suggest you start with a basic .tex file and play with it. Then use a sample .tex file to learn how to spruce up your basic tex file.
What does a tex file look like? A basic .tex file
You must have these 3 lines surrounding your text in every .tex file:
\documentclass[10pt]{article}
\begin{document}
This is a basic document.
\end{document}
References:
How to get from .tex to .pdf:
Type the following commands (from the directory where your files live,
including any figures).
- pdflatex sample.tex
- pdflatex sample.tex (that's a repeat of the first line)
- gv sample.pdf & (to view your document)
If you run the "latex" command and something goes wrong, instead of getting the
regular prompt back, you'll get an (outstandingly cryptic) error message and
maybe a prompt that looks like ":". Type q to get out of that, examine the
error message to find the line number it's unhappy with, and go check out that
line in your code. GOOD LUCK.
What does a tex file look like? A sample .tex file.
Also available as sample.tex. The result is sample.pdf. Before running this code download the image file:mme.jpg
\documentclass[11pt]{article} %Picks the type of document: article,book,report,letter, proc, slides %11pt sets the font size
%%%%Packages: Reference:http://www.math.uiuc.edu/~hildebr/tex/packages.html%%%%%
\usepackage{amsmath}
%Needed for typing equations and theorems
\usepackage{amssymb}
%Loads additional fonts and symbols
\usepackage{graphicx}
%Needed for adding graphics to the document
%%%%Margin Definitions. Reference:http://www.iam.ubc.ca/~newbury/tex/page-set-up.html %%%%%
\oddsidemargin -7mm % Decreases the left margin by 7mm
\textwidth 17cm %Sets text width across page = 17cm
\textheight 20cm %Sets text height up and down = 20cm
%%%%%%%%%%%%%%%%%%%%%%%% Macro Definitions %%%%%%%%%%%%%%%%%%%%%%%
% Macro Definitions; abbreviations for symbols that you will use
\def\dx {{\Delta x}}
% In LaTeX you define symbols with \. For more information view Symbol References.
\def\pppx {{\frac{\partial \psi}{\partial x}}}
\def\grad {{\nabla}}
\def\vvec {{\bf{v}}}
\begin{document} % Begins Document, needed for all LaTeX files
%%% Setup information for Maketitle%%%%%
\title{My Sample \LaTeX{} Document}
\author{Aewsome Math Texer}
\maketitle %Uses information you gave: author, title, etc. And computer's date to create a title
\vspace*{2mm}
\tableofcontents %Creates a list of all your sections
\listoffigures % Creates a list of your figures
\listoftables %Creates a list of your tables
\newpage %Makes a newpage
\section{Section Title}
This is a section in my paper. This figure, \ref{fig:coolpic}, is a cool picture in my paper.
%%%%Add a Figure. Fore more information go to figure references %%%%%
\begin{figure}[hbt]
\centering
\resizebox{1.5in}{!}{\includegraphics{mme.jpg}} %Resize the graphic to fit.
\caption{\label{fig:coolpic}The coolest picture in my paper} %Add a caption. THe label allows you to refer to it in your paper.
\end{figure}
\subsubsection{A Section of my previous section}
Now I'm going to add a table. This table is going to be Table \ref{Table:k_7}.
\begin{table}[ht] %[ht] describe the table placement. Reference:http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/teTeX/latex/latex2e-html/ltx-67.html
\label{Table:k_7} % again, allows you to refer tot he table in your text with latex providing the reference number
\begin{center} % Centers the table in the page
\begin{tabular}{|c|c|c|} % |c| shows alignment of table elements
\hline % Puts in a horizontal line
column 1 & $\dx$ & $L^1$ \\ %Table Headers , columns seperated by &, rows ended by \\
\hline
\hline
128&0.00781250&0.00000445 \\
256&0.00390625&0.00000112 \\
2048&0.00048828&0.00000002 \\
\hline
\end{tabular}
\end{center}
\caption{The discrete $L^1$, $L^2$ and $L^{\infty}$ norms of the error for kth mode = 7}
\end{table}
\subsubsection{The next sub section in my paper}
Now I'm going to add some really cool equations. There are two ways to add equations:
\begin{itemize} %Itemize is a way of creating bullets, each bullet is one item. When you've listed all your bullets you end your itemize function.
\item One way to do equations is adding them in the line using \$. To do this you just add a \$ on each side of your equation:
$L(z) = lim_{\overline{AB} \rightarrow 0} \left( \frac{1}{\overline{AB}}\left[ V(A)-V(B) \right] \right) = \frac{\Delta v}{\dx} $.
\item The other way to do equations is to use the eqnarray function in \LaTeX{}:
\begin{eqnarray}
\label{eqn:REGdefn}
REG= \grad \cdot \vvec
\end{eqnarray}
This is nice becuase it allows you to refer to your equation, Equation \ref{eqn:REGdefn}.
\end{itemize}
\section{Conclusion}
\begin{enumerate} %%enumerate is similar to itemize, except it uses numbers
\item So hopefully you see how useful it can be to use \LaTeX{}
\begin{itemize}
\item It provides a really nice format
\item Everyone can read it on their computers because .pdf readers are free
\item It allows you to meet the requirements of applications when submitting.
\end{itemize}
\item It's also nice that you can bracket your itemize/enumerate items and create sublists
\item You can also create subsubsections
\item If you don't want your sections numbered you can write section*\{Title\}. The * will get rid of the numbers. But if you * it you won't see it in the table of contents.
\end{enumerate}
\end{document}
Additional References
Tex References and Groups:
Other sample .tex files:
Other Tutorials:
Math Symbol References:
LaTeX Figure References:
Other LaTeX Tips: