\documentclass[11pt]{article}
\usepackage{dag,verbatim,hyperref}
\usepackage{tikz}
\usepackage[author-year]{amsrefs}
\setcounter{secnumdepth}{0}
\title{\TeX{} and \LaTeX{}\\For the Uninitiated\thanks{If you already
know much about \TeX{} you shouldn't be reading this.}}
\author{Daniel A. Graham }
\begin{document}
\maketitle
The name \TeX{}, pronounced ``tech'', actually stands for $\tau \epsilon \chi$, the beginning of the Greek word for \emph{art}. It is not a word processor but rather a text-formatter for documents. You can use \emph{any} editor (or word processor) you like to compose a text (ascii) file that is then processed by \TeX. The output from \TeX{} is either a \emph{device independent} \verb=.dvi= file or a \emph{page description format} \verb=.pdf= file which can be printed on virtually any printer or displayed on the screen or sent to other personal computers, workstations or mainframes.
Why might you be interested in \TeX?
\begin{itemize}
\item It produces typographically beautiful documents. For typesetting mathematics, in particular, it has no peer.
\item It is universally available. It is standard on UNIX systems and versions exist for MAC and MS-Windows.
\item It is supported by a large number of individuals world wide and by a number of Usenet groups.
\item It is free. Complete versions for any platform can be obtained from a number of FTP sites.
\item It is extremely easy to use for anyone who speaks ``mathematics''.
\item \TeX\ documents are small, ascii files which can be edited by any editor. This means that you can change editors without changing your files. You can quickly send your documents via email without having to ``uuencode'' or ``uudecode'' them at either end or worrying about whether your colleague has the right version of the right word processor for your file. You can also use standard utilities such as find, grep, or perl to make your collection of files an easily searched and indexed database.
\end{itemize}
\TeX{} was designed by Donald E.\ Knuth, of computer programming fame, in the late 1970's so that he might have a typesetting program worthy of his computer science textbooks. The effort took eight years but was worth it. One writer described the result as the most significant event in typesetting in this century and ranked it near the introduction of the Gutenberg press in terms of importance. It has, in fact, become the lingua franca of the scientific community. Scientific papers are routinely prepared and distributed using \TeX{} or \LaTeX{}.
Although \TeX{} itself is concerned with the low-level formatting task of
laying out text on the page, it is very extensible. Of the many extensions
intended to provide higher-level elements such as chapters, sections and
footnotes, the two most important have been Ams\TeX{} and \LaTeX.
Ams\TeX{} was developed for the American Mathematics Society and articles
submitted for publication in top mathematics journals must now be
submitted as Ams\TeX{} files. \LaTeX\ was originally intended to provide
somewhat less support than Ams\TeX{} for specialized mathematics but more
for other document features such as cross-references, tables of contents,
indexes and bibliographies. With the advent of the the new \LaTeX{},
called \LaTeXe{} during its development, you no longer need to choose ---
it has the best features of both and more to boot. The details of \LaTeX{}
(\LaTeXe{}) are set forth in the companion volumes Lamport~\ycite{ll:1985}
and Goosens et al.~\ycite{gms:1994} and in my personal favorite, Kopka and
Daly~\ycite{kd:1999}.
\section{Backslash Commands for Every Purpose}
This document was written using \LaTeX{} and Vim but any editor
or word processor that will save documents as straight ascii (text)
documents will do. You can lay out your text in any way that makes it
more readable to you --- your formating will largely be ignored by
\LaTeX. A group of spaces (one or more), for example, will be treated
as a single space, indentions will be ignored and a group of blank
lines will become a paragraph break. The editor itself needs very few
frills since \TeX{} does nearly everything for you taking its guidance
from \emph{backslash commands} that you embed in the text. A
footnote, for example, is obtained by merely typing%
\begin{verbatim}
\footnote{This paper was composed using Vim on a Mac running OS X.}
\end{verbatim}
at the point\footnote{This paper was composed using Vim on a Mac running
OS X.} where
you want the footnote inserted. Note that \LaTeX{} handles the
numbering and placement automatically. Similarly, The heading of
this paper was
produced by typing%
\begin{verbatim}
\title{\TeX{} and \LaTeX\\For the Uninitiated\thanks{If you
already know much about \TeX{} you shouldn't be reading this.}}
\author{Daniel A. Graham\thanks{Department of Economics, Duke
University, Durham, NC 27708-0097, (919) 660-1802,
dgraham@acpub.duke.edu.}}
\end{verbatim}
at the beginning of the document. Note that \LaTeX{} selects the
fonts, handles the placement and even provides today's date since I
neglected to provide one myself. If you will also notice that
\LaTeX{} centered the title and author lines without counting the
space taken by the asterisk and dagger then you will have begun to see
its subtle magic. \LaTeX{} handles this sort of detail for you so you
can devote yourself to writing.
Mathematical expressions are simplicity itself. To get $z = \lambda x
+ \Gamma y$, for example, simply type \verb|$z = \lambda x + \Gamma y$|.
Note that you only need to know how to spell Greek characters to get
them. Equations are just as easy;
\begin{verbatim}
\begin{equation}
\label{fundamental}
F(b)-F(a) = \int_a^b f(x) \, dx
\end{equation}
\end{verbatim}
produces the automatically numbered and centered
equation:\footnote{The $\backslash$, in this equation gives the nice
little space between $f(x)$ and $dx$.}
\begin{equation}
\label{fundamental}
F(b)-F(a) = \int_a^b f(x) \, dx
\end{equation}
In \TeX{} the underscore is used for subscripts the carrot is used for
superscripts. Note the analogous use here for the lower and upper
limits of integration.
Equations can then be referenced in the text by using their ``labels''
so that \verb=Equation~\ref{fundamental}= becomes
Equation~\ref{fundamental} when printed.\footnote{The \~{} is a
``non-breaking'' space character that assures that the words it
connects will not be split by a line break.} Similarly,
\verb=Equation~\ref{determinant}= gives Equation~\ref{determinant}
even though this equation will not appear until
\verb=page~\pageref{determinant}= page~\pageref{determinant}.
Footnote, equation, page and other numbers and references to them are
adjusted automatically, of course, when you make additions or
deletions.
Backslash commands are available to produce every imaginable
% \textsc{Character} \textsf{face}, \textsl{\textbf{style}} and \Huge S\LARGE
i\large z\scriptsize e \normalsize of font.
An unbelievable assortment of symbols is also available: $\ddagger$,
$\vee$ $\wedge$, $\equiv$, $\geq$, $\succeq$, $\succcurlyeq$,
$\pitchfork$, $\aleph$, and $\varnothing$ to name a few. The names are
easy to remember too: for $\exists$, $\forall$, or $\infty$ just type
\verb=\exists, \forall or \infty=. Access to ``math'' fonts like
$\Bbb{BLACKBOARD\;BOLD}$ and $\frak{Euler\;Fraktur}$ is also easy.
Tables of contents and indexes are trivial. Master bibliographies can
be created with reference ``keys'' such as\footnote{This format is used
with the \emph{amsrefs} package.}
\begin{verbatim}
\bib{ll:1985}{book}{
author = {Leslie Lamport},
title = {\LaTeX{} --- A Document Preparation System --- User's
Guide and Reference Manual},
publisher = {Addison-Wesley},
year = {1985}
}
\end{verbatim}
and the simple command
\verb=\cite{ll:1985}= in a paper is then sufficient not only to produce
the appropriate citation to the reference you've labeled ``ll:1985'' but
also to create a reference section in your paper which automatically
includes the full reference from the master bibliography.
\section{Lists}
Enumerated lists couldn't be simpler. The input
\begin{verbatim}
\begin{enumerate}
\item Sections, subsections, subsubsections, \ldots
\item And enumerated lists are also numbered automatically
\begin{enumerate}
\item And each of these can be labeled
\item And referenced in the text
\end{enumerate}
\item In exactly the same way that equations are referenced
\end{enumerate}
\end{verbatim}
produces
\begin{enumerate}
\item Sections, subsections, subsubsections, \ldots
\item And enumerated lists are also numbered automatically
\begin{enumerate}
\item And each of these can be labeled
\item And referenced in the text
\end{enumerate}
\item In exactly the same way that equations are referenced
\end{enumerate}
Similarly
\begin{verbatim}
\begin{itemize}
\item \emph{Itemized lists} are also possible. These use symbols such as
bullets as labels.
\item Still another possibility is a \emph{description list} which
uses names as labels:
\begin{description}
\item[Pareto Improvement.] A change in circumstance which benefits
at least one person without harming any other person.
\item[Pareto Optimum.] A situation in which a Pareto improvement is
not possible.
\end{description}
\item All forms of lists can be combined.
\end{itemize}
\end{verbatim}
yields
\begin{itemize}
\item \emph{Itemized lists} are also possible. These use symbols such as
bullets as labels.
\item Still another possibility is a \emph{description list} which
uses names as labels:
\begin{description}
\item[Pareto Improvement.] A change in circumstance which benefits
at least one person without harming any other person.
\item[Pareto Optimum.] A situation in which a Pareto improvement is
not possible.
\end{description}
\item All forms of lists can be combined.
\end{itemize}
\section{Macros}
\LaTeX{} can itself be easily extended. Consider, for instance, the
\emph{macro}:
\begin{verbatim}
\newcommand{\mymatrx}[5]{\left#1 \begin{array}{cccc}
#2_{11} & #2_{12} & \cdots & #2_{1 #5} \\
#2_{21} & #2_{22} & \cdots & #2_{2 #5} \\
\vdots & \vdots & \ddots & \vdots \\
#2_{#4 1} & #2_{#4 2} & \cdots & #2_{#4 #5}
\end{array} \right#3}
\end{verbatim}
\newcommand{\mymatrx}[5]{\left#1 \begin{array}{cccc}
#2_{11} & #2_{12} & \cdots & #2_{1 #5} \\
#2_{21} & #2_{22} & \cdots & #2_{2 #5} \\
\vdots & \vdots & \ddots & \vdots \\
#2_{#4 1} & #2_{#4 2} & \cdots & #2_{#4 #5}
\end{array} \right#3}
This defines a macro with five arguments numbered \#1 through \#5. The
first and third determine the delimiters (brackets, braces,
parenthesis, etc.) that will surround a \#4 by \#5 matrix with
elements corresponding to \#2. Now typing
\begin{verbatim}
\begin{equation}
\mymatrx [ a ] m n
\end{equation}
\end{verbatim}
for example, produces
\begin{equation}
\mymatrx [ a ] m n
\end{equation}
This new macro can itself be used within other commands so that
\begin{verbatim}
\begin{equation}
\label{determinant}
\left( \begin{array}{cc}
\mymatrx | b | q q & c_{12} \\
c_{21} & c_{22}
\end{array} \right)
\end{equation}
\end{verbatim}
produces
\begin{equation}
\label{determinant}
\left( \begin{array}{cc}
\mymatrx | b | q q & c_{12} \\
c_{21} & c_{22}
\end{array} \right)
\end{equation}
\section{Tables}
With this input
\begin{verbatim}
\begin{table}
\begin{center}
\begin{tabular}{lr|rcc}
\multicolumn{2}{l}{Crop} & \multicolumn{3}{c}{Plots} \\
\multicolumn{2}{l}{Damage} & 0 & 1 & 2 \\ \hline
{} & 0 & 0 & 0 & 0 \\
Trains & 1 & 0 & 60 & 120 \\
{} & 2 & 0 & 120 & 240 \\ \hline
\end{tabular}
\end{center}
\end{table}
\caption{The Coase Example \label{coase}}
\end{verbatim}
you get \verb=Table~\ref{coase} on page~\pageref{coase}= i.e.,
Table~\ref{coase} on page~\pageref{coase}. The ``table'' environment
allows the table to ``float'' to a good nearby spot.
\begin{table}
\begin{center}
\begin{tabular}{lr|rcc}
\multicolumn{2}{l}{Crop} & \multicolumn{3}{c}{Plots} \\
\multicolumn{2}{l}{Damage} & 0 & 1 & 2 \\ \hline
{} & 0 & 0 & 0 & 0 \\
Trains & 1 & 0 & 60 & 120 \\
{} & 2 & 0 & 120 & 240 \\ \hline
\end{tabular}
\end{center}
\caption{The Coase Example\label{coase}}
\end{table}
\section{Illustrations}
There are a number of possibilities for incorporating illustrations in
your documents. Postscript and graphics files in other formats can be
incorporated --- see Goosens et al.~\ycite{grm:1997}. It is also possible
to construct drawings in the document itself. The ``pgf/tikz'' package is
new, free and one of my favorites. Here is a sample of the possible output
followed by the code that produced it.
\begin{center}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-0.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-0.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot[id=x] function{x} node[right] {$f(x) =x$};
% \draw[color=red] plot[id=x] function{x**2} node[right] {$f(x) =x^2$};
\draw[color=blue] plot[id=sin] function{sin(x)} node[right] {$f(x) = \sin x$};
\draw[color=orange] plot[id=exp] function{0.05*exp(x)} node[right] {$f(x) = \frac{1}{20} e^x$};
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}[scale=3,cap=round]
% Local definitions
% Colors
\colorlet{anglecolor}{green!50!black}
\colorlet{sincolor}{red}
\colorlet{tancolor}{orange!80!black}
\colorlet{coscolor}{blue}
% Styles
\tikzstyle{axes}=[]
\tikzstyle{important line}=[very thick]
\tikzstyle{information text}=[rounded corners,fill=red!10,inner sep=1ex]
% The graphic
\draw[style=help lines,step=0.5cm] (-1.4,-1.4) grid (1.4,1.4);
\draw (0,0) circle (1cm);
\begin{scope}[style=axes]
\draw[->] (-1.5,0) -- (1.5,0) node[right] {$x$} coordinate(x axis);
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$y$} coordinate(y axis);
\foreach \x/\xtext in {-1, -.5/-\frac{1}{2}, 1}
\draw[xshift=\x cm] (0pt,1pt) -- (0pt,-1pt) node[below,fill=white] {$\xtext$};
\foreach \y/\ytext in {-1, -.5/-\frac{1}{2}, .5/\frac{1}{2}, 1}
\draw[yshift=\y cm] (1pt,0pt) -- (-1pt,0pt) node[left,fill=white] {$\ytext$};
\end{scope}
\filldraw[fill=green!20,draw=anglecolor] (0,0) -- (3mm,0pt) arc(0:30:3mm);
\draw (15:2mm) node[anglecolor] {$\alpha$};
\draw[style=important line,sincolor]
(30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis);
\draw[style=important line,coscolor]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0);
\draw[style=important line,tancolor] (1,0) -- node[right=1pt,fill=white] {
$\displaystyle \tan \alpha \color{black}=
\frac{{\color{sincolor}\sin \alpha}}{\color{coscolor}\cos \alpha}$}
(intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
\draw (0,0) -- (t);
\end{tikzpicture}
\end{center}
\footnotesize
\begin{verbatim}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-0.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-0.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot[id=x] function{x} node[right] {$f(x) =x$};
\draw[color=blue] plot[id=sin] function{sin(x)} node[right]%
{$f(x) = \sin x$};
\draw[color=orange] plot[id=exp] function{0.05*exp(x)} node[right]%
{$f(x) = \frac{1}{20} e^x$};
\end{tikzpicture}
\end{verbatim}
\begin{verbatim}
\begin{tikzpicture}[scale=3,cap=round]
% Local definitions
% Colors
\colorlet{anglecolor}{green!50!black}
\colorlet{sincolor}{red}
\colorlet{tancolor}{orange!80!black}
\colorlet{coscolor}{blue}
% Styles
\tikzstyle{axes}=[]
\tikzstyle{important line}=[very thick]
\tikzstyle{information text}=[rounded corners,fill=red!10,inner sep=1ex]
% The graphic
\draw[style=help lines,step=0.5cm] (-1.4,-1.4) grid (1.4,1.4);
\draw (0,0) circle (1cm);
\begin{scope}[style=axes]
\draw[->] (-1.5,0) -- (1.5,0) node[right] {$x$} coordinate(x axis);
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$y$} coordinate(y axis);
\foreach \x/\xtext in {-1, -.5/-\frac{1}{2}, 1}
\draw[xshift=\x cm] (0pt,1pt) -- (0pt,-1pt) node[below,fill=white] {$\xtext$};
\foreach \y/\ytext in {-1, -.5/-\frac{1}{2}, .5/\frac{1}{2}, 1}
\draw[yshift=\y cm] (1pt,0pt) -- (-1pt,0pt) node[left,fill=white] {$\ytext$};
\end{scope}
\filldraw[fill=green!20,draw=anglecolor] (0,0) -- (3mm,0pt) arc(0:30:3mm);
\draw (15:2mm) node[anglecolor] {$\alpha$};
\draw[style=important line,sincolor]
(30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis);
\draw[style=important line,coscolor]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0);
\draw[style=important line,tancolor] (1,0) -- node[right=1pt,fill=white] {
$\displaystyle \tan \alpha \color{black}=
\frac{{\color{sincolor}\sin \alpha}}{\color{coscolor}\cos \alpha}$}
(intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
\draw (0,0) -- (t);
\end{tikzpicture}
\end{verbatim}
\normalsize
% \bibliography{IntroTeXLaTeX}
\begin{bibdiv}
\begin{biblist}
\bibselect{IntroTeXLaTeX}
\end{biblist}
\end{bibdiv}
\end{document}