% TEACH LATEX.TEX                                      A.Sloman Dec 1997
%                                               Last updated 12 Dec 1998
%                           (Added more information on printing options)
%                                         Slightly modified: 10 Feb 2008

% A SAMPLE LATEX FILE, USING LATEX2E

% WARNING before latex will work you have to edit your .login file.
% See TEACH LATEX

% NOTE Comments start with "%". Everything to the right of that
% is ignored by latex.

% HOW TO PROCEED (more detailed instructions in TEACH LATEX.TEX
% 1. Rename this file something like myproject.tex, e.g.
%       ENTER name myproject.tex

% 2. Run it through latex by doing:
%       ENTER latex

% You will get some output in a latex log file in a new Ved window.
%   (It also creates files myproject.aux myproject.log myproject.dvi
%   on the magnetic disk, but not in VED. Ignore them for now.)

% 3. Quit that log file. and repeat the "ENTER latex" command,
%    then quit the new log file.
%    (Doing it twice is needed to produce a table of contents)

% 4. View the result by doing
%   ENTER xdvi
% That should invoke the "xdvi" previewer showing how the file will look
% if printed on a laser printer.

% 5. Then try changing the text below and then redo the "ENTER latex"
% command

% After redoing it you can get the previewer to refresh itself by
% iconising and de-iconisign it, or partially cover and uncover it.

% More instructions can be found at the end.

% Now read on: you'll find the latex header lines, from the next
% line down to \begin{document}

% THIS IS HOW A LATEX2E DOCUMENT STARTS
\documentclass[12pt,a4paper]{article}

% Delete 12pt, to get 10pt, the default font size.
% You can also choose 11pt.

% If you don't like the default font, CMR, try this, to use the
% times font (strongly recommended):
% \usepackage{times}

\thispagestyle{empty}   % Number all pages except the first

% Reduce the default margin size, to make text wider
\setlength{\oddsidemargin}{-0.3cm}
\setlength{\evensidemargin}{-0.3cm}

% You can control text with and height
\setlength{\textwidth}{16.5cm}
\setlength{\textheight}{24.1cm}

% Other bits of layout control, explained in HELP LATEX
\setlength{\topmargin}{0.1cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{0cm}

% define commands \sp, \Sp and \SP to leave vertical spaces of
% different sizes
\def\sp{\vspace*{2mm}}
\def\Sp{\vspace*{3mm}}
\def\SP{\vspace*{4.5mm}}

% Include this if you wish to use the \includegraphic command.
% See HELP LATEX
% \usepackage{graphicx}

% THE MAIN TEXT STARTS AFTER THIS:
\begin{document}
\hyphenpenalty 5000     %discourage hyphens

\parskip 2mm            %space between paragraphs
\parindent 0mm          %paragraph indentation changed below

% Start a centred heading. Note spelling of "center"
\begin{center}

% change to a \Large font, using bold (\bf)
{\Large \bf
MY PROGRAMMING PROJECT

% Add some space, using command defined above.
\Sp

% Slightly smaller font, still bold font. Insert your
% course code and title

\large \bf
Course: CG20 -- Introduction to AI programming

% Go back to normal font size, but still boldface
\normalsize \bf

% Insert your name, and perhaps add a footnote?
A.B.Student \footnote{This work was inspired by TEACH RIVER, and was
done with the help of all my friends, but I
inserted the comments in the code.}
\\              % "\\" causes a line break
Login name: abs
School of Computer Science \\
The University of Birmingham

\today

}
% You could include other information in the header.

\end{center}


% If you want to include a table of contents, remove the "%" in
% the following line and then run it through latex TWICE
% \tableofcontents \newpage

% Have your abstract indented using the "quotation" context
\begin{quotation}

% A heading for the abstract
\begin{center}
{\large \bf Abstract}
\end{center}

\noindent
In this report, a very important contribution to knowledge is described,
along with the techniques for implementing it. This will surely
revolutionise thinking about life the universe and everything.
\end{quotation}

% Make new paragraphs indented by 7mm from now on
\parindent 7mm

% Extra 1mm between paras
\parskip 1mm

\section{Introduction}
This is my great work. The first paragraph after a heading or
sub-heading is not indented, as that would look rather silly, as
everyone will agree.

However subsequent paragraphs are indented, by the amount specified in
the parindent command above, which you can change, if you prefer.

\section{Another section}

It really is very important stuff, and the second section is here to
make sure that all readers understand that, in case they have forgotten.

The ends  of words and sentences in a Latex document are marked
  by   spaces. It  doesn't matter how many
spaces    you type; one is as good as 100.  The
end of   a line counts as a space.
One   or more   blank lines denote the  end
of  a paragraph.

Since any number of consecutive spaces are treated
like a single one, the formatting of the input
file makes no difference to the output, though it may make a different
to you when typing in your text or proof-reading it.


\section{How it works}

This is described in two main sections called
% add some bullet points
\begin{itemize}

\item The first part

\item The second part
%end bullet points
\end{itemize}

\subsection{The first part}

This is the most important procedure

% go into verbatim mode, so that pop11 code is not reformatted

\begin{verbatim}

    define my_great_program(problem) -> solution;
        apply_solution_technique(problem) -> solution;
    enddefine;

\end{verbatim}
% Back to formatted text

That program is remarkably general and efficient, and displays my
wonderful skill at programming.

\subsection{The second part}


This would be fascinating except that I am far too busy to type it in,
but you can see the subsection heading anyway. Further details can be
found in the appendix. It is \emph{very} important that the appendices
are provided, and read by everyone.
\SP

\fbox{\parbox{10cm}{
    \begin{center}
        The box is \\ very pretty. \\ Don't you think?
    \end{center}}}


\section{Conclusion}

You should believe me you know. This is very important work, which will
enhance life experiences for all mankind.

\section{REFERENCES}

\parindent 0mm  % turn off paragraph indentation

\begin{description}     %from here to \end{description} indent
                    %and use \item to start new entry

\item
Bernard J. Baars.
{\em A cognitive Theory of Consciousness}.
Cambridge University Press, Cambridge, UK, 1988.

\item
L.P. Beaudoin.
{\em Goal processing in autonomous agents}.
PhD thesis, School of Computer Science, The University of Birmingham,
1994.

\item
M.A. Boden.
{\em Artificial Intelligence and Natural Man}.
Harvester Press, Hassocks, Sussex, 1978.
Second edition 1986. MIT Press.

\item
R.A. Brooks.
Intelligence without representation.
{\em Artificial Intelligence}, 47:139--159, 1991.

\item
H.A. Simon.
Motivational and emotional controls of cognition, 1967.
Reprinted in {\em Models of Thought,} Yale University Press, 29--38,
  1979.


\end{description}

% Start a new page for appendices
\newpage

% The next command tells latex that appendices are starting, so that
% section numbers will not be used. Instead A, B, C are used.
\appendix

\centerline{\Large \bf APPENDICES}


\section{Appendix 1: How to use it}

The instructions are as follows ...
The program can be found in the file \~{}abs/myproject.p


% If desired \subsection* produces a section heading without a number
% But then it does not appear in table of contents
\subsection*{Compiling the program from inside the editor}

blah blah blah

\subsection*{Compiling the file from outside the editor}

blah blah blah

\subsection*{Running the program}

You can either run the program from Ved or from the Pop-11 prompt....

\newpage
\section{Appendix 2: The Program Code}

% try one of these three font sizes to make your code fit into
% the page width
% \small        %% smaller than normal
\footnotesize   %% smaller than small
% \scriptsize   %% smaller than scriptsize
% \tiny         %% nearly invisible. don't use

\begin{verbatim}
define solve_problem
    (initial, current_goal, isgoal, nextstates, samestate) -> result;
    lvars
        initial,        ;;; the initial state
        current_goal,   ;;; the second argument for isgoal
        procedure (isgoal, nextstates, samestate),  ;;; three procedures
        result;

    lvars
        alternatives = [^initial],  ;;; the list of alternative states
        history = [] ;              ;;; the list of previous states

    lvars current_state, rest;      ;;; pattern variables

    repeat
        if null(alternatives) then
            ;;; failed
            false -> result;
            return();
        else
            alternatives --> ! [?current_state ??rest];
            rest -> alternatives;

            ;;; Check if current_state is a goal state
            if isgoal(current_state, current_goal) then
                ;;; problem solved
                current_state -> result;
                return();
            else
                ;;; Keep a history list, avoid circles
                [ ^current_state ^^history ] -> history;

                ;;; generate successor states to current_state
                lvars states;
                nextstates(current_state) -> states;

                ;;; put all the "new" states onto the alternatives list
                lvars state;
                for state in states do
                    unless is_in_list(state, history, samestate) then
                        [ ^state ^^alternatives] -> alternatives
                    endunless;
                endfor;
                ;;; now go back to the beginning of the repeat loop
            endif
        endif
    endrepeat
enddefine;
\end{verbatim}

\section{Appendix 3: Sample program output}

The following blah blah blah

\normalsize % re-set standard font size for rest of document

% Next line tells latex this is the end. You must include it
\end{document}

Latex ignores all text after that line even if the text is uncommented.

NOTES:

Note 1. Error messages
If you make changes and make a mistake, e.g. misspelling a key word
like "subsection" or leaving out a closing bracket "}" or using
an underscore character "_" without preceding it with "\", you will
get an error message. Latex errors can be hard to understand, alas.
Sometimes trial and error can be used to debug the file.

VED will help you by locating the most useful portion of the latex
error message and taking you to the line in your latex file where
the error was encountered. (The source of the error will be there or
earlier.)

Note 2. Printing
 To print the file From VED on printer lw2  do:

        ENTER latex print -Plw2

If you have already defined your PRINTER to be lw2, in your .login
file, you do not need to specify the printer. So it will suffice to do

        ENTER latex print

If you want to print only pages 2 to 5 and 15-19 (e.g. for
proofreading), you can do

        ENTER latex print -pp 2-5 -pp 15-19

If you add "ps" at the end, the pages will go into a file, as explained
below.

Note 3. Saving output in a file
To save the output in a postscript file called myproject.ps do

   ENTER latex print ps

This will not print to the printer. If your latex file is called
myfile.tex, then the output will go into a postscript file called
myfile.ps

You can preview the postscript file using ghostview, but usually that
will not be necessary because you can use xdvi, as explained earlier.

Note 4. Unnumbered subsections

If you wish to have headers for some sections or subsections without
numbers, put an asterisk after '\section' or '\subsection', e.g.

    \section*{A note on terminology}

    \subsection*{Yet another variant}

These sections and subsections will not appear in the table of contents.

Note 5
For more information see
    HELP LATEX
        General information on latex. Also, at Birmingham you can
        use lynx or netscape to read
            /bham/doc/latex-help
    HELP VED_LATEX


--- $poplocal/local/ved_latex/teach/latex.tex
    linked to $poplocal/local/teach/latex.tex

Also
    http://www.cs.bham.ac.uk/research/projects/poplog/teach/latex.tex

--- $usepop/pop/packages/vedlatex/teach/latex.tex
--- Copyright University of Birmingham 2008. All rights reserved. ------
