% day1.tex
%
% Mac Mason, Spring 2006
%
% Source for first day of the ACM LaTeX course

\documentclass[t]{beamer}

\mode<presentation>
\setbeamertemplate{navigation symbols}{}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{pdfpages}
\usepackage{moreverb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[all]{xy}


\title{\LaTeX{} Week 3\\ Graphics, references, bibliographies, etc.}
\author{Mac Mason \\ \texttt{mac@cs.hmc.edu}}
\date{\today}
\begin{document}

\newcommand{\bs}{\ensuremath{\backslash}}
\begin{frame}[fragile]
  \titlepage
\end{frame}

% \begin{frame}
%   \frametitle{TOC}
%   \tableofcontents
% \end{frame}

\begin{frame}[c]
  \frametitle{Today}
  \begin{block}{Figures \& Graphics}
    \begin{itemize}
    \item What's a figure?
    \item Putting in graphics
    \end{itemize}
  \end{block}
  \begin{block}{References \& Footnotes}
    \begin{itemize}
    \item Labels
    \item \texttt{\bs{}ref\{\}}
    \end{itemize}
  \end{block}
  \begin{block}{Bibliographies}
    \begin{itemize}
    \item \texttt{\bs{}cite\{\}}
    \item Why BiBTeX makes this trivial
    \end{itemize}
  \end{block}
\end{frame}

\begin{frame}
  \frametitle{``\ldots worth a thousand words''}
  \begin{displaymath}
    \UseTips
    \entrymodifiers={++[o][F]}
    \xymatrix @-1mm {
      *+\txt{start} \ar[r]
      & 1 \ar@(dr,dl)[]^b \ar[r]_a
      & 2 \ar@(d,dl)[]^a \ar[r]_b
      & 3 \ar@{-<} `u^l[l] `l^d[l]_a [l] \ar[r]_b
      & *++[o][F=]{4}
        \ar `dl_l[ll]+/d6mm/`l_ul[ll]^a [ll]
        \ar `u^l[lll]+/u1cm/`l^d[lll]_b [lll]
    }
  \end{displaymath}
  \begin{columns}[c]
    \column{0.4\textwidth}
    \includegraphics{vector}
    \column{0.4\textwidth}
    \includegraphics[width=0.9\textwidth]{akmap}
  \end{columns}
\end{frame}

\begin{frame}[t]
  \frametitle{Figures}
  \begin{center}
    \includegraphics[width=0.7\textwidth]{figure_example}
  \end{center}
\end{frame}
\begin{frame}
  \frametitle{Code}
  \begin{block}{Generally}
    \texttt{\bs{}begin\{figure\}[htb]}\\
    \texttt{\bs{}centering} \\
    \emph{Some \LaTeX{} code that does something figureful} \\
    \texttt{\bs{}caption\{A caption for your figure\}} \\
    \texttt{\bs{}label\{A label for your figure\}} \\
    \texttt{\bs{}end\{figure\}} \\
  \end{block}
  \pause
  \begin{block}{Example}
    \alert{\texttt{\bs{}usepackage\{graphicx\}}} \\
    \texttt{\bs{}begin\{figure\}[htb]} \\
    \texttt{\bs{}centering} \\
    \texttt{\bs{}includegraphics[width=0.5\bs{}textwidth]\{akmap\}} \\
    \texttt{\bs{}caption\{A picture of Alaska\}} \\
    \texttt{\bs{}label\{akmap\}} \\
    \texttt{\bs{}end\{figure\}}\\
  \end{block}
\end{frame}
\begin{frame}
  \frametitle{\texttt{[htb]?}}
  \begin{block}{Figures are ``smart''}
    \begin{itemize}
    \item They don't (necessarily) go exactly where you put them
    \item So you have to tell them how to behave
    \end{itemize}
  \end{block}
  \begin{block}{\texttt{htb}}
    \begin{itemize}
    \item[\texttt{h}:] ``Here''
    \item[\texttt{t}:] Top of Page
    \item[\texttt{b}:] Bottom of Page
    \item[\texttt{p}:] Figures Page
    \item[\texttt{!}:] Quit thinking and \emph{do what I say!}
    \end{itemize}
    Order matters: \texttt{[htb]} is different than \texttt{[bth]} \\
    Be careful with !: it's not a good idea. 
  \end{block}
\end{frame}
\begin{frame}
  \frametitle{Including Graphics}
  \begin{center}
    \texttt{\bs{}includegraphics[modifiers]\{filename\}}
    \begin{block}{Modifiers}
      \begin{itemize}
      \item \texttt{width}, \texttt{height}, and \texttt{scale} do
        exactly what you'd think.
      \item \texttt{keepaspectratio} makes sure you don't distort the image
      \item \texttt{draft} just puts in a rectangle, not the actual image 
      \item \texttt{rotate} is crazy.
      \end{itemize}
    \end{block}
    \begin{block}{Formats}
      When compiling to PDF use a \texttt{.jpg}, \texttt{.png}, or
      \texttt{.pdf} file. \\
      \texttt{.ps} and \texttt{.eps} \emph{won't work!}
    \end{block}
    \begin{center}
      \texttt{\bs{}includegraphics[width=50mm, keepaspectratio]\{foo\}}
    \end{center}
  \end{center}
\end{frame}

\begin{frame}
  \frametitle{References}
  \begin{block}{Let's say\ldots}
  \end{block}
  \pause
  \begin{block}{\texttt{\bs{}label\{\}} \& \texttt{\bs{}ref\{\}}}
    If you want to be able to reference something, \texttt{\bs{}label} it. \\
    When you want to talk about it, \texttt{\bs{}ref} it.\\
    \begin{itemize}
    \item \texttt{\bs{}section*\{\bs{}label\{problems\}Error Analysis\}}
    \item The figure label we saw earlier
    \end{itemize}
  \end{block}
\end{frame}
\begin{frame}
  \frametitle{References Example}
  \begin{center}
    \includegraphics[width=\textwidth]{references_example}    
  \end{center}
\end{frame}
\begin{frame}
  \frametitle{Bibliographies}
  \pause
  \begin{block}{file.bib}
    \texttt{@book\{iliad,} \\
    \quad \texttt{title=``The Iliad of Homer'',}\\
    \quad \texttt{editor=``Richmond Lattimore'',} \\
    \quad \texttt{publisher=``University of Chicago Press'',} \\
    \quad \texttt{year=``1951''}\\
    \texttt{\}} \\
    \vspace{\baselineskip}
  \end{block}
  \pause
  \begin{block}{file.tex}
    \alert{\texttt{\bs{}bibliographystyle\{something\}}} \\
    \texttt{\bs{}begin\{document\}} \\
    \ldots \\
    \texttt{\bs{}cite\{iliad\}} \\
    \ldots \\
    \texttt{\bs{}bibliography\{file\}} \\
    \texttt{\bs{}end\{document\}}
  \end{block}
\end{frame}
\begin{frame}
  \frametitle{I run \LaTeX{} how many times?}
  \begin{block}{Three!}
    \begin{itemize}
    \item \texttt{latex file.tex}
    \item \texttt{bibtex file}
    \item \texttt{latex file.tex}
    \item \texttt{latex file.tex}
    \end{itemize}
  \end{block}
  \begin{block}{Luckily\ldots}
    Graphical user interfaces usually do this for you.
  \end{block}
  \begin{block}{Luckier\ldots}
    You only have to re-do this when the bibliography changes.
  \end{block}
  \begin{block}{\texttt{\bs{}newpage}}
    Forces \LaTeX{} to start a new page. 
  \end{block}
\end{frame}
\end{document}
