Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 16659
1
% this is a comment -- it is a line starting in %
2
3
% the pre-eamble is everything from \documentclass to \begin{document}
4
\documentclass[12pt]{article} % the 12pt makes the font bigger
5
\title{Math 152: Intro to Mathematical Software -- Lecture 7: LaTeX (part 2)} % document title
6
\author{Kiran Kedlaya (guest lecturer: Alina Bucur) \\
7
(based on lectures by William Stein, University of Washington)} % who wrote this
8
\date{January 25, 2017}
9
10
\usepackage{amssymb}
11
12
\usepackage{hyperref} % make it so there is a \url{} command and links work (in pdf!)
13
14
% include support for putting pdf's and png's in our file
15
\usepackage{graphicx}
16
17
% Package for the "newtheorem" command
18
\usepackage{amsthm}
19
\newtheorem{exercise}{Exercise}[section] % exercise environment
20
21
\begin{document}
22
% this is the body of the document
23
24
% This is a command that says: "put the title block here".
25
% Try copying this command and putting it somewhere else and get multiple titles
26
\maketitle
27
28
\tableofcontents
29
30
% Use \section{...} to make a new section.
31
% The * prevents it from being automatically numbered.
32
33
\section{Announcements\label{announcements}}
34
35
{\bf Some announcements:} % md the {\bf ...} makes it bold
36
37
\begin{enumerate}
38
\item You should open {\tt lectures/2017-01-25/2017-01-25.tex} in your project to follow along.
39
\item \label{reminder-homework} HW 2 peer grading due Thursday, January 26 at 8pm.
40
\item HW 3 due Tuesday, January 31 at 8pm.
41
\end{enumerate}
42
43
\section{Math formulas}
44
\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
45
writing, not on how it looks. Also, the result is much more
46
professional-looking. And you can define functions, e.g.,
47
48
\newcommand{\hello}[1]{Hello #1, hello #1 !! }
49
50
\hello{World} - I say \hello{to you}!\\
51
\hello{Kiran}
52
53
\subsection{Some basics}
54
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
55
interesting symbols, like this:
56
$$
57
\varphi, \Xi, \partial, \hookleftarrow, \bigoplus
58
$$
59
60
Consider $\varphi + \Xi^3$.
61
62
Top hit (San Diego company interested in math education! Ask me about them later):\\ \url{https://www.artofproblemsolving.com/wiki/index.php/LaTeX:Symbols}
63
64
This webpage explains a lot of math typesetting. Here are some key things:
65
\begin{itemize}
66
\item Braces: $\{ x : x \in \mathbb{Q}\}$
67
\item Powers: $x^{2+3}$, $x^2+3$, $x^(2+3)$
68
\item Subscripts: $x_2, x_5, x_{2+3}$
69
\item Both: $x^{2+3}_{5}$
70
\item A fraction: $\frac{2+3 \hello{10}}{5}$
71
\item An integral: $\int_0^{\pi+e^i} \sin(x) dx$
72
\item A ``displayed'' integral: $$\int_0^{\pi} \sin(x) dx$$
73
\end{itemize}
74
75
\url{http://detexify.kirelabs.org/classify.html}
76
77
\subsection{Using Sage}
78
79
Given any object {\tt obj} in a Sage worksheet you
80
can (try to) do {\tt latex(obj)} to see how to typeset
81
obj. You already learned about sagetex, which uses
82
this under the hood, on Monday.
83
84
$$
85
x + \frac{1}{6} x^{3} + (-\frac{1}{40}) x^{5} + (-\frac{55}{1008}) x^{7} + \mathcal{O}\left(x^{8}\right)
86
$$
87
88
$$
89
\displaystyle \left(\begin{array}{rrr}
90
1 & -2 & \frac{1}{2} \\
91
1 & 0 & 0 \\
92
-2 & 0 & 1
93
\end{array}\right)
94
$$
95
96
\begin{exercise}
97
Use Sage to find a \LaTeX\ formula for the first few terms
98
of the Taylor series of $\tan(x)$ about
99
zero.\footnote{Hint: use {\tt latex(tan(x).series(x, 10))} in a worksheet, then copy/paste.}
100
\end{exercise}
101
102
$$
103
your series here!
104
$$
105
106
107
\begin{exercise}
108
Use Sage to find a \LaTeX\ formula for a matrix using Sage. Use the command {\tt matrix} to make a matrix.
109
\end{exercise}
110
111
$$
112
your matrix here!
113
$$
114
115
116
117
118
\subsection{Use Some random webpage}
119
120
If you do a Google search for {\tt latex formula editor}
121
you'll find (many) kind-of-ugly websites with
122
various programs that
123
let you graphically construct an equation, which show
124
you the latex code.
125
126
This is an unusual new demo, where they use machine learning
127
to recognize handwriting (it is pretty impressive):\\
128
\url{http://webdemo.myscript.com/#/demo/equation}
129
130
$$
131
\frac{\Omega +\alpha ^{3}} {2}
132
$$
133
134
\section{Sectioning and cross referencing\label{a-label}}
135
This is Section \ref{a-label}. The next section is Section \ref{graphics}.
136
You can reference anything, e.g., reminder \ref{reminder-homework}
137
from Section \ref{announcements}.
138
%Fix the typo here!
139
140
\begin{exercise}
141
Try reordering the enumerate list above in some random way and or the sections
142
(or adding new ones), then recompile and see all the cross reference numbers
143
get updated.
144
\end{exercise}
145
146
147
\section{Including graphics\label{graphics}}
148
149
You can take any pdf, png, or jpg file, put it in the
150
same directory as your tex file (+New, drag and drop),
151
and display them as follows. (Photo taken by William Stein.)
152
153
\begin{center} % this centers it
154
\includegraphics[width=.6\textwidth]{svr.jpg}
155
\end{center}
156
157
\hello{\includegraphics[width=.1\textwidth]{svr.jpg}}
158
159
% Newly added feature: if LaTeX encounters any errors while processing
160
% your source file, the errors are marked in place. This isn't perfect,
161
% but this example is spot on:
162
163
$$x^{\includegraphics[width=.1\textwidth]{a.pdf}} + 1$$
164
165
% Fix the typo and see what happens!
166
167
\begin{exercise}
168
Upload and insert an image of your choice below. It must
169
be png or pdf.
170
\end{exercise}
171
172
% Copy paste the includegraphics thing above here, change
173
% the name from image to the name of your file:
174
175
176
177
Sage can also produce pdf's of plots.
178
E.g., if {\tt g = plot(sin) + plot(cos)}, then
179
{\tt g.save('a.pdf')} will create a file {\tt a.pdf}
180
that you can include. This is a little more tedious
181
than Sagetex, but you have more control.
182
183
\begin{exercise}
184
Create a plot and save it to a file
185
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.)
186
\end{exercise}
187
188
% Copy paste the includegraphics thing above here, change
189
% the name from image to the name of your file:
190
191
192
193
194
\end{document}
195
196