\documentclass[pdf]{beamer}
%\documentclass[handout]{beamer}
%\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyvrb}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{graphicx}
%\usepackage{pgfpages}
%\pgfpagesuselayout{resize}[a4paper]
%\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Warsaw}
\usecolortheme{rose}
\useoutertheme{infolines}
\setbeamertemplate{navigation symbols}{\insertslidenavigationsymbol}
%\setbeamertemplate{footline}{A short introduction}

\newcommand{\TNC}{\TeX nicCenter}
\newcommand{\keyword}[1]{\texttt{\slshape\color{blue}#1}}
\newcommand{\smltt}[1]{\small {\bfseries {\ttfamily {#1}}} \normalsize}
\newcommand{\smlsf}[1]{\small {\textsf{\color{magenta}{#1}}}\normalsize}

\newcommand{\bi}{\begin{itemize}}
\newcommand{\ei}{\end{itemize}}

\title[Further \LaTeX]{\LaTeX\ Level 4}
\subtitle{Further document preparation}

\author{Susan Hutchinson}
\date{May 2010}
\institute[Oxford]{Department of Statistics, University of Oxford.}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Course outline and structure}
\tableofcontents
\end{frame}

\section{Revision}
\begin{frame}
\frametitle{Our \LaTeX\ environment}
\begin{itemize}
\item We will use Mik\TeX{} and \TNC{} in Windows.
\item If you prefer to use the Command Prompt and Wordpad or Notepad then do so.
\end{itemize}  
\end{frame}
\begin{frame}
\frametitle{How does \LaTeX\ work?}
In order to use \LaTeX\ two components are needed. 

\begin{enumerate}
\item<1-> {\textcolor{blue}{A \LaTeX\ engine or distribution}}
\newline
In Windows the most commonly used distribution is MiK\TeX{}. It provides all the infrastructure 
for creating documents such as fonts, style files, compilation and previewing commands and
 much else. Another popular distribution is 
\TeX Live which is widely used in Linux; Mac users generally use Mac\TeX.

\item<2-> {\textcolor{blue}{An editor or IDE (Integrated Development Environment)}}
\newline
This is used to edit, compile and preview \LaTeX\ documents. There are many editors and IDEs 
available. Emacs is a popular editor which is available for
 both Windows and Linux; Lyx is available for both too and Texmaker runs on Windows, Linux and Macs.  Several other platform-dependent editors are available such as Kile in Linux, TeXNicCenter, WinEDT and Winshell in Windows and Aquamacs for Macs. In Linux a simple text editor such as gedit can be a
good option. 
\end{enumerate}
\end{frame}

\begin{frame}[fragile]
\frametitle{Developing \LaTeX\ documents}
When using \TNC{} remember that 
\begin{itemize}
\item \LaTeX\ works on an edit $\to$ compile $\to$ view cycle.
\item You must save your file after making changes
\item You must recompile [ \smlsf{Build and view current file} ] after any change.
\begin{itemize}
\item Use the build profile [ \smlsf{LaTeX $=>$ PDF} ] to compile.
\item After a successful compilation Adobe Reader will display the contents of the file.
\end{itemize}
\item Image files --- plots, graphs, pictures --- can cause confusion.
\begin{itemize}

\item Documents with images in PostScript format (\verb+.eps+ or \Verb+.ps+) are compiled using [ \smlsf{LaTeX $=>$ DVI} ].
\item Documents with images in PDF, PNG, or JPG format are compiled with [ \smlsf{LaTeX $=>$ PDF} ]. This is what we'll be using today.
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{A simple \LaTeX\ file}
\begin{Verbatim}[formatcom=\color{red}]
\documentclass[a4paper,12pt]{report}
\begin{document}
\chapter{Introduction}
Hello there. This is the first paragraph.

Goodbye now. That's it.
\end{document}
\end{Verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{A simple \LaTeX\ file explained}
The text of the document is surrounded by commands. 
\begin{Verbatim}[formatcom=\color{red}]
\documentclass[a4paper,12pt{report}
\end{Verbatim}
\ldots This bit is called the preamble \dots
\begin{Verbatim}[formatcom=\color{red}]
\begin{document}
\end{Verbatim}
\ldots This bit is called the body \ldots
\begin{Verbatim}[formatcom=\color{red}]
\end{document}
\end{Verbatim}
\end{frame}

\section{Planning and managing longer documents}

\begin{frame}
\frametitle{Planning a longer document}
When writing a longer document such as a thesis there are many advantages to breaking your document into separate files.

\pause
\begin{itemize}
\item Imposes a structure on the document as a whole.
\pause
\item Allows you to focus on each part separately.
\pause
\item Conditional compilation can speed up the 
compile $\rightarrow$ edit $\rightarrow$ preview cycle.
\end{itemize}
\pause

It is also possible to create a standard preamble which can be used whenever you start a new \LaTeX\ document.
\end{frame}

\begin{frame}[fragile]
\frametitle{Structuring a longer document}
When dividing up a longer document into separate files you need to do the following.
\begin{itemize}
\item Create a root file which is the file you use when compiling.
This file contains markup which points to the files you want to include.
\item When including files the \verb+.tex+ suffix is not needed.
\end{itemize}
When using \TNC{} you will have many files open. Make sure you \emph{always} compile your root file. Compiling any others will fail with many errors.
\end{frame}

\begin{frame}[fragile]
\frametitle{How to break up a long document}
\begin{Verbatim}[formatcom=\color{red}]
\documentclass[a4paper,12pt]{report}
\begin{document}
\title{My long document}
\author{My Name}
\date
\maketitle
\include{intro}
\include{theory}
\include{research}
\include{results}
\include{conclusion}
\end{document}
\end{Verbatim}

In this case the document is organised into five separate files called \verb+intro.tex+, \verb+theory.tex+ and so on,
each of which will contain the text of a single chapter. 
\end{frame}

\begin{frame}[fragile]
\frametitle{Conditional compilation}
There are many reasons why you may want to compile only one or two 
chapters. It is particularly useful if one chapter contains a lot of images and is slow to compile.

\begin{itemize}
\item Make sure that one compilation is done with all the chapters.
\item Add the line
\begin{Verbatim}[formatcom=\color{red}]
\includeonly{intro,theory}
\end{Verbatim}
in the preamble and recompile.
\item Only the first two chapters will appear, but cross-referencing will 
be preserved, even to the chapters that have been left out.
\end{itemize}
Alternatively the \Verb[formatcom=\color{red}]+\excludeonly+ command can be used to exclude one or more files.
\end{frame}

\begin{frame}[fragile]
\frametitle{Revision: labels and cross-references}
\LaTeX\ makes it easy to create cross-references to other parts of your 
document. You can create references to equations, figures, chapters, 
sections, pages, tables and so on. To create a reference to a chapter 
and page use the following:
\begin{itemize}
\item Add the following markup 
\begin{Verbatim}[formatcom=\color{red}]
\label{ch:intro}
\end{Verbatim}
at the beginning of the chapter. Labels are case-sensitive so 
\textcolor{red}{INTRO} is different from \textcolor{red}{intro}.
\item Then when you want to make reference to the chapter add
\begin{Verbatim}[formatcom=\color{red}]
In Chapter \ref{ch:intro} on \pageref{ch:intro}
\end{Verbatim}
when to reference the chapter and the page number.
\end{itemize}

Remember that you may need to compile your \LaTeX\ file twice (at least)
to get references right.
\end{frame}


\subsection{Exercise: creating, compiling and viewing simple documents}
\subsection{Exercise: managing longer documents}


\begin{frame}
\frametitle{Exercises}
Now do the following exercises.
\begin{itemize}
\item Creating, compiling and viewing a simple document using  
\TNC
\item Managing longer documents
\end{itemize}
\end{frame}


\section{Customising \LaTeX : creating and changing commands}

\begin{frame}[fragile]
\frametitle{Customising \LaTeX}
It is possible to define new commands and redefine existing ones. You may
want to do this for several reasons.
\begin{itemize}
\item To save typing. If you keep typing the same markup it makes sense to 
define a command in the preamble and use the shortened version in the document.
\item To keep a consistent style.
\end{itemize}
It is possible to create new commands that are shortcuts to existing commands. 
\begin{Verbatim}[formatcom=\color{red}]
\newcommand{\bi}{\begin{itemize}}
\newcommand{\ei}{\end{itemize}}
\end{Verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Creating your own commands}
For example instead of writing 
\begin{Verbatim}[formatcom=\color{red}]
{\textrm {\slshape{Department of Statistics}}}
\end{Verbatim}
every time I want to write
{\textrm {\slshape{Department of Statistics}}} I
can define a new command in the preamble using
\begin{Verbatim}[formatcom=\color{red}]
\newcommand{\DOS}{\textrm {\slshape Department 
of Statistics}}
\end{Verbatim}
and use \Verb[formatcom=\color{red}]!\DOS! instead. 

\medskip

It is easy to change your mind later -- the change would only need to be made in once in the preamble.

\medskip

In slides the default font is sans--serif so in order to make my new command clearer I am using a Roman font. In documents it is the other way round so use \Verb[formatcom=\color{red}]+\textsf+ instead.

\end{frame}

\begin{frame}[fragile]
\frametitle{Defining a new command with an argument}
The syntax of the command to define a new command is
\begin{Verbatim}[formatcom=\color{red}]
\newcommand{cmd}[n-args][default]{text}
\end{Verbatim}
where
\begin{description}
\item[cmd] is the name you decide to use for the new command.
\item[n-args] [optional] is the number of arguments your new command will have.
\item[default] [optional] what to use as a default argument.
\item[text] what \LaTeX\ should do with when this command is used.
\end{description}
To define a command called {\slshape{keyword}} which typesets a word or phrase in bold using a typewriter font and coloured blue add to the preamble
\begin{Verbatim}[formatcom=\color{red}]
\newcommand{\keyword}[1]{\texttt{\slshape\color{blue}#1}}
\end{Verbatim}
So to typeset the word ``section'' as a keyword use
 \verb+\keyword{section}+ which would appear as \keyword{section}.
\end{frame}

\begin{frame}[fragile]
\frametitle{Customising an existing command}
Using \Verb[formatcom=\color{red}]+\renewcommand+ the behaviour of existing commands can be changed. For example to change the page with your table of contents to say ``Table of Contents'' rather than ``Contents'' you would use
\begin{Verbatim}[formatcom=\color{red}]
\renewcommand*{\contentsname}{Table of Contents}
\end{Verbatim}
There are many predefined names which can be changed.
\begin{Verbatim}[formatcom=\color{red}]
\contentsname
\listfigurename
\listtablename
\figurename
\chaptername
\end{Verbatim}
Note that some names will only apply to some documentclasses. For example there is no Chapter command when using the \keyword{article} class.

The use of an asterisk (star) in a \Verb[formatcom=\color{red}]+\renewcommand+ indicates that the command is \emph{short} and unlikely to include a paragraph break.
\end{frame}

\begin{frame}[fragile]
\frametitle{Advice on customising commands}
Customisation needs to be done with care. \LaTeX\ imposes good typesetting rules on your document so you need to make sure your changes are necessary.
\begin{itemize}
\item \LaTeX\ does not allow you to create new commands with the same name as existing commands.
\item Check that there isn't a package which will achieve the effect you are looking for, before trying to make extensive customisations to an existing command.
\item If you do end up creating many customisations your preamble may become rather long; it is relatively simple to bundle them all up into your own package which can then be invoked 
with \Verb[formatcom=\color{red}]+\usepackage{mypackage}+.
\end{itemize}
\end{frame}

\section[Creating slides]{Creating slides using the Beamer class}

\begin{frame}
\frametitle{Why use a \LaTeX\ slide-making environment?}
\ldots when there's Microsoft Powerpoint?

\begin{itemize}
\item It is straightforward to include mathematics.
\item It is possible to link to bibliographies.
\item Customisation is possible, so that the environment can be
tailored to suit your needs.
\end{itemize}

So the same considerations apply. If you have chosen to use \LaTeX\ to 
write your thesis then you will probably need to be able to create 
presentations in \LaTeX\ too.
\end{frame}


\begin{frame}
\frametitle{Creating slideshows}
 There are several slide-making document classes. Originally there were
 several classes that were suited to creating transparencies and foils.
\begin{description}
\item[SliTeX] A separate program, written by Leslie Lamport for creating
transparencies.
\item[slides] Early \LaTeX\ slide-making document class. It is not
widely used now as it lacks many more complex features. It was good for 
creating transparencies; less so for online presentations.
\item[seminar and foils] Originally developed to 
produce acetate foils, but can produce output suitable for an overhead 
projector. Not much used.
\end{description}
Powerpoint changed everything. The expectation was that a presentation,
as well as containing useful information would also be colourful, include
dynamic effects such as animations and pausing between bullet points.
\end{frame}

\begin{frame}
\frametitle{Current slide-making classes}
Several new slide-making environments were produced in response.

\begin{description}
\item[prosper] Based on seminar and includes the ability
to produce dynamic effects. Now superceded largely by powerdot.
\item[beamer] Relatively powerful and easy to learn; creating dynamic effects
is relatively straightforward.
\item[talk] Again, easy to learn. It doesn't impose a particular slide-style
on you.
\end{description}

We will be using Beamer today. Early distributions of \LaTeX\ did not always
include Beamer; but if you are using an up-to-date version then it should
be available. 

%A couple of additional packages such as \keyword{pgfpages} are also needed.

\medskip

Beamer will produce output in PDF format which makes it very portable. 
PDF format presentations will ``just work'' on most systems.
\end{frame}

\begin{frame}
\frametitle{What Beamer provides}
\begin{block}{Beamer extensions}
There are several additional environments and commands that are specific to Beamer. 
\begin{itemize}
\item New environments include \keyword{block}, \keyword{column} and \keyword{animate}.
\item There are also several mathematical environments such as \keyword{theorem}, \keyword{proof} and \keyword{definitions}.
\item Transitions, pauses and overlays are easily managed.
\pause 
\item That was a pause.
\end{itemize}
\pause


\setbeamercolor{bonkers}{fg=magenta,bg=darkgray}
\begin{beamercolorbox}{bonkers}
\keyword{beamercolorbox} allows you to change both the background and foreground colour of a part of a slide.
\end{beamercolorbox}

\end{block}

\end{frame}

\begin{frame}[fragile]
\frametitle{A simple beamer file}

\begin{Verbatim}[formatcom=\color{red}]
\documentclass[pdf]{beamer}
\usetheme{Warsaw}
\begin{document}
\title{My first slideshow}
\subtitle{I hope you like it}
\author{Susan Hutchinson}
\institute{University of Oxford}
\date\maketitle
\tableofcontents
\section{Introduction}
\frame{My first slide}
\end{document}
\end{Verbatim}
\transdissolve
\end{frame}

\begin{frame}
\frametitle{The components of a slide}
\begin{enumerate}
\item a headline and a footline
\item a left and right sidebar
\item navigation bars
\item navigation symbols
\item a logo
\item a frametitle
\item a background
\item some frame contents
\end{enumerate}

Not all slides have all these components. The first three are usually set up by the theme you choose. The contents are your problem!
\end{frame}

\begin{frame}[fragile]
\frametitle{Beamer themes and colours}
The appearance of your slides depends on the theme you have chosen. There
is a smaller range than with powerpoint but there is much scope for 
customisation. To change the theme and colour use
\begin{Verbatim}[formatcom=\color{red}]
\usetheme{PaloAlto}
\usecolortheme{albatross}
\end{Verbatim}

Some popular themes are
\begin{tabular}{llll}
AnnArbor & Berkeley & Berlin & Boadilla \\
CambridgeUS & Copenhagen & Darmstadt & Frankfurt \\
Hanover & Luebeck & Marburg & PaloAlto \\
Pittsburgh & Rochester & Singapore & Warsaw
\end{tabular}\\
\medskip

Some popular colours are
\begin{tabular}{llllll} 
albatross & beaver & beetle & crane & dolphin & dove\\
fly & orchid & rose & seagull & seahorse & wolverine 
\end{tabular}

\medskip

I am using the \smltt{Warsaw} theme and \smltt{rose}.
\end{frame}

\begin{frame}[fragile]
\frametitle{The layout of a slide}
Each slide has the format
%[formatcom=\color{red}]
\begin{Verbatim}[formatcom=\color{red}]
\begin{frame}
\frametitle{}
\\end{whatever}
\end{Verbatim}

The contents of the slide go here.

%\begin{Verbatim}[formatcom=\color{red}]
%\end{frame}
%\end{Verbatim}

The contents of the slide can include \LaTeX\ commands, pictures, tables
and so on. 
\begin{block}{Beamer restrictions}
\begin{itemize}
\item The depths of \keyword{itemize},\keyword{enumerate} and \keyword{description} environments are limited.
\item Pictures and figures need careful handling.
\item Using \keyword{bibtex} is rather fiddly.
\end{itemize}
\end{block}

\end{frame}

\begin{frame}[fragile]
\frametitle{The title page}
Add the following to the preamble
\begin{Verbatim}[formatcom=\color{red}]
\title[Short title]{My long title}
\subtitle[Short subtitle]{My long subtitle}
\author{My Name}
\date{November 2007}
\institute{My University}
\end{Verbatim}

and then include 
\begin{Verbatim}[formatcom=\color{red}]
\begin{frame}
\frametitle{Outline}
\maketitle
\verb!\end{frame}!
\end{Verbatim}


\medskip

after \Verb[formatcom=\color{red}]!\begin{document}!. A short version of the text has been included between \Verb[formatcom=\color{red}]![! and \Verb[formatcom=\color{red}]!]! which will appear at the foot of each slide.
\end{frame}

\begin{frame}[fragile]
Effects can be included such a pauses and overlays.
For example to pause between items like this:
\begin{itemize}
\item Mount Everest grows by 1cm a year
\pause
\item A new planet is discovered every day.
\end{itemize}
\pause
use
\begin{Verbatim}[formatcom=\color{red}]
\begin{itemize}
\item Mount Everest grows by 1cm a year
\pause
\item A new planet is discovered every day.
\end{itemize}
\pause
\end{Verbatim}
\end{frame}

\begin{frame}
\frametitle{Creating overlays}
Overlays allow you to determine in what order items appear. For example
\begin{theorem}
There is no largest prime number.
\end{theorem}
\begin{proof}
\begin{enumerate}
\item<1-> Suppose $p$ where the largest prime number.
\item<2-> Let $q$ be the product of the first $p$ numbers.
\item<3-> Then $q + 1$ is not divisible by any of them.
\item<1-> Thus $q + 1$ is also prime and greater than $p$. \qedhere
\end{enumerate}
\end{proof}
\uncover<4->{Proved using \textit{reduction ad absurdum}.}
\end{frame}

\begin{frame}[fragile]
\frametitle{The markup for overlays}
\begin{Verbatim}[formatcom=\color{red}]
\begin{theorem}
There is no largest prime number.
\end{theorem}
\begin{proof}
\begin{enumerate}
\item<1-> Suppose $p$ where the largest prime number.
\item<2-> Let $q$ be the product of the first $p$ numbers.
\item<3-> Then $q + 1$ is not divisible by any of them.
\item<1-> Thus $q + 1$ is also prime and greater than
 $p$. \qedhere
\end{enumerate}
\end{proof}
\uncover<4->{Proved using \textit{reduction ad absurdum}.}
\end{Verbatim}

Note the use of \verb!<1->!, \verb!<2->! to determine the order in which
information is revealed.
\end{frame}

\begin{frame}[fragile]
\frametitle{Adding some structure}
The \Verb[formatcom=\color{red}]+\section+ and \Verb[formatcom=\color{red}]+\subsection+ commands are used to add 
structure to the slides. These are used outside frames. They can contain a long and short version. The long version appears in the table of contents, the short version in the header line.
\begin{Verbatim}[formatcom=\color{red}]
\section[Slide creation]{Creating slides using Beamer}
\end{Verbatim}
Add a slide that contains
\begin{Verbatim}[formatcom=\color{red}]
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{Verbatim}
\verb!\end{frame}!

and a  slide which includes all the section and subsections headings will be generated.

Finally navigation symbols can be added which allow you to find your way around the presentation when it is being given.
\end{frame}



\subsection{Exercise: creating and customising commands}
\subsection{Exercise: make your own slide show}

\begin{frame}
\frametitle{Exercises}
Now do the following exercises.
\begin{itemize}
\item Creating and customising commands
\item Make your own slide show
\end{itemize}
\end{frame}


\section{Exploring packages}

\begin{frame}[fragile]
\frametitle{What are packages}
Packages are used to alter or add to basic \LaTeX\ behaviour. For example to change the way paragraphs are separated add \Verb[formatcom=\color{red}]+\usepackage{parskip}+ to the preamble.

\begin{Verbatim}[formatcom=\color{red}]
\documentclass{article}
\usepackage{parskip}
\begin{document}
\section{Introduction}
Hello there. This is the first paragraph.

Goodbye now. That's it.
\end{document}
\end{Verbatim}
\end{frame}

\begin{frame}
\frametitle{More about packages}
Finding and configuring packages to do what you want is a key skill for \LaTeX\ users. 
\begin{itemize}
\item Packages extend existing functions.
\item Packages add extra functions.
\item There are hundreds of packages, many of which will be installed with your \LaTeX\ distribution. 
\end{itemize}
\end{frame}


\begin{frame}
\frametitle{Some commonly-used packages}
\begin{description}
\item[amsmath,amssymb] Additional mathematical characters
\item[fancyhdr] Extends headers and footers on the page
\item[graphicx] More configuratable picture environment
\item[longtable] Allows tables to extend over more than one page
\item[lscape] Change the orientation of a page
\item[natbib] Add a bibliography
\item[tocloft] Changes Table of Contents format
\end{description}
\end{frame}
\begin{frame}
\frametitle{Some more commonly used packages}
\begin{description}
\item[babel] Allows you to choose the language of key words.
\item[color, xcolor] Change the colour of text and other features.
\item[fancyvrb] Enhances the verbatim environment. Useful if you need to make text appear exactly as it is typed.
\item[glossaries] Create a glossary of key words.
\item[hyperref] Make your references, tables of contents, lists of figures and tables links.
\end{description}
\end{frame}

\begin{frame}
\frametitle{Learning a new package}
Once you have found the package you want, you will need to understand how it works.
\begin{itemize}
\item Read the documentation. Most packages have a guide which can be read with the \keyword{texdoc} command if you are using a Unix/Linux system.
\item Use Google.
\item Create a small working example to help you become familiar with the features.
\end{itemize}
\end{frame}

\section{Going further: finding answers, asking good questions}

\begin{frame}[fragile]

\frametitle{Solving your own problems}
These slides and exercises are designed to get you started. At some point you will hit a problem (I do all the time) which you can't solve immediately. 
\begin{itemize}
\item Move \Verb[formatcom=\color{red}]+\end{document}+ further up the file. This may isolate the problem.
\item If the error reports a line number make sure you look for errors before that.
\item Use Google to search for the error. Or look at a guide.
\item Create a minimal example. This helps you narrow the problem down.
\item Either subscribe to \smltt{comp.text.tex} via a news reader like Thunderbird or use Google groups.
\end{itemize}
\end{frame}

\subsection{Exercises: exploring packages}
%\subsection{Exercise: tips and tricks to solve problems yourself}
\begin{frame}
\frametitle{Exercises}
Now do the following exercise.
\bi
\item Exploring packages.
%\item Tips and tricks to solve problems yourself.
\ei

If you have problems check that you have used the suggestions in the previous slide.
\end{frame}
\section{Conclusion}

\begin{frame}
\frametitle{Conclusion}
Good luck!

\bigskip

I hope you will all now write beautiful documents.
\end{frame}


\end{document}

