\documentclass{article} \begin{document} \centerline{{\Huge My First Latex Document}} % the centered title is optional and could be omitted % The section line below is optional and could % be omitted. Also the label command after it. \section{Tex versus Latex}\label{tex.vs.ltx} This is a very simple document, intended to show a few very basic commands. To see how Latex works, you should compare the source file with the output document. Latex is the most widely used ``flavor'' of Tex --- it has largely displaced Plain Tex, AMStex, and all the others. Consequently, the words ``Tex'' and ``Latex'' are used interchangeably, more or less. In our first lesson we might not get to many of the features that make Latex so advantageous over those other flavors of Tex. We'll start with some features that are common to all versions of Tex. Tex does not follow the line breaks of your source file. Also Latex ignores extra spaces in your source file. Compare this paragraph's source file and output document and you'll see what I mean. One or more blank lines begins a new paragraph. \section{Doing math}\label{good.math} Dollar signs are used to enter math mode and then to exit math mode. For instance, here is an $\alpha$ and an $\Omega$. Doubled dollar signs can be used to enter or exit display math mode. For instance, here is a displayed equation (which illustrates several of Tex's features: $$ 1^2 + 2^2 + 3^2 + \ldots + n^2 = \sum_{j=1}^n j^2 = \frac 16 n(n+1)(2n+1).$$ One of Tex's biggest advantages is its automatic use of spacing that suits the mathematician's taste very well --- far better than any WYSIWYG\footnote{``What you see is what you get,'' an editor such as Wordperfect or Microsoft Word.}. Look at the spacing in these displays: $$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$ $$ \left[ \begin{array}{cc} 0 & 1 \\ 1 & 2 \\ \end{array} \right] ^ n = \left[\begin{array}{cc} f_{n-1} & f_n \\ f_n & f_{n+1} \\ \end{array}\right] \;\; (n=1,2,3,\ldots)$$ \section{Lists, tables, and other formats}\label{lists} The ``itemize'' environment in Latex is like the ``unnumbered list'' (UL) of HTML: \begin{itemize} \item Its items are indicated by bullets \item at least in the default setting \item as shown here \item but actually \item[$\circ$] you can replace the bullets with whatever you want. \end{itemize} The ``enumerate'' environment in Latex is like the ``ordered list'' (OL) of HTML: \begin{enumerate} \item Here is the first thing. \item Here is the second thing. \item Latex does the numbering automatically. \item \label{numbered} And if I label an item in an enumerated list (as I'm doing now), then I can refer to the label elsewhere; see my discussion of labels in section \ref{xrefs}. \end{enumerate} In addition to ``itemize'' and ``enumerate'', advanced users can design their own customized list environments. (More about that in a later lesson, perhaps.) Another important environment is the \textit{table}. Once you learn all the tricks, tables in Latex are even more flexible and controllable than those in HTML. \begin{center}\begin{tabular}{r|ccc|c|} & a & b & x & total \\ \hline more symbols & $\sqrt{3}$ & $\sqrt[5]{3}$ & $f:A\to B$ & $\uparrow$ \\ \cline{1-2}\cline{4-5} sizes of letters & {\Large Xy} & {\Huge Xy} & {\tiny Xy} & ??? \\ \hline \end{tabular}\end{center} Tables and arrays can do essentially the same things, though \begin{itemize} \item tables are designed primarily for text (with math thrown in via extra commands), whereas \item arrays are designed for math (with text thrown in via extra commands). \end{itemize} Lately I have begun to prefer tables because a slight adjustment in ``tabular'' turns it into ``supertabular'', an environment that can go across page breaks when desired. I'm not aware of any analogous variant for arrays. \section{Cross-referencing}\label{xrefs} Latex has lots of nice features built in for cross-referencing. For instance, I have labeled the sections of this paper as ``tex.vs.ltx'', ``good.math'', etc. Those labels are not seen by the person who eventually reads the paper; they are only seen by me while I'm editing the paper. I can refer to a section of the paper by citing its label; for instance, right now the section labeled ``tex.vs.ltx'' is section \ref{tex.vs.ltx}; and in my example of an enumerated list, the item in which I mentioned cross-referencing was item number \ref{numbered}. You can attach labels of this sort to chapters, sections, subsections, equation numbers, and other subdivisions of the document. \textbf{Why would you want to?} Well, the point is this: If I rearrange my document, changing the order in which the sections (or equations, or whatever) appear, I don't have to \textit{renumber} everything. The numbering is done automatically by Latex. I keep the label with the content, and Latex automatically recalculates what number should go with that label. If you're writing a book, Latex can automatically keep track of the cross-references needed for your table of contents and your index. You don't have to rewrite those everytime you change a page in the book; Latex rewrites those automatically. I can't imagine how people wrote books before Latex was invented. Another fancy bit of cross-referencing: You can set up \textit{hyperlinks}, so that (for instance) someone who clicks a mouse on some reference to section 2 will automatically be taken \textit{to} section 2. That might be nice for reading, but I find it even nicer for \textit{writing} --- i.e., I can jump back and forth easily between different parts of my document while I'm writing and editing the document. \end{document}