<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<article id="LaTeX">
  <articleinfo>
    <title>LaTeX</title>
    <author>
      <firstname>Ashley</firstname>
      <othername>J.S</othername>
      <surname>Mills</surname>
      <affiliation>
        <address><email>ashley@ashleymills.com</email></address>
      </affiliation>
    </author>

    <copyright>
      <year>2005</year>
      <holder role="mailto:ashley@ashleymills.com">The University Of Birmingham</holder>
    </copyright>
    <revhistory>
       <revision>
          <revnumber>0.1</revnumber>
          <date>20 November 2005</date>
          <authorinitials>AJS</authorinitials>
          <revremark>
             This tutorial was written in 2001, at that time I had little LaTeX experience. Please bear this in mind, and please do not consider this revision as an indicator of the quality of the entire tutorial set. Since 2001 I have written many documents in LaTeX and so if time permits I will update this tutorial.
          </revremark>
        </revision>
    </revhistory>
  </articleinfo> 

  <sect1 id="LaTeX-Introduction"><title>Introduction</title>
    <para>
      LaTeX (pronounced Lay-Tex) is a macro package originally created by Leslie Lamport for the document generation language TeX (pronounced like the <emphasis>tech</emphasis> in <emphasis>tech</emphasis>nology). TeX was created by Donald E. Knuth around 1970 in order to provide him with the necessary tools to produce his legendary <citetitle>The Art Of Computer Programming</citetitle> series of books (which are still being written) and various other books. A more comprehensive description of TeX can be found at <ulink url="http://www.tug.org/whatis.html">http://www.tug.org/whatis.html</ulink> and the TeX FAQ can be found at <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes">http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes</ulink>.  TeX is famous for it's excellent mathematical and scientific typesetting capabilities. TeX is also Turing complete.
    </para>

    <para>
      TeX is a program which manipulates the TeX language used to describe the structure of a document. A TeX document be processed in order to generate printable output, this is achieved using TeX the program. Other tools such as <command>dvips</command> are then used to convert the <acronym>DVI</acronym>(Device Independent) output produced by the TeX tools to a device dependent Postscript format.
    </para>

    <para>
      LaTeX is a layer on top of TeX t abstract functionality and more. Author-friendly development is coupled with an emphasis in generating high quality output. LaTeX2e (pronounced Lay-Tech-Two-E), is the latest development of LaTeX available at the time of writing. You can find a lot more about LaTeX and LaTeX2e at <ulink url="http://www.latex-project.org/">http://www.latex-project.org/</ulink>. This tutorial will focus on LaTeX2e, the reason for the weird capitalization in TeX, LaTeX and LaTeX2e is because the ASCII characters are representing Greek letters. Images of how these words should actually look are shown below: 
    </para>

    <figure><title>TeX, LaTeX, LaTeX2e</title>
      <mediaobject>
        <imageobject><imagedata fileref="files/images/latexlook.png" format="PNG"/></imageobject>
      </mediaobject>
    </figure>

    <para>
      Leslie Lamports Book <citetitle>LaTeX: A Document Preparation System, Second Edition</citetitle> is still regarded as a very worthwhile reference, any serious LaTeX user should consider obtaining it.
    </para>
  </sect1>

  <sect1 id="LaTeX-Installation"><title>LaTeX Installation</title>
    <para>
      It is assumed that you know how to setup environment variables and install software on your operating system, for a comprehensive guide to doing so for Windows see <ulink url="winenvars/winenvarshome.html"><citetitle>Configuring A Windows Working Environment</citetitle></ulink>, for Unix see <ulink url="unixenvars/unixenvarshome.html"><citetitle>Configuring A Unix Working Environment</citetitle></ulink> Follow these instructions to install JDOM:
    </para>

    <sect2 id="LaTeX-Installation-TeX"><title>Install A TeX Distribution</title>
      <para>
        Installing a TeX distribution should suffice here as it is more likely than not that any TeX distribution you care to install will install the LaTeX2e macro extensions by default.
      </para>

      <para>
        If you need extra packages for your TeX distribution, it is extremely likely that these can be obtained from <acronym>CTAN</acronym> (Comprehensive TeX Archive Network). The UK mirror of this file tree is hosted by Cambridge University and can be found here <ulink url="http://www.tex.ac.uk/">http://www.tex.ac.uk/</ulink>.
      </para>
        
      <para>
        A basic knowledge of operating system concepts, such as changing environment variables, is assumed. Detail pertaining to this topic can be found in the documents: <ulink url="../winenvars/winenvarshome.html">Configuring A Windows Working Environment</ulink> and <ulink url="../unixenvars/unixenvarshome.html">Configuring A Unix Working Environment</ulink>.
      </para>

       <para>
         For the Windows user, TeXLive (<ulink url="ftp://ftp.dante.de/pub/fptex/current/TeXSetup.exe">ftp://ftp.dante.de/pub/fptex/current/TeXSetup.exe</ulink>) is an excellent all-in-one TeX package that this tutorial will be using. Download it and follow the installation instructions, change the installation directory to something suitable; <filename>C:\tools\TeXLive\</filename>.  Install the <citetitle>Generic recommend TeXLive scheme</citetitle> but check the box that says <quote>I want to customize the selected scheme</quote>. The next screen presents the user with a list of all possible packages on offer. Make sure you select the LaTeX package if it is not already selected.
       </para>

       <note>
         <para>
           During the TeXLive setup, when on the <citetitle>Root of installation page</citetitle> I advise you only to change the <quote>Root directory</quote> field (the others will update automatically, leave the <citetitle>Extra TeXMF tree</citetitle> and <citetitle>Home TeXMF Tree</citetitle> fields alone.  In other words, do not check the box that says <quote>You can change the default configuration for the main directories.</quote>.
         </para>
       </note>

      <para>
        If you are using Unix there are a number of schools of thought on which is the best TeX distribution to install on your system, a good one is <ulink url="http://www.tug.org/texlive.html">TeXLive</ulink>. The Unix distribution of TeXLive is available to download off ftp at <ulink url="http://www.tex.ac.uk/">http://www.tex.ac.uk/</ulink> or is available on CDROM. The CDROM is available free and can be downloaded as an ISO-Image to be burned or you can order it from a UK based supplier.  If you don't want to install TeXLive you may want to consider <ulink url="http://www.tug.org/teTeX/">teTeX</ulink> which is available from ftp.  Your Unix distribution may have came pre-installed with TeX/LaTeX, perform this test to check. This test can also be used to check if you have installed a distribution correctly. Create the document <filename>test.tex</filename>:
      </para>

      <programlisting>
\documentclass[a4paper,12pt]{article}
\begin{document}  
blah blah blah
\end{document}      
      </programlisting>

      <para>Process this with the command:</para>

      <screen><userinput><command>latex</command> <filename>test.tex</filename></userinput></screen>

      <para>If all goes well, the following will be output:</para>

      <screen>
This is TeX, Version 3.14159 (Web2c 7.3.7x)
(./test.tex
LaTeX2e &lt;2001/06/01&gt;
--SNIP--
(c:/Program Files/TeXLive/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(c:/Program Files/TeXLive/texmf/tex/latex/base/size12.clo)) (./test.aux)
[1] (./test.aux) )
Output written on test.dvi (1 page, 232 bytes).
Transcript written on test.log.
      </screen>
    </sect2>

    <sect2 id="LaTeX-Installation-Ghost"><title>Install GhostView and GhostScript</title>
      <para>In order to view and print PostScript files it is necessary to install GhostScript and GhostView.</para>

      <para>
        If you are using Windows, download GhostScript from <ulink url="http://www.cs.wisc.edu/~ghost/doc/AFPL/get704.htm">http://www.cs.wisc.edu/~ghost/doc/AFPL/get704.htm</ulink> and GhostView from <ulink url="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/ghostgum/gsv43w32.exe">ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/ghostgum/gsv43w32.exe</ulink>. Run the executables to install the software.
      </para>

      <para>
        GhostScript doesn't add the <filename>lib</filename> or <emphasis>bin</emphasis> directories to your path when you install it on Windows (because it expects you to be using the GUI). Which means that you cannot access the <emphasis>31</emphasis> auxiliary tools from the command line. To be able to use them, add the <filename>lib</filename> and <filename>bin</filename> directories to your <envar>PATH</envar> environment variable (prefix <filename>lib</filename> and <filename>bin</filename> with the base directory where GhostScript was installed).
      </para>

      <para> 
        If you are using Unix, Download GhostScript from: <ulink url="http://sourceforge.net/projects/ghostscript/">http://sourceforge.net/projects/ghostscript/</ulink> and GhostView from: <ulink url="http://www.cs.wisc.edu/~ghost/doc/AFPL/get704.htm">http://www.cs.wisc.edu/~ghost/doc/AFPL/get704.htm</ulink> you may also find this resource page useful: <ulink url="http://www.cs.wisc.edu/~ghost/">http://www.cs.wisc.edu/~ghost/</ulink>
      </para>

      <para>
        Notice that you can download either the sources or the <filename>rpm</filename>s, choose whichever method you feel most comfortable with.  Install the software. 
      </para>
    </sect2>
  </sect1>

  <sect1 id="LaTeX-ToolUse"><title>Latex ToolUse</title>
    <sect2 id="laTeX-ToolUse-TeX"><title>Conversion To DVI</title>
      <para>To convert a <filename>tex</filename> file to DVI:</para>

      <screen><userinput><command>latex</command> <filename>blah.tex</filename></userinput></screen>

      <para>Which outputs:</para>

      <screen>
blah blah blah...
Output written on blah.dvi (1 page, 676 bytes).
Transcript written on template.log.
      </screen>

      <para>
        You may have to execute the command several times to ensure that <filename>yourfile.aux</filename> is correctly updated with page numbers and file references etc, the recommendation is &quot;at least twice&quot;.  This will generate <filename>blah.dvi</filename>, which as explained, is a device independent format, you will need to convert it to something else in order to print it (well actually, you can print it from DVI if your tools/printer support it).  If errors are encountered, you will be presented with a prompt in the form of a question mark, type another question mark and hit enter and the following options will be displayed:
      </para>

      <screen>
Type &lt;return&gt; to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
      </screen>

      <para>
        Generally you should try <emphasis role="strong">S</emphasis> or <emphasis role="strong">R</emphasis> to suppress errors and let TeX handle them as it sees best, or you could learn TeX inside out and deal with the errors yourself, you will probably have to deal with errors some day.  Thankfully the error-output specifies the line the error occurred on and you have the option to edit the file there or insert something. For more information about dealing with errors see the section entitled <citetitle>The joy of TeX errors</citetitle> in the TeX FAQ: <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html">http://www.tex.ac.uk/cgi-bin/texfaq2html</ulink>.
      </para>

      <para>
        You can view the DVI file with WinDVI in Windows, assuming a TeXLive installation, this can be done by double clicking on the file or typing:
      </para>
      
      <screen><userinput><command>windvi</command> <filename>in.dvi</filename></userinput></screen>

      <para>If you do not have WinDVI, obtain it.  If you are using Unix then you can use XDVI:</para>

      <screen><userinput><command>xdvi</command> <filename>in.dvi</filename></userinput></screen>

      <para>
        If you do not have XDVI, obtain it from <ulink url="http://math.berkeley.edu/~vojta/xdvi.html">http://math.berkeley.edu/~vojta/xdvi.html</ulink>.
      </para>
    </sect2>

    <sect2 id="LaTeX-ToolUse-Dvips"><title>Converting DVI to PostScript</title>
      <para>To convert DVI output into PostScript:</para>

      <screen><userinput><command>dvips</command> <filename>blah.dvi</filename> <option>-o</option></userinput></screen>

      <para>
        Which will produce <filename>blah.ps</filename>.  You can now use <filename>ps2pdf</filename> to convert the <filename>ps</filename> file to <acronym>PDF</acronym> or one of the other tools that came with GhostScript to get some other output format. Alternatively you can open the <filename>ps</filename> file in GhostView and use the <guimenu>File</guimenu>...<guimenuitem>Convert</guimenuitem> menu item to <emphasis>export</emphasis> the file to various formats.
      </para>
    </sect2>
  </sect1>

  <sect1 id="LaTeX-Template"><title>LaTeX2e <emphasis>article</emphasis> Template</title>
    <para>Here is an extremely simple LaTeX2e <emphasis>article</emphasis> template to get you started:</para>

    <programlisting>
%This is a comment
\documentclass[a4paper,12pt]{article} <co id="LaTeX-Template-DocClass"/>
\usepackage{fullpage} <co id="LaTeX-Template-Package"/>

\begin{document}  <co id="LaTeX-Template-Begin"/>

\title{A latex Template}
\author{Jimmy Riddles}
\date{\today}   <co id="LaTeX-Template-Title"/>
\maketitle

\begin{abstract} 
  This is an abstract  <co id="LaTeX-Template-Abstract"/>
\end{abstract}

\tableofcontents  <co id="LaTeX-Template-TOC"/>

\section[Optional TOC Title]{Otherwise this is used}
This is a section

\subsection[Optional TOC Title]{Otherwise this is used}
This is a sub-section <co id="LaTeX-Template-Sections"/>

\subsubsection[Optional TOC Title]{Otherwise this is used}
This is a sub-sub-section

\end{document} <co id="LaTeX-Template-End"/>
    </programlisting>

    <calloutlist>
      <callout arearefs="LaTeX-Template-DocClass">
        <para/>
        <programlisting>
\documentclass[a4paper,12pt]{article}
        </programlisting>
        <para>Three types of document class are available as standard in LaTeX2e:</para>
          
        <orderedlist>
          <listitem>
            <para>
              <emphasis>article</emphasis>, articles, essays and other short pieces of text.
            </para>
          </listitem>
          <listitem>
            <para>
              <emphasis>report</emphasis>, reports, theses and other medium length pieces of text.
            </para>
          </listitem>
          <listitem>
            <para>
              <emphasis>book</emphasis>, for actual books.
            </para>
          </listitem>
        </orderedlist>

        <para>
          The document class defines the structure of the document and the set of elements that are allowed in it and how certain elements should be displayed. A document class element takes the generic form:
        </para>

        <programlisting>
\documentclass[options]{documentclass}          
        </programlisting>

        <para>
          In this template the options <emphasis>a4paper</emphasis> and <emphasis>12pt</emphasis> are used to specify a4 sized paper and a font size of 12pt, 10pt is the default font size. A particular document class can have options which are unique to it.
        </para>
      </callout>

      <callout arearefs="LaTeX-Template-Package">
        <para/>
        <programlisting>
\usepackage{fullpage}
        </programlisting>
        <para>
          Packages provide extra functionality to the production of LaTeX documents.  In this template example the package <emphasis>fullpage</emphasis> has been imported which changes the default margins to 1inch each side. The generic form of <emphasis>usepackage</emphasis> is:
        </para>

        <programlisting>
\usepackage[options]{packages}
        </programlisting>

        <para>
          More than one package may be specified, either separated by commas in a single <emphasis>usepackage</emphasis> statement or by using multiple <emphasis>usepackage</emphasis> statements. The options provided are relative to the packages imported. Options declared in the <emphasis>documentclass</emphasis>(described above), will effect any packages that are imported that can use the options declared.
        </para>
      </callout>

      <callout arearefs="LaTeX-Template-Begin">
        <para/>
        <programlisting>
\begin{document}
        </programlisting>
        <para>
          The actual document is opened with a <emphasis>\begin{document}</emphasis> element, this is an example of an <emphasis>environment</emphasis>.
        </para>
      </callout>

      <callout arearefs="LaTeX-Template-Title">
        <para/>
        <programlisting>
\title{A latex Template}
\author{Jimmy Riddles}
\date{\today}
\maketitle
        </programlisting>
        <para>
          To create a title one must define at least the <emphasis>title</emphasis> and <emphasis>author</emphasis> elements, <emphasis>date</emphasis> is optional and is sometimes included by default anyway, even if not specified here, defaulting to the current date. <emphasis>\maketitle</emphasis> is then called to produce the title at this point in the document.
        </para>
      </callout>

      <callout arearefs="LaTeX-Template-Abstract">
        <para/>
        <programlisting>
This is an abstract
        </programlisting>
        <para>An optional abstract section may be defined.</para>
      </callout>

      <callout arearefs="LaTeX-Template-TOC">
        <para/>
        <programlisting>
\tableofcontents
        </programlisting>
        <para>
          <emphasis>\tableofcontents</emphasis> will generate a table of contents at the point it is used based on the titles given for the <emphasis>section</emphasis>s defined in the document body.
        </para>
      </callout>

      <callout arearefs="LaTeX-Template-Sections">
        <para/>
        <programlisting>
\subsection[Optional TOC Title]{Otherwise this is used}
This is a sub-section
        </programlisting>
        <para>
          Sections and sub-sections add structure to a document and assist in the generation of tables of content(TOC). One may specify the title to be used for the section in the TOC in the options section (<emphasis role="strong">[</emphasis> ... <emphasis role="strong">]</emphasis>).  If this section is not included, the section title will be used, which is the title that will appear at this point in the document for this section.
        </para>
      </callout>

      <callout arearefs="LaTeX-Template-End">
        <para/>
        <programlisting>
\end{document}
        </programlisting>
        <para>
          Just as the document was opened with a <emphasis>\begin{document}</emphasis>, it is terminated with a <emphasis>\end{document}</emphasis>.
        </para>
      </callout>
    </calloutlist>

    <para>When the above document is processed with LaTeX, the resulting DVI file looks like this:</para>

    <figure><title>LaTeX Template DVI</title>
      <mediaobject>
        <imageobject><imagedata fileref="files/images/latextemplate.png" format="PNG"/></imageobject>
      </mediaobject>
    </figure>
  </sect1>

  <sect1 id="LaTeX-Examples"><title>LaTeX Examples</title>
    <para>
      It is recommended that you read <citetitle>A not very short introduction to LaTeX2e</citetitle>, available from <ulink url="http://people.ee.ethz.ch/~oetiker/lshort/">http://people.ee.ethz.ch/~oetiker/lshort/</ulink>, you will probably want the PDF file at the bottom. This provides many examples of how to get things done with LaTeX2e, it is an excellent document written by Tobi Oetiker, Hubert Partl, Irene Hyna and Elisabeth Schlegl. I am not going to replicate that document here. It covers almost everything you could possibly want to do with LaTeX. You can even download the source code to see how the document was produced.
    </para>
     
    <sect2 id="LaTeX-Examples-Environments"><title>Environments</title>
      <para>
        LaTeX2e uses what are known as <emphasis>environments</emphasis> to markup content in a document.  An environment is opened with:
      </para>

      <programlisting>\begin{environmentName}</programlisting>

      <para>And is closed with:</para>

      <programlisting>\end{environmentName}</programlisting>

      <para>
        The text between the opening and closing of the environment will be subject to the constraints of this particular environment. Some environments may be nested.  There are many environments available in LaTeX2e, with special applications such as creating tables, inserting images, displaying literal text and creating bibliographies.
      </para>
    </sect2>

    <sect2 id="LaTeX-Examples-Images"><title>Inserting Images</title>
      <para>
        One of the most common ways to use images within LaTeX is to use eps(encapsulated PostScript) images. In order to convert your files to this format you will have to install some kind of image manipulation program, The <acronym>GIMP</acronym>(<acronym>GNU</acronym> Image Manipulation Program) is a free image manipulation program with the capability to do this conversion (it would probably be overkill to install this program <emphasis>just</emphasis> to do this but the program is very good so you should install it anyway). It is available for both Unix and Windows, the Unix version can be obtained from the <acronym>GIMP</acronym> homepage: <ulink url="http://www.gimp.org/">http://www.gimp.org/</ulink>.  The windows version can be obtained from here: <ulink url="http://www2.arnes.si/~sopjsimo/gimp/">http://www2.arnes.si/~sopjsimo/gimp/</ulink>.
      </para>

      <para>The basic template for inserting an image is shown below:</para>

      <programlisting>
\documentclass[a4paper,12pt]{article}
\usepackage{fullpage, graphicx}
\begin{document}
\begin{center}
\includegraphics{yourimage.eps}
\end{center}
\end{document}
      </programlisting>

      <para>
        There are many other options that can go with this, but the key points are the <emphasis>epsfig</emphasis> package import and the <emphasis>\epsfbox</emphasis> directive, which is centered.
      </para>

      <para>
        A better way to include images within LaTeX is to use the <emphasis>eepic</emphasis> package. <emphasis>epic</emphasis> is an extension to LaTeX's own picture format <emphasis>pic</emphasis> (extended pic) and provides a simpler and more powerful interface, it inherits many of the limitations of LaTeX, to overcome these limitations one generally uses <emphasis>eepic</emphasis> (extended <emphasis>epic</emphasis>). The extensions provide the ability to draw lines in any slopes, draw discs and circles with any diameter that TeX supports and various other enhancements. The main bonus of using <emphasis>eepic</emphasis> is it's ability to include LaTeX mathematical symbols and special commands so that figures may contain mathematical formula which are consistent with the rest of the document.
      </para>

      <para>
        The <emphasis>eepic</emphasis> image not a bitmapped image but a LaTeX document containing the relevant markup required to produce the desired effect, for example:
      </para>

      <programlisting>
\setlength{\unitlength}{0.00083333in}
%
\begingroup\makeatletter\ifx\SetFigFont\undefined%
\gdef\SetFigFont#1#2#3#4#5{%
  \reset@font\fontsize{#1}{#2pt}%
  \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
  \selectfont}%
\fi\endgroup%
{\renewcommand{\dashlinestretch}{30}
\begin{picture}(4137,2325)(0,-10)
              .
              .
              .
      </programlisting>

      <para>
        It is not necessary for one to understand this kind of markup in order to use <emphasis>eepic</emphasis>. Instead, one uses a program such as xfig to create the image, xfig is loaded up like this:
      </para>

      <screen><userinput><command>xfig</command> <option>-specialtext</option></userinput></screen>

      <para>
        The <option>-specialtext</option> option is required so that inserted text is treated as special and the LaTeX escaped commands can be used. A screenshot of xfig showing a created image can be seen below:
      </para>

      <mediaobject>
        <imageobject>
          <imagedata fileref="files/images/latexeepicraw.png" format="PNG" align="center"/>
        </imageobject>
        <textobject><phrase>A screenshot of xfig showing an image that has been created</phrase></textobject>
      </mediaobject>

      <para>The image is exported, using xfig, as <emphasis>LaTeX picture + eepic macros</emphasis>:</para>

      <mediaobject>
        <imageobject>
          <imagedata fileref="files/images/eepicexportxfig.png" format="PNG" align="center"/>
        </imageobject>
        <textobject><phrase>Using xfig to export an image to LaTeX picture + eepic macros format</phrase></textobject>
      </mediaobject>
        
      <para>The LaTeX picture + eepic macros file generated is included in the LaTeX document like this:</para>

      <programlisting>
\documentclass[a4paper,12pt]{article}
\usepackage{fullpage, epic, eepic}
\begin{document}
\begin{center}
\input{cool.eepic}
\end{center}
\end{document}
      </programlisting>

      <para>
        Notice the inclusion of the packages <emphasis>epic</emphasis> and <emphasis>eepic</emphasis>. The <emphasis>eepic</emphasis> file generated is imported into the document verbatim by using the <emphasis>\input</emphasis> command. When output as PDF the LaTeX generated from the xfig screenshot shown above looks like this:
      </para>

      <mediaobject>
        <imageobject>
          <imagedata fileref="files/images/latexeepicformat.png" format="PNG" align="center"/>
        </imageobject>
        <textobject><phrase>PDF output from the LaTeX and eepic generated using xfig, as shown in the screenshot above.</phrase></textobject>
      </mediaobject>

      <sect3 id="LaTeX-Examples-Images-xfig"><title>Getting XFig</title>
        <para>
          Xfig is only available for Unix or unix emulators such as Cygwin for Windows. Instructions on obtaining and installing xfig can be found at <ulink url="http://www-epb.lbl.gov/xfig/installation.html">http://www-epb.lbl.gov/xfig/installation.html</ulink>. Information about using fig with Microsoft windows can be found at <ulink url="http://duke.usask.ca/~macphed/soft/fig/winfig.html">http://duke.usask.ca/~macphed/soft/fig/winfig.html</ulink>.
        </para>

        <para>
          Windows users will probably have to install jfig, available for download at <ulink url="http://tech-www.informatik.uni-hamburg.de/applets/javafig/download.html">http://tech-www.informatik.uni-hamburg.de/applets/javafig/download.html</ulink>, fig2dev must also be available so that jfig can export as eepic, this can be obtained from the same place as jfig, mentioned above. A screenshot of jfig showing an eepic export in progress is shown below:
        </para>

        <mediaobject>
          <imageobject>
            <imagedata fileref="files/images/jfigscreenshot.png" format="PNG" align="center"/>
          </imageobject>
          <textobject><phrase>A screenshot of jfig showing an eepic export in progress</phrase></textobject>
        </mediaobject>

        <para>
          If one wants to include LaTeX escaped commands within jfig text insert, for instance to include a mathematical formula one should set the text type to special via the drop-down menu box at the bottom of the jfig screen:
        </para>

        <mediaobject>
          <imageobject>
            <imagedata fileref="files/images/jfigtextspecial.png" format="PNG" align="center"/>
          </imageobject>
          <textobject><phrase>To make sure that LaTeX escaped commands are expanded set the text type to <emphasis>special</emphasis></phrase></textobject>
        </mediaobject>
      </sect3>
    </sect2>

    <sect2 id="LaTeX-Examples-Tables"><title>Tables</title>
      <para>Tables are a common document inclusion, here is a simple example:</para>

      <programlisting>
\documentclass[12pt]{article}
\usepackage{a4}
\begin{document}
  \begin{center}
    \begin{tabular}{|l|l|c|c|c|}
  \hline
NAME       &amp; MAKE     &amp; HP &amp; YEAR &amp; PRICE \\
  \hline \hline
GSX250     &amp; Honda    &amp; 26 &amp; 1981 &amp; 300  \\
  \hline
GS250T     &amp; Honda    &amp; 26 &amp; 1982 &amp; 250  \\
  \hline
NSR250R    &amp; Honda    &amp; 60 &amp; 1993 &amp; 1340 \\ 
  \hline
NSR250R-SP &amp; Honda    &amp; 65 &amp; 1994 &amp; 2000 \\
  \hline
KR1S       &amp; Kawasaki &amp; 60 &amp; 1989 &amp; 1250 \\
  \hline
RGV250     &amp; Suzuki   &amp; 60 &amp; 1993 &amp; 1400 \\
  \hline
RGV250-SP  &amp; Suzuki   &amp; 65 &amp; 1994 &amp; 2400 \\
  \hline
    \end{tabular}
  \end{center}
\end{document}
      </programlisting>

      <para>
        The table is opened with <emphasis role="strong">\begin{tabular}</emphasis> after that the parameters are specified, the parameters indicate how each column should be displayed. A pipe symbol ('|') is used to designate a vertical line so one is placed at the start so that the table will have a left edge, the next character is an 'l', this specifies that we would like this column to be left justified, the choices are (l - left, r - right, c - centre).  So you can see how the column justification has been specified for each column and the columns have been separated by vertical lines and the there is a vertical line after the last column to close off the right edge of the table. Each line is terminated with a double backslash.
      </para>

      <para>
        Next comes the table data itself, well actually, first we draw a horizontal line with the <emphasis role="strong">\hline</emphasis> directive to indicate that the table should have a top to it. Then comes the table headings, the '&amp;' character is used as a column separator and each row is terminated with a double backslash (\\). Finally, we end the table with a horizontal line so it has a bottom to it and then close of the <emphasis>tabular</emphasis> directive and our <emphasis>center</emphasis> directive. The finished table will look like this when output:
      </para>

      <figure><title>LaTeX Table Output</title>
        <mediaobject>
          <imageobject><imagedata fileref="files/images/latextable.png" format="PNG"/></imageobject>
        </mediaobject>
      </figure>
    </sect2>
  </sect1>

  <sect1 id="LaTeX-Advanced-Template"><title>Advanced Template</title>
    <para>A more advanced template created by Alan P Sexton is shown below:</para>

    <programlisting>
\documentclass{article}
% for information about the packages, look in Lamport's book and in &quot;The
% Latex Companion&quot; by Goosens et al. For definitive info, the package
% files themselves are self documenting so you can download and read
% them from http://www.tex.ac.uk/ (here at Bham CS, we mostly only have
% the style files installed that have had the documention stripped from them

\usepackage{calc}
\usepackage{theorem}
\input{prooftree}             % Paul Taylor's natural deduction
                              % prooftree package
\usepackage{amsmath}          % These three lines are only for heavy maths
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{stmaryrd}         % extra symbols
\usepackage{verbatim}
% \usepackage{longtable}        % for tables that go over multiple pages
% Use xfig for figures and export them as eepic macros
\usepackage{epic}
\usepackage{eepic}
%\usepackage[ps,all]{xy}

% The following is to set up margins and paper size
\usepackage{vmargin}
\setpapersize{A4}
%% the args to setmarginsrb are as follows (note that the distance from
%% the top of the page to the first line of (non-header) text is
%% topmargin+headheight+headsep:
%% \setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%
%%              {headheight}{headsep}{footheight}{footskip}
\setmarginsrb{35mm}{10mm}{25mm}{25mm}%
             {12pt}{11mm}{0pt}{11mm}

% The following is to set up headers and footers conveniently
\usepackage{fancyheadings}
\pagestyle{fancy}
%\setlength{\headrulewidth}{0.4pt}
%\setlength{\footrulewidth}{0.4pt}
\chead{}
\lhead{}
\rhead{}
\lfoot{}
\rfoot{\tiny\thepage}
\cfoot{}

% The following allows putting comments in the margin: &quot;\marginpar{comment}&quot;
%\reversemarginpar
%\setlength{\marginparwidth}{24mm}


%\input{abbr}  %This should be a list of user specific abbreviations and macros

\begin{document}

\title{XXXXX}
\author{XXXXX\\[.5ex]
School of Computer Science\\
University of Birmingham\\[.5ex]
XXXXX@cs.bham.ac.uk}

\date{}
\maketitle

\input{XXXXX}    % use a separate file for each section of your document
\input{XXXXX}
\bibliographystyle{plain}
\bibliography{bib}

\end{document}
    </programlisting>
  </sect1>

  <sect1 id="LaTeX-References"><title>References and links you may find useful</title>
    <para>
      Well, that concludes the brief introduction to LaTeX. By searching the references and links in this page you should be able to find anything you need to know about LaTeX.
    </para>

    <itemizedlist>
      <listitem>
        <para>
          The Book <citetitle>LaTeX: A Document Preparation System, Second Edition</citetitle> by Leslie Lamport.
       </para>
      </listitem>

      <listitem>
        <para>
          <ulink url="http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/LaTeX_intro.html">http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/LaTeX_intro.html</ulink>
        </para>
        <para>
          <literallayout>
Text Processing using LaTeX
          </literallayout>
        </para>
      </listitem>
      <listitem>
        <para>
          <ulink url="http://www.sci.usq.edu.au/staff/robertsa/LaTeX/">http://www.sci.usq.edu.au/staff/robertsa/LaTeX/</ulink>
        </para>
        <para>
          <literallayout>
LaTeX: from quick and dirty to style and finesse
by Prof Tony Roberts
Dept of Mathematics and Computing
University of Southern Queensland
3 August, 1998 
          </literallayout>
        </para>
      </listitem>
      <listitem>
        <para>
          <ulink url="http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/">http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/</ulink>
        </para>
        <para>
          <literallayout>
Getting Started with LaTeX 
By David R. Wilkins
2nd Edition
Copyright David R. Wilkins 1995 
          </literallayout>
        </para>
      </listitem>
      <listitem>
        <para>
          <ulink url="http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/LaTeX-Home.html">http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/LaTeX-Home.html</ulink>
        </para>
        <para>
          <literallayout>
Beginning LaTeX tutorial
          </literallayout>
        </para>
      </listitem>
      <listitem>
        <para>
          <ulink url="http://web.mit.edu/olh/Latex/">http://web.mit.edu/olh/Latex/</ulink>
        </para>
        <para>LaTeX on Athena</para>
      </listitem>
      <listitem>
        <para>
          <ulink url="http://www.colorado.edu/ITS/docs/latex/FAQ/"/>
        </para>
        <para>
          <literallayout>
Frequently Asked Questions
about using LaTeX at C.U.
          </literallayout>
        </para>
      </listitem>
    </itemizedlist>

    <para>
      These are just a few of the tutorials available on the Internet, there are a lot more, just try your favourite search engine.
    </para>
  </sect1>
</article>

