\documentstyle[fancyheadings]{article}
\pagestyle{fancy}
\lhead{\egtrm\LaTeX{} training meeting (\today)}
\rhead{\egttt /mit/bert/consult/LATEX\_TUTORIAL.tex}
\font\egttt=cmtt8

\newcommand{\bs}{\leavevmode\hbox{$\backslash$}}
\setcounter{secnumdepth}{1}

\let\nverbatim=\verbatim
\let\endnverbatim=\endverbatim
\def\verbatim{\viiipt \baselineskip=.75\baselineskip \nverbatim}

\renewcommand{\thesection}{\Roman{section}}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{dealing with errors}

Every once in a while, \LaTeX{} is likely to choke on some error in a
document.  Knowing what the errors mean and what might be causing them
makes helping users with problems in their \LaTeX{} documents much easier.

Let us start with a fairly simple example of \LaTeX{} complaining:

\begin{verbatim}
This is TeX, Version 3.141 (C version d)
(LATEX_TUTORIAL.tex
LaTeX Version 2.09 <25 March 1992>
(prepared for MIT Athena) (/usr/athena/lib/tex/macros/latex/article.sty
Standard Document Style `article' <14 Jan 92>.
(/usr/athena/lib/tex/macros/latex/art10.sty))
LaTeX error.  See LaTeX manual for explanation.
              Type  H <return>  for immediate help.
! Missing \begin{document}.
\@latexerr ...for immediate help.}\errmessage {#1}
                                                  
<to be read again> 
                   h
l.9 h
     ere is some text that appears too early
?
\end{verbatim}

The line starting with \verb+!+ displays the type of error that occurred.
In this case, some text in the file appears before \verb+\begin{document}+.

The last two lines of error output indicate the line number ({\it
l.9\/}) where the error occured and the contents of that line.  The
line ``jumps'' down at the place where the error occurred.

If you are dealing with a document that is split across several files,
like most theses, you have to pay attention to which file the error
occurred in.  \TeX{} indicates it started reading a file by printing
an open parenthesis and the name of the file.  A matching closed
parenthesis indicates that the entire file has been input.

When an error occurs, you can type ``h'' to try obtaining more
information, ``x'' to exit \LaTeX{}, or just $<${\em return}$>$ to try
continuing past the error.  Unfortunately, explanations of \LaTeX{}
error messages are often not very useful; for instance, in the above
example typing ``h'' displays

\begin{verbatim}
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.
?
\end{verbatim}

You can also try looking the meanings of various errors in the
\LaTeX{} manual and the \TeX{}book.

Now, let's try tackling something a bit more complicated.

Since \TeX{} works by macro expansion, the error may occur because of
a problem in a macro called from another macro, etc.  In that case,
\TeX will display several levels of macro expansion when it runs into
an error.  For instance:

\begin{verbatim}
! Undefined control sequence.
\@maketitle ...5em \begin {tabular}[t]{c}\@author 
                                                  \end {tabular}\par }\vskip...

\maketitle ...ge \global \@topnum \z@ \@maketitle 
                                                  \fi \thispagestyle {plain}...
l.70 \maketitle
               
?
\end{verbatim}

So, the error occured while doing \verb+\maketitle+ on line 70.
\verb+maketitle+ is a macro which expands to a long sequence of other
commands and macros which is displayed just above l.70 (the
{\tt\ldots} indicate that parts were left out because the expansion
was too long).  The problem in \verb+\maketitle+ occured inside
another macro, \verb+\@maketitle+, which is expanded just above the
expansion of \verb+\maketitle+.  Finally, the cause of the problem is
that \verb+\@author+ is undefined.

Even if you don't know how \verb+\maketitle+ works, you might be able
to guess that the cause of the problem is that
\verb+\author{+\ldots\verb+}+ wasnt't spcified in the document.

There is a class of problems that are really hard to trace even if you
examine the error messages, because they usually cause a glorious mess
inside \TeX{}'s bowels.  If you put a ``fragile'' command (which
includes most things more complex than a font or size change) inside
of an argument to a command that might write to the table of contents
or the list of figures (such as \verb+\caption+ or \verb+\section+),
it will break.  You will need to precede the ``fragile'' command with
a \verb+\protect+.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{sectioning commands}

The rest of this handout will mostly be concerned with useful tips and
tricks\ldots

\subsection{controlling section numbering}

Some people complain about the fact that \verb+\subsubsection+s aren't
numbered in ``thesis'' and ``article'' styles.  Others want to prevent
\verb+\subsection+s from getting numbered.

\LaTeX{} has a counter variable named \verb+secnumdepth+ that selects
how many ``levels'' of sections get numbered.  You can use
\verb+\setcounter{secnumdepth}{+{\it number}\verb+}+ to change this
value.  Setting it to, say, 100 will make sure all levels of
subsections get numbered.  Setting it to 1 will make only
\verb+\section+s be numbered.  The value of -1 will disable all
numbering.

The format of the chapter, section, etc, numbers is determined by
macros \verb+\thechapter+, \verb+\thesection+, etc.  For instance, the
default formats for the ``article'' document style are

\begin{verbatim}
\thesection       {\arabic{section}}
\thesubsection    {\thesection.\arabic{subsection}}
\thesubsubsection {\thesubsection.\arabic{subsubsection}}
\theparagraph     {\thesubsubsection.\arabic{paragraph}}
\thesubparagraph  {\theparagraph.\arabic{subparagraph}}
\end{verbatim}

Instead of \verb+\arabic+, one can use \verb+\Roman+, \verb+\roman+,
\verb+\Alph+ or \verb+\alph+ to format the counters.

\subsection{inclusion into the table of contents}

\LaTeX{} has a counter variable named \verb+tocdepth+ that selects how
many ``levels'' of sections get included into the table of contents;
it works identically to \verb+secnumdepth+.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{labels and references}

In a figure/table, the \verb+\caption+ actually increment the
figure/table numbering counter and sets things up so that the figure
can be referenced using \verb+\label+ and \verb+\ref+.  Because of
this, the \verb+\label+ for a figure or table must come {\it after}
its \verb+\caption+.  There is a similar problem with some of the
equation environments.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{paths}

\section{float (figure, table) placement}

The way \LaTeX does placement of tables and figures is rather
confusing.  There are four possible position specifiers that you can
specify as options to the figure and table environments: \verb+h+ (for
``here''), \verb+t+ (for ``top''), \verb+b+ (for ``bottom'') and
\verb+p+ (for ``separate page'').  You can, and should, specify
several options simultaneouly, in the order of desirability; otherwise
\LaTeX{} may fail to place the float, and all subsequent floats, until
the end of the document.  (This often happens with \verb+h+.)  The
default options are \verb+tbp+.

There are also a lot of variables controlling the way floats can get
placed.  They are described in a lot of detail at the end of section
C.8.1 of the \LaTeX{} manual.  If you're having problems, using
\verb+\renewcommand+ to set \verb+floatpagefraction+ and
\verb+textfraction+ to 0 may be a good idea.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{{\tt\bs input} vs. {\tt\bs include}}

{\tt\bs include} starts a new page and generates a separate
\verb+.aux+ file for every {\tt\bs include}'d file.  You can also make
only some of the {\tt\bs include} commands actually read other files
by using \verb+\includeonly+.

{\tt\bs input} just reads in a file as if you cut and pasted it, plain
and simple.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{\LaTeX\ and PostScript}

\section{finding other's people's styles}

A very good list of all kinds of \TeX{} and \LaTeX{}-related software
is a file called \verb+TeX-index+, which is available by anonymosu FTP
from \verb+theory.lcs.mit.edu+ in the directory
\verb+/pub/tex/TeX-index+.  It's about 350K big, and it contains a lot
of useful macro packages that may let you help the user without
actually writing the solution yourself.

\end{document}
