% Heavily modified LaTeX code under non-commercial use as per license below.
% Elana Hashman, Slides July 2013
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This text is proprietary.                                                    %
% It's a part of presentation made by myself.                                  %
% It may not used commercial.                                                  %
% The noncommercial use such as private and study is free                      %
% Dec 2007                                                                     %
% Author: Sascha Frank                                                         %
% University Freiburg                                                          %
% www.informatik.uni-freiburg.de/~frank/                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{beamer}
%% Handouts for printing
%\usepackage{pgfpages}
%\pgfpagesuselayout{4 on 1}[a4paper, landscape, border shrink=5mm]
%\pgfpageslogicalpageoptions{1}{border code=\pgfusepath{stroke}}
%\pgfpageslogicalpageoptions{2}{border code=\pgfusepath{stroke}}
%\pgfpageslogicalpageoptions{3}{border code=\pgfusepath{stroke}}
%\pgfpageslogicalpageoptions{4}{border code=\pgfusepath{stroke}}
\setbeamertemplate{navigation symbols}{}
\usetheme{Bergen}
\beamersetuncovermixins{\opaqueness<1>{25}}{\opaqueness<2->{15}}
\DeclareFontShape{OT1}{cmtt}{bx}{n}{
<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
\usepackage[greek,english]{babel}
\usepackage{ragged2e}
\usepackage{alltt}
\usepackage{tikz}
\usepackage{coordsys}
\newcommand{\bs}{\symbol{92}}

\begin{document}
\title{A Mathematical Introduction to LaTeX\\[2mm]}
\subtitle{CUMC -- CC\'{E}M 2013, Montr\'{e}al, Qu\'{e}bec}  
\author{Elana Hashman\thanks{French Translations by David McLaughlin}}
\institute{\large University of Waterloo}
\date{July 13, 2013} 

%%% Title
\frame{\titlepage}

%%% ToC
\begin{frame}
\frametitle{Table of contents}
\tableofcontents
\end{frame} 


%%% History
\section{Introduction} 
\subsection{History}
\begin{frame}\frametitle{A Brief History of \LaTeX} 
\TeX\ is almost certainly older than you.\\[3mm]

\begin{itemize}
\item ``\TeX''\ developed by Don Knuth in 1978
\item Pronounced ``tech'', from Greek \greektext teqnh\latintext\ 
\item Markup language, like HTML
\item \LaTeX\ was derived from \TeX\ by Leslie Lamport in 1985\\[3mm]
\item Idea: Focus on content while \LaTeX\ takes care of the presentation for 
you
\end{itemize}
\end{frame}


%%% Software to use
\subsection{Setting up}
\begin{frame} 
\frametitle{Get the software}
\LaTeX\ is free, platform-independent software.\\[3mm]
\begin{itemize}
\item {\tt pdflatex} package for OS X/UNIX-based platforms
\item LyX for WYSIWYG: \url{http://www.lyx.org}
\item Online: \url{http://scribtex.com}
\end{itemize}
\end{frame}


%%% My first document
\subsection{My first document}
\begin{frame}\frametitle{My first document}
\framebox[3.55in]{\textrm{ Hello, world!}}
\end{frame}


%%% Code
\section{Into the Code}
\begin{frame}[fragile]
\frametitle{Code for my first document}
\LaTeX\ code:
{\small \begin{verbatim}
\documentclass{article}
\begin{document}
Hello, world!
\end{document}
\end{verbatim}}
\pause
\vspace{5mm}

Contrast with a similar HTML document:
{\small \begin{verbatim}
<html>
   <body>
      Hello, world!
   </body>
</html>
\end{verbatim}}
\end{frame}


%%% Layout
\subsection{Document layout}
\begin{frame}
\frametitle{Document Layout}
\begin{enumerate}
\item Document type\\
{\small {\tt $\circ$ article}\\
{\tt $\circ$ beamer} (slides)\\
{\tt $\circ$ report}}\\[4mm]\pause
\item Preamble (header)\\
{\small $\circ$ Include packages\\
$\circ$  Set spacing\\[0mm]
$\circ$  Declare macros, commands}\\\pause
\item Body (content)
\end{enumerate}
\end{frame}


%%% Template samples
\subsection{Templates}
\begin{frame}
\frametitle{Sample templates}
See \url{http://hashman.ca/tex} for\\
\begin{itemize}
\item {\tt article.tex}, 
\item {\tt report.tex}, and 
\item {\tt slides.tex} 
\end{itemize}
sample templates.\\[5mm]

This gives you some sample preamble information\\ and templates for your use.
\end{frame}


%%% Proof and code
\subsection{Proof by example}
\begin{frame}
\frametitle{\tt \textbackslash begin\{document\} }
{\bf Squeeze Theorem.}\\[1mm]
{\justifying Let $(x_n)$, $(y_n)$ and $(z_n)$ be sequences in $\mathbb{R}$.  
Suppose $(x_n)\to L$, $(z_n)\to L$, and for all $n \ge n_0$, we have $x_n \le 
y_n \le z_n$; then $(y_n)\to L$.\\[1mm]\pause
\begin{proof}
Let $\varepsilon > 0$. Since $(x_n)\to L$, there is some integer $n_1$ such 
that $\forall\ n \ge n_1$, we have $|x_n - L| < \varepsilon$.\\[2mm]

Similarly, for the same $\varepsilon$, since $(z_n)$ converges, $\exists\ n_2 
\in \mathbb{N}$ such that $\forall\ n \ge n_2$, we have $|z_n - L| < 
\varepsilon$.\\[2mm]

Then take $N = \max(n_0, n_1, n_2)$, and let $n \ge N$. For all $n \ge N$, we 
must have
\[ L-\varepsilon < x_n \le y_n \le z_n < L+\varepsilon \]
which implies $|y_n - L| < \varepsilon$. So $(y_n)$ converges to $L$.
\end{proof}
}
\end{frame}


\begin{frame}[fragile]
\frametitle{Squeeze Theorem Code, I}
\begin{alltt}
\{\emph{{\bs}bf} Squeeze Theorem.\}

Let \textbf{$(x_n)$}, \textbf{$(y_n)$} and \textbf{$(z_n)$} be 
sequences in \textbf{$\emph{{\bs}mathbb}\{R\}$}.

Suppose \textbf{$(x_n) \emph{{\bs}to} L$}, \textbf{$(z_n) \emph{{\bs}to} L$}, 
and for all \textbf{$n \emph{{\bs}ge} n_0$}, we have \textbf{$x_n 
\emph{{\bs}le} y_n \emph{{\bs}le} z_n$}; then \textbf{$(y_n) \emph{{\bs}to} 
L$}.

\end{alltt}
\end{frame}


\begin{frame}[fragile]
\frametitle{Squeeze Theorem Code, II}
\begin{alltt}
\emph{{\bs}begin}\{proof\}
Let \textbf{$\emph{{\bs}epsilon} > 0$}. Since \textbf{$(x_n)\emph{{\bs}to} L$}, 
there is some integer \textbf{$n_1$} such that 
\textbf{$\emph{{\bs}forall} n \emph{{\bs}ge} n_1$}, we have 
\textbf{$|x_n - L| < \emph{{\bs}epsilon}$}.\bs\bs[2mm]

Similarly, for the same \textbf{$\emph{{\bs}epsilon}$}, since 
\textbf{$(z_n)$} converges, \textbf{$\emph{{\bs}exists} n_2 \emph{{\bs}in} 
\emph{{\bs}mathbb}\{N\}$} such that \textbf{$\emph{{\bs}forall} n \emph{{\bs}ge}
n_2$}, we have \textbf{$|z_n - L| < \emph{{\bs}epsilon}$}.\bs\bs[2mm]
\end{alltt}
\end{frame}


\begin{frame}[fragile]
\frametitle{Squeeze Theorem Code, III}
\begin{alltt}
Then take \textbf{$N = \emph{{\bs}max}(n_0, n_1, n_2)$}, 
and let \textbf{$n \emph{{\bs}ge} N$}. For all \textbf{$n \emph{{\bs}ge} N$}, 
we must have

\textbf{\bs[ L - \emph{{\bs}epsilon} < x_n 
              \emph{{\bs}le} y_n 
              \emph{{\bs}le} z_n < L + \emph{{\bs}epsilon} \bs]}

which implies \textbf{$|y_n - L| < \emph{{\bs}epsilon}$}. 
So \textbf{$(y_n)$} converges to \textbf{$L$}.
\emph{{\bs}end}\{proof\}

\end{alltt}
\end{frame}


%%% Terminology
\begin{frame}
\frametitle{Terminology}
\begin{itemize}
\item {\bf Control characters:} \textbf{\tt \$ \% \# \& \^ \_ \{ \}}, etc. 
\pause
\item {\bf Command:} sequence beginning with {\tt `\bs'}, e.g. {\tt {\bs}bf} or 
{\tt {\bs}mathbb\{R\}} \pause
\item {\bf Environment:} section delimited by commands, with special 
properties, e.g.  {\tt {\bs}begin\{proof\}} and {\tt {\bs}end\{proof\}} \pause
\item {\bf Math mode:} delimited by \$'s
\end{itemize}
\end{frame}


%%% Things to know for math mode
\begin{frame}[fragile]
\frametitle{Common math mode commands}
\begin{center}
\begin{tabular}{cc}
\hline~\\[-3mm]
\textbf{Display} & \textbf{\LaTeX\ code}\\[1mm]\hline\hline ~\\[-3mm]
$x^{i+1}$ & \verb|x^{i+1}| ~\\[1mm]\hline\\[-3mm]
   $\frac{1}{2}$ & \verb|\frac{1}{2}| ~\\[1mm]\hline\\[-3mm]
$\quad \sqrt{b^2-4ac}\quad\ $ & \verb|\sqrt{b^2-4ac}| ~\\[1mm]\hline\\[-3mm]
   $\ln{e}$ & \verb|\ln{e}| ~\\[1mm]\hline\\[-2mm]
$\displaystyle\lim_{n\to\infty} (x_n)$ & \verb|\lim_{n\to\infty} (x_n)| 
~\\[2mm]\hline\\[-3mm]
$\cos{(2{\pi}n)}$ & \verb|\cos{(2{\pi}n)}|~\\[1mm]\hline\\[-3mm]
$\displaystyle\sum_{i=1}^n s_ib_i$ & \verb|\sum_{i=1}^n s_i b_i|~\\[5mm]\hline
\end{tabular}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{Common math mode commands, continued}
\begin{center}
\begin{tabular}{cc}
\hline~\\[-3mm]
\textbf{Display} & \textbf{\LaTeX\ code}\\[1mm]\hline\hline ~\\[-3mm]
$10 \equiv 3 \pmod{7}$ & \verb|10 \equiv 3 \pmod{7}| ~\\[1mm]\hline\\[-3mm]
$\displaystyle\int_a^b f(x)\,dx$ & \verb|\int_a^b f(x)\,dx| ~\\[4mm]\hline\\[-3mm]
$\mathcal{P}$ & \verb|\mathcal{P}| ~\\[1mm]\hline\\[-3mm]
$\tau\ \varepsilon\ \chi$ & \verb|\tau \epsilon \chi| ~\\[1mm]\hline\\[-2mm]
$A \cap B \ne \varnothing$ & \verb|A \cap B \ne \varnothing|~\\[1mm]\hline\\[-3mm]
$\beta = \{v_1, \ldots, v_n\}$ & \verb|\beta = \{v_1, \ldots, v_n\}|~\\[1mm]\hline\\[-3mm]
$f\colon S \to \mathbb{R}$ & \verb|f \colon S \to \mathbb{R}|~\\[1mm]\hline\\[-3mm]
\end{tabular}
\end{center}

\end{frame}


%%% TeX experts bits
\section{For \TeX\ experts}
\subsection{Some fun tricks}
\begin{frame}
\frametitle{Tricks for \LaTeX\ veterans!}

\begin{block}{DON'T}
\begin{itemize}
\item ...use arrays for matrices. Use a {\tt matrix} environment.
\item ...forget about the {\tt `*'} commands.
\item ...let people tell you you're using \LaTeX\ ``wrong.''
\item ...be afraid to write macros to make your code shorter.\\[2mm]
\end{itemize}
\end{block}
\begin{block}{DO}
\begin{itemize}
\item ...use a good text editor.
\item ...be willing to learn all the time. The learning curve is steep but your 
speed improves quickly.
\item ...use Google (or your search engine of choice). It is your friend.
\item ...use \LaTeX\ for your assignments. More legible work means TAs are more 
forgiving on marking!
\end{itemize}
\end{block}
\end{frame}


\subsection{Macros and Custom Environments}
\begin{frame}[fragile]
\frametitle{Macros and Other User-Defined Objects}
\begin{itemize}
\item $\mathbb{R}$: {\tt{\bs}mathbb\{R\}} vs. {\tt{\bs}R}
\item $\operatorname{dim}(V)$: {\tt{\bs}operatorname\{dim\}} vs. {\tt{\bs}dim}
\item $\overline{\int}_P(e^x)$: {\tt{\bs}overline\{{\bs}int\}} 
vs.  {\tt{\bs}uint}
\item $\subseteq$: {\tt{\bs}subseteq} vs. {\tt{\bs}ss}\\[3mm]
\item Centering math in {\tt enumerate} environment without moving the numbers\\[3mm]
\item Question counters\\[3mm]
\item Using the provided document structuring commands to easily generate a 
table of contents, title page, etc.\\[3mm]
\end{itemize}

My take on this can be found in the {\tt macros.sty} file on my website.
\end{frame}

\subsection{Graphics}
\begin{frame}
\frametitle{TiKZ and Other Graphics Packages}
\vspace{-0.1in}
\begin{center}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Algorithmic Graph Theory
%% http://code.google.com/p/graph-theory-algorithms-book/
%%
%% Copyright (C) 2009--2011 Minh Van Nguyen <nguyenminh2@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% from http://code.google.com/r/isabelindarj-graph/source/browse/image/distance-connectivity/petersen-graph.tex?r=6b8618b651eb5af51b726d688de6acad9ff931a1
%% Copying permitted under the GPL v1.3.
\begin{block}{Graphs}
\begin{tikzpicture}
[nodeDecorate/.style={shape=circle,inner sep=2pt,draw,thick},%
  lineDecorate/.style={-,thick},scale=1.5]
%% nodes or vertices
\foreach \nodename/\x/\y in {
  %% outer pentagon
  0/0/2, 1/-1.9021/0.6180, 2/-1.1755/-1.6180, 3/1.1755/-1.6180,
  4/1.9021/0.6180,
  %% inner pentagon
  5/0/1, 6/-0.9510/0.3090, 7/-0.5877/-0.8090, 8/0.5877/-0.8090,
  9/0.9510/0.3090}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {};
}
%% edges or lines
\path
\foreach \startnode/\endnode in {0/1, 0/4, 0/5, 1/2, 1/6, 2/3, 2/7,
  3/4, 3/8, 4/9, 5/7, 5/8, 6/8, 6/9, 7/9}
{
  (\startnode) edge[lineDecorate] node {} (\endnode)
};
\end{tikzpicture}
\end{block}
$\phantom{x}$\\

\begin{block}{Diagrams}
%%% Authored by yours truly
\vspace{0.25in}
\begin{picture}(200,0)
\put(100,0){\vector(1,0){75}}
\put(100,0){\vector(-1,0){75}}
\put(100,-3){\line(0,1){6}}
\put(150,-3){\line(0,1){6}}
\put(50,-3){\line(0,1){6}}
\put(100,-15){\makebox(0,0)[b]{$b$}}
\put(150,-15){\makebox(0,0)[b]{$b+r$}}
\put(50,-15){\makebox(0,0)[b]{$b-r$}}
\put(50,5){$\overbrace{\rule{35mm}{0mm}}$}
\put(100,17){\makebox(0,0){$a$}}
\end{picture}
\end{block}
\end{center}
\end{frame}


%%% Conclusion
\section{Questions}

\begin{frame}[fragile]
\frametitle{fin.}
{\bf More resources:}

\begin{itemize}
\item My website:\\ {\small \url{http://hashman.ca/tex}}
\item Wikibooks' \LaTeX\ guide: {\small 
\url{http://en.wikibooks.org/wiki/LaTeX}}
\item David Wilkins' Primer: {\small
\url{http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/}}
\item Random math grad students, particularly when fretting over their theses
\end{itemize}
\end{frame}

\end{document}
