Creating LaTeX documents
latex
(the Unix command)
On Unix computers, the command you type to compile and format
your LaTeX source file is latex;
ucsub> latex MyDoc.tex
If there are crossreferences or bibliographic references or
footnotes in your document, they will not all get matched up
on the first pass; it may take up to three times.
Additionally, if you are generating a bibliography from
a bibtex database, you must also run the bibtex command,
followed by the latex command again.
So, for example, to compile document used as an example
on these web pages, the typed Unix commands would be
ucsub> latex MyDoc.tex
ucsub> bibtex MyDoc
ucsub> latex MyDoc.tex
ucsub> latex MyDoc.tex
Not shown above is the outpouring of messages from each
latex/bibtex process to the terminal, as well as to the files
MyDoc.log and MyDoc.blg.
If there are errors in the source files, latex
will actually pause, give some
information about the error
and its line number, and ask you how to proceed.
The sample files used on these web pages to illustrate the process are
MyDoc.tex
 
(the main LaTeX file)
chapt2.tex
 
(chapter 2 stuff in a separate file)
chapt3.tex
 
(chapter 3 stuff in a separate file)
appendix.tex
 
(appendix A stuff in a separate file)
biblio.bib
 
(the bibliographic database)
Creating LaTeX documents
bibtex
-- generating a bibliography
You can save yourself the tiresome process of formatting
each bibliographic reference in the appropriate manner
by letting bibtex do the work.
You do have to have the basic information about each
reference in the form of a
bibliographic database file,
whose entries are standardized --
not bound to any particular style --
and often available online.
One need only specify the desired
bibliographic style,
and bibtex will then do all the work
of selecting, re-ordering, and formatting
each entry.
The command bibtex extracts only the
cited references from the *.bib file(s)
mentioned in the
\bibliography{} macro.
(Non-cited references can be included in the bibliography
by using the macro \nocite{...}.)
These references are formatted according to the
bibliographic style
indicated in the
\bibliographystyle{...} macro,
and placed in an auxiliary file named with the
suffix bbl, which LaTeX can later use.
(Compare file
MyDoc.bbl
with original database file
biblio.bib.)
The full sequence of Unix commands to compile the document
including bibliography is thus
- latex MyDoc.tex
    (``first pass'')
- bibtex MyDoc
  (extracts reference data)
- latex MyDoc.tex
    (matches citations/references)
- latex MyDoc.tex
    (finishes all cross-referencing)
Creating LaTeX documents
pdflatex
-- compiling straight to PDF
The command pdflatex compiles LaTeX source
and converts it immediately to PDF
without using intermediate DVI or PostScript files
or otherwise using a ghostscript interpreter.
It almost always gives better quality results and smaller PDF files.
Another benefit of using pdflatex is that you can
insert JPEG, PNG and PDF graphics into your document.
On the other hand, PostScript images and commands
cannot be inserted,
so if you want to insert an Encapsulated Postscript
figure it must first be converted to Encapsulated PDF.
This can be done using epstopdf.
PDF, PNG and JPEG image files can then be incorporated
into your document using the LaTeX macro
\includegraphics{}.
So, for example, the image included in
section 3 must
first be converted to PDF,
then the inclusion command is
\includegraphics{diagram.pdf}.
So for the sample document ``MyDoc.tex'',
the steps to compiling the document straight to PDF,
including the use of the bibliographic database file,
would be
- epstopdf diagram.eps    
(convert image to new file diagram.pdf)
- pdflatex MyDoc.tex      
(``first pass'')
- bibtex MyDoc          
    (extracts reference data)
- pdflatex MyDoc.tex      
(matches citations/references)
- pdflatex MyDoc.tex      
(finishes all cross-referencing,
final form of file
MyDoc.pdf)