\documentclass[12pt]{article}
\title{Math 152: Intro to Mathematical Software -- Lecture 7: LaTeX (part 2)}
\author{Kiran Kedlaya (guest lecturer: Alina Bucur) \\
(based on lectures by William Stein, University of Washington)}
\date{January 25, 2017}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{amsthm}
\newtheorem{exercise}{Exercise}[section]
\begin{document}
\maketitle
\tableofcontents
\section{Announcements\label{announcements}}
{\bf Some announcements:}
\begin{enumerate}
\item You should open {\tt lectures/2017-01-25/2017-01-25.tex} in your project to follow along.
\item \label{reminder-homework} HW 2 peer grading due Thursday, January 26 at 8pm.
\item HW 3 due Tuesday, January 31 at 8pm.
\end{enumerate}
\section{Math formulas}
\LaTeX\ is massively different than a typical word processor (e.g., Microsoft Word). You focus entirely on the content and structure of what you are
writing, not on how it looks. Also, the result is much more
professional-looking. And you can define functions, e.g.,
\newcommand{\hello}[1]{Hello #1, hello #1 !! }
\hello{World} - I say \hello{to you}!\\
\hello{Kiran}
\subsection{Some basics}
Google ``latex symbols''\footnote{Look in the tex file for how I did those quotes and this footnote.} for tables\footnote{what is a table?} giving how to typeset
interesting symbols, like this:
$$
\varphi, \Xi, \partial, \hookleftarrow, \bigoplus
$$
Consider $\varphi + \Xi^3$.
Top hit (San Diego company interested in math education! Ask me about them later):\\ \url{https://www.artofproblemsolving.com/wiki/index.php/LaTeX:Symbols}
This webpage explains a lot of math typesetting. Here are some key things:
\begin{itemize}
\item Braces: $\{ x : x \in \mathbb{Q}\}$
\item Powers: $x^{2+3}$, $x^2+3$, $x^(2+3)$
\item Subscripts: $x_2, x_5, x_{2+3}$
\item Both: $x^{2+3}_{5}$
\item A fraction: $\frac{2+3 \hello{10}}{5}$
\item An integral: $\int_0^{\pi+e^i} \sin(x) dx$
\item A ``displayed'' integral: $$\int_0^{\pi} \sin(x) dx$$
\end{itemize}
\url{http://detexify.kirelabs.org/classify.html}
\subsection{Using Sage}
Given any object {\tt obj} in a Sage worksheet you
can (try to) do {\tt latex(obj)} to see how to typeset
obj. You already learned about sagetex, which uses
this under the hood, on Monday.
$$
x + \frac{1}{6} x^{3} + (-\frac{1}{40}) x^{5} + (-\frac{55}{1008}) x^{7} + \mathcal{O}\left(x^{8}\right)
$$
$$
\displaystyle \left(\begin{array}{rrr}
1 & -2 & \frac{1}{2} \\
1 & 0 & 0 \\
-2 & 0 & 1
\end{array}\right)
$$
\begin{exercise}
Use Sage to find a \LaTeX\ formula for the first few terms
of the Taylor series of $\tan(x)$ about
zero.\footnote{Hint: use {\tt latex(tan(x).series(x, 10))} in a worksheet, then copy/paste.}
\end{exercise}
$$
your series here!
$$
\begin{exercise}
Use Sage to find a \LaTeX\ formula for a matrix using Sage. Use the command {\tt matrix} to make a matrix.
\end{exercise}
$$
your matrix here!
$$
\subsection{Use Some random webpage}
If you do a Google search for {\tt latex formula editor}
you'll find (many) kind-of-ugly websites with
various programs that
let you graphically construct an equation, which show
you the latex code.
This is an unusual new demo, where they use machine learning
to recognize handwriting (it is pretty impressive):\\
\url{http://webdemo.myscript.com/#/demo/equation}
$$
\frac{\Omega +\alpha ^{3}} {2}
$$
\section{Sectioning and cross referencing\label{a-label}}
This is Section \ref{a-label}. The next section is Section \ref{graphics}.
You can reference anything, e.g., reminder \ref{reminder-homework}
from Section \ref{announcements}.
\begin{exercise}
Try reordering the enumerate list above in some random way and or the sections
(or adding new ones), then recompile and see all the cross reference numbers
get updated.
\end{exercise}
\section{Including graphics\label{graphics}}
You can take any pdf, png, or jpg file, put it in the
same directory as your tex file (+New, drag and drop),
and display them as follows. (Photo taken by William Stein.)
\begin{center}
\includegraphics[width=.6\textwidth]{svr.jpg}
\end{center}
\hello{\includegraphics[width=.1\textwidth]{svr.jpg}}
$$x^{\includegraphics[width=.1\textwidth]{a.pdf}} + 1$$
\begin{exercise}
Upload and insert an image of your choice below. It must
be png or pdf.
\end{exercise}
Sage can also produce pdf's of plots.
E.g., if {\tt g = plot(sin) + plot(cos)}, then
{\tt g.save('a.pdf')} will create a file {\tt a.pdf}
that you can include. This is a little more tedious
than Sagetex, but you have more control.
\begin{exercise}
Create a plot and save it to a file
as above in a Sage worksheet, then include it below. (Remember, you can use the ``Plots'' menu in a worksheet to see some examples of plotting syntax.)
\end{exercise}
\end{document}