aboutsummaryrefslogtreecommitdiff
path: root/src/Lecture2/slides/3-MoreLatex.tex
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-05-25 17:10:49 +0200
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-05-25 17:10:49 +0200
commitd6c61d988bfa4255baf9cdae42db59ebee38363f (patch)
tree118ff3c2424e735149c145524965a4a337e50beb /src/Lecture2/slides/3-MoreLatex.tex
parent46eef66b1e1571c77dc828d7e950b129b4c8bfd0 (diff)
downloadmathsoftware-d6c61d988bfa4255baf9cdae42db59ebee38363f.tar.gz
mathsoftware-d6c61d988bfa4255baf9cdae42db59ebee38363f.zip
Added files
Diffstat (limited to '')
-rw-r--r--src/Lecture2/slides/3-MoreLatex.tex478
1 files changed, 478 insertions, 0 deletions
diff --git a/src/Lecture2/slides/3-MoreLatex.tex b/src/Lecture2/slides/3-MoreLatex.tex
new file mode 100644
index 0000000..5f234b0
--- /dev/null
+++ b/src/Lecture2/slides/3-MoreLatex.tex
@@ -0,0 +1,478 @@
1\documentclass[11pt]{beamer}
2\usetheme{Madrid}
3\usepackage[utf8]{inputenc}
4\usepackage{amsmath, amssymb, amsfonts, amsthm}
5\usepackage{xcolor}
6
7\usepackage{tikz-cd}
8%\usepackage{enumitem}
9
10\author[\texttt{sebastiano.tronto@uni.lu}]{Sebastiano Tronto}
11\title{More Latex}
12\logo{\includegraphics[scale=0.1]{img/unilu.jpg}}
13%\institute{University of Luxembourg}
14
15\newcommand{\bs}{\textbackslash}
16
17\date{2021-03-12}
18
19\begin{document}
20
21\begin{frame}
22 \titlepage
23\end{frame}
24
25\begin{frame}{Theorems (review)}
26 \begin{center}
27 \large
28 \texttt{\bs newtheorem\{env-name\}{\color{red}[number-with]}\{Text\}{\color{red}[number-parent]}}
29 \end{center}
30
31 \vspace{0.4cm}
32 \begin{itemize}
33 \item \texttt{env-name}: Environment name (use
34 \texttt{\bs begin\{env-name\}...})
35 \item \texttt{Text}: Theorem name to be displayed
36 \item \texttt{[number-with]} for ``shared counter''
37 \item \texttt{[number-parent]} adds x.1
38 \item {\color{red} At most one of \texttt{[number-with]}
39 and \texttt{[number-parent]}}
40 \end{itemize}
41
42\end{frame}
43
44\begin{frame}{Theorems (review)}
45 \begin{columns}
46 \column{0.5\textwidth}
47 \includegraphics[scale=0.3]{img/thm_pre.png}
48
49 \vspace{0.2cm}
50 \vdots
51 \vspace{0.3cm}
52
53 \includegraphics[scale=0.3]{img/thm_tex.png}
54
55 \column{0.5\textwidth}
56 \includegraphics[scale=0.2]{img/thm_pdf.png}
57
58 \vspace{1cm}
59 \end{columns}
60\end{frame}
61
62
63\begin{frame}{Counters}
64 Reference: \url{https://en.wikibooks.org/wiki/LaTeX/Counters}
65
66 \vspace{0.5cm}
67 \begin{itemize}
68 \item Sections, theorems etc have an associated \emph{counter}
69
70 \vspace{0.2cm}
71 \item Common usage:
72
73 \vspace{0.1cm}
74 \texttt{\bs setcounter\{counter-name\}\{n\} \quad \%Set counter to n}
75
76 \vspace{0.1cm}
77 \texttt{\bs addtocounter\{counter-name\}\{n\}\quad\%Add n to counter}
78 \end{itemize}
79\end{frame}
80
81
82\begin{frame}{Counters}
83
84 \begin{itemize}
85 \item Define a counter with \texttt{\bs newcounter\{name\}[number-parent]}
86
87 \vspace{0.2cm}
88 \item Change sub-numbering of defined counters:
89
90 \vspace{0.15cm}
91 \begin{center}
92 \begin{tabular}{l}
93 \texttt{\bs numberwithin\{equation\}\{section\}}
94 %\texttt{\bs numberwithout\{subsection\}\{section\}}
95 \end{tabular}
96 \end{center}
97
98 \vspace{0.2cm}
99 \item Print formatted counter with \texttt{\bs{\color{red}the}name}
100 or just number with \texttt{\bs arabic\{name\}}
101 (or \texttt{\bs alph}, \texttt{\bs Alph}, \texttt{\bs roman},
102 \texttt{\bs Roman}, \texttt{\bs fnsymbol})
103 \end{itemize}
104\end{frame}
105
106
107\begin{frame}{Counters}
108
109 \begin{columns}
110
111 \column{0.5\textwidth}
112 \begin{center}
113 {\large\textbf{Default counters}}
114
115 \vspace{0.3cm}
116 \begin{tabular}{l}
117 %part \\
118 chapter \\
119 section \\
120 subsection \\
121 subsubsection \\
122 paragraph \\
123 %subparagraph \\
124 page \\
125 figure \\
126 %table \\
127 footnote \\
128 %mpfootnote \\
129 equation \\
130 enumi \\
131 enumii \\
132 ...
133 %enumiii \\
134 %enumiv \\
135 \end{tabular}
136 \end{center}
137
138 \column{0.5\textwidth}
139 {\large\textbf{Counter styles}}
140
141 \vspace{0.3cm}
142 \begin{tabular}{ll}
143 \texttt{arabic} & 1, 2, 3, 4... \\
144 \texttt{alph} & a, b, c, d... \\
145 \texttt{Alph} & A, B, C, D... \\
146 \texttt{roman} & i, ii, iii, iv... \\
147 \texttt{Roman} & I, II, III, IV... \\
148 \texttt{fnsymbol} & $\ast$, $\dagger$, $\ddagger$, $\S$ ...
149 \end{tabular}
150 \end{columns}
151\end{frame}
152
153\begin{frame}{Counters: change \texttt{\bs thecounter}}
154 \begin{itemize}
155 \item Change how counter is displayed by default, for example:
156
157 \vspace{0.2cm}
158 \begin{center}
159 \texttt{\bs renewcommand\{\bs thesection\}\{\bs alph\{section\}\}}
160 \end{center}
161
162 \vspace{0.3cm}
163 \item For enumerate:
164
165 \vspace{0.2cm}
166 \begin{center}
167 \begin{tabular}{l}
168 \texttt{\bs usepackage\{enumitem\}} \\
169 \texttt{\bs begin\{enumerate\}[label=\bs alph*]}
170 \end{tabular}
171 \end{center}
172 \end{itemize}
173\end{frame}
174
175\begin{frame}{\texttt{label} and \texttt{ref}}
176 \begin{itemize}
177 \item Put \texttt{\bs label\{mark\}} immediately after the thing you want
178 to refer to (after \texttt{\bs refstepcounter\{countername\}} for
179 counters you define)
180
181 \vspace{0.3cm}
182 \item Use \texttt{\bs ref\{mark\}} or \texttt{\bs eqref\{mark\}} to refer
183 %(or \texttt{\bs eqref\{mark\}} = \texttt{(\bs ref\{mark\})})
184
185 (Pro tip: write \texttt{Proposition$\sim$\bs ref\{mark\}})
186 \vspace{0.3cm}
187 \item Compile twice!
188 \end{itemize}
189\end{frame}
190
191
192\begin{frame}{The \texttt{hyperref} package}
193 \texttt{\bs usepackage\{hyperref\}}
194
195 \vspace{1cm}
196 \begin{itemize}
197 \item Now all \texttt{\bs ref\{mark\}} become clickable!
198
199 \vspace{0.3cm}
200 \item \texttt{\bs hyperref[mark]\{text\}} for internal links
201
202 \vspace{0.3cm}
203 \item \texttt{\bs url\{www.google.com\}} or
204 \texttt{\bs href\{www.google.com\}\{Google\}} for web links
205 \end{itemize}
206\end{frame}
207
208\begin{frame}{New commands}
209 \begin{itemize}
210 \item We have seen \texttt{\bs newcommand\{\bs command\}\{output\}}
211
212 \vspace{0.3cm}
213 \item Arguments: use \texttt{\bs newcommand\{\bs command\}[n]\{output\}}
214 and use the arguments in \texttt{output} with
215 \texttt{\#1, \#2, ... \#n} \hspace{0.4cm}(\texttt n$\leq 9$)
216
217 \vspace{0.3cm}
218 \item If \texttt{\bs command} is already defined:
219 \texttt{\bs renewcommand} (overwrite) or
220 \texttt{\bs providecommand} (use old definition, if it exists)
221 \end{itemize}
222\end{frame}
223
224\begin{frame}{New commands - examples}
225
226 \begin{tabular}{l|c}
227 \texttt{\bs newcommand\{hi\}\{Hello, World!\}} \\
228 \texttt{\bs hi} & Hello, world! \\
229 \\
230 \texttt{\bs newcommand\{hello\}[1]\{Hello, \#1!\}} \\
231 \texttt{\bs hello\{my friend\}} & Hello, my friend! \\
232 \\
233 \texttt{\bs renewcommand\{binom\}[2]\{bin(\#1,\#2)\}} \\
234 \texttt{\bs( \bs binom\{10\}2 \bs)} & \(bin(10,2)\)
235 \end{tabular}
236\end{frame}
237
238
239\begin{frame}{New commands - optional argument}
240 \texttt{\bs newcommand\{\bs com\}[n][default1]\{output\}}
241
242 \texttt{\bs com[first]\{other,args\}} or \texttt{\bs com\{without,first\}}
243
244 \vspace{1cm}
245 \begin{itemize}
246 \item At most one optional argument, must be \texttt{\# 1}
247
248 \vspace{0.3cm}
249 \item More complex things: use TeX primitives such as
250 \texttt{\bs ifthenelse} or see
251 \url{https://www.ctan.org/tex-archive/support/newcommand/}
252 \end{itemize}
253\end{frame}
254
255\begin{frame}{Exercises}
256 \begin{enumerate}%[label=(\arabic*)]
257 \item Write a command \texttt{\bs mat} which takes $4$ arguments and
258 outputs a $2\times 2$ matrix with those arguments as entries
259 (use \texttt{pmatrix}).
260
261 \vspace{0.5cm}
262 \item Write a command to define a function case-by-case ($2$ cases,
263 $4$ arguments). Use the \texttt{cases} environment:
264
265 \vspace{0.2cm}
266 \begin{columns}
267 \column{0.45\textwidth}
268 \begin{center}\begin{tabular}{l}
269 \texttt{\bs begin\{cases\}} \\
270 \texttt{\quad 1 \& 2 \bs\bs \quad3 \& 4} \\
271 \texttt{\bs end\{cases\}}
272 \end{tabular}\end{center}
273
274 \column{0.09\textwidth}
275 \begin{center} $\implies$ \end{center}
276
277 \column{0.45\textwidth}
278 \begin{align*}
279 \begin{cases} 1 & 2 \\ 3 & 4 \end{cases}
280 \end{align*}
281 \end{columns}
282 \end{enumerate}
283\end{frame}
284
285
286\begin{frame}{Pictures}
287 \texttt{\bs usepackage\{graphicx\}}
288
289 \texttt{\bs includegraphics[options]\{picture.jpg\}}
290
291 \vspace{1cm}
292 Options (comma-separated) include:
293
294 \vspace{0.2cm}
295 \begin{itemize}
296 \item \texttt{scale=x} (scale by a factor of x)
297 \item \texttt{width=x} and \texttt{height=y} (if both specified picture
298 is distorted)
299 \item \texttt{angle=$\alpha$} (rotate)
300 \end{itemize}
301\end{frame}
302
303
304\begin{frame}{Figures}
305 \texttt{\bs begin\{figure\}[place]}
306
307 \vspace{1cm}
308 \begin{itemize}
309 \item Figure outside normal text flow.
310 \item \texttt{place}: \texttt{h} (here), \texttt{t} (top) or \texttt{b}
311 (bottom).
312 \item Can add \emph{caption}
313 \end{itemize}
314
315 \vspace{0.3cm}
316 \begin{center} \begin{tabular}{l}
317 \texttt{\bs begin\{figure\}[h]} \\
318 \texttt{\qquad\bs centering \qquad \% recommended} \\
319 \texttt{\qquad \bs includegraphics\{picture.jpg\}} \\
320 \texttt{\qquad \bs caption\{Description of the picture\}} \\
321 \texttt{\bs end\{figure\}}
322 \end{tabular} \end{center}
323\end{frame}
324
325
326\begin{frame}{Wrapping text around figures}
327
328 \texttt{\bs usepackage\{{\color{red}wrapfig}\}}
329
330 \texttt{\bs begin\{wrapfigure\}{\color{red}\{alignment\}\{width\}}}
331
332 \vspace{1cm}
333 \begin{itemize}
334 \item \texttt{alignment}: \texttt{l} (left) or \texttt{r} (right)
335 \item Must specify \texttt{width}
336 \item Works the same as \texttt{figure}
337 \end{itemize}
338
339 \vspace{0.3cm}
340 \begin{center} \begin{tabular}{l}
341 \texttt{\bs begin\{wrapfigure\}{\color{red}\{l\}\{0.5\bs textwidth\}}} \\
342 \texttt{\qquad\bs centering} \\
343 \texttt{\qquad \bs includegraphics\{picture.jpg\}} \\
344 \texttt{\qquad \bs caption\{Description of the picture\}} \\
345 \texttt{\bs end\{wrapfigure\}}
346 \end{tabular} \end{center}
347\end{frame}
348
349
350\begin{frame}{Lengths}
351 Reference: \url{https://en.wikibooks.org/wiki/LaTeX/Lengths}
352
353 \vspace{0.5cm}
354 \begin{itemize}
355 \item Similar to counters:
356
357 \vspace{0.3cm}
358 \begin{center}\begin{tabular}{l}
359 \texttt{\bs newlength\{\bs lengthname\}}\\
360 \texttt{\bs setlength\{\bs lengthname\}\{value\}}
361 \end{tabular}\end{center}
362
363 \vspace{0.3cm}
364 \item \texttt{value}: number followed by unit
365 (\texttt{12pt}, \texttt{1.2cm}, \texttt{65mm}, \dots)
366 \end{itemize}
367\end{frame}
368
369\begin{frame}{Lengths}
370 Default lengths:
371
372 \vspace{0.5cm}
373 \begin{itemize}
374 \item \texttt{\bs textwidth}: width of text in a page
375 \item \texttt{\bs textheight}: height of text in a page
376 \item \texttt{\bs baselineskip}: space between lines in same paragraph
377 \item \texttt{\bs parskip}: space between paragraphs
378 \item \texttt{\bs parindent}: indentation of first line of a paragraph
379 \item \dots
380 \end{itemize}
381\end{frame}
382
383\begin{frame}{Manual spacing}
384 \begin{itemize}
385 \item \texttt{\bs vspace\{length\}} and \texttt{\bs hspace\{length\}}
386
387 \vspace{0.2cm}
388 \item Fill space: \texttt{\bs vfill} and \texttt{\bs hfill}
389
390 \vspace{0.2cm}
391 \item Fill line with ``decoration'':
392 \texttt{\bs hrulefill} and \texttt{\bs dotfill}
393
394 \vspace{0.2cm}
395 \item Example:
396
397 \vspace{0.2cm}
398 \begin{center}
399 \texttt{First name: \bs hrulefill \bs quad Last name: \bs hrulefill}
400 \end{center}
401 \end{itemize}
402\end{frame}
403
404
405
406\begin{frame}{Bibliography}
407 Simple bibliography with \texttt{thebibliography} environment:
408
409 \vspace{0.5cm}
410 \begin{center}\begin{tabular}{l}
411 \texttt{\bs begin\{thebibliography\}\{99\}} \\
412 \texttt{\qquad\bs bibitem\{knuth68\}} \\
413 \texttt{\qquad\qquad Donald Knuth, The Art of Computer Programming,} \\
414 \texttt{\qquad\qquad Volume I, 1968, Addison-Wesley}\\
415 \texttt{\bs end\{thebibliography\}}
416 \end{tabular}\end{center}
417
418 %\vspace{0.5cm}
419 %And cite with \texttt{\bs cite\{knuth68\}}
420\end{frame}
421
422
423\begin{frame}{Bibligraphy}
424 \begin{itemize}
425 \item Simple citation: \texttt{\bs cite\{knuth68\}}
426
427 \vspace{0.3cm}
428 \item Cite multiple sources: \texttt{\bs cite\{source1, source2\}}
429
430 \vspace{0.3cm}
431 \item Cite specific part with \texttt{\bs cite[p.$\sim$42]\{source\}}
432 \end{itemize}
433\end{frame}
434
435
436\begin{frame}{Bibliography: BibTeX}
437 \begin{itemize}
438 \item Separate file \texttt{mybib.bib}, different syntax:
439
440 \begin{center}\begin{tabular}{l}
441 \texttt{@book\{knuth68,} \\
442 \texttt{\qquad author = "Donald Knuth",}\\
443 \texttt{\qquad title = "The Art of Computer Programming",}\\
444 \texttt{\qquad publisher = "Addison-Wesley",}\\
445 \texttt{\qquad volume = "I",}\\
446 \texttt{\qquad year = "1968",} \\
447 \texttt{\}}
448 \end{tabular}\end{center}
449
450 \vspace{0.3cm}
451 \item Include bibliography in your \texttt{.tex} file:
452
453 \begin{center}\begin{tabular}{l}
454 \texttt{\bs bibliographystyle\{plain\}}\\
455 \texttt{\bs bibliography\{mybib\}}
456 \end{tabular}\end{center}
457 \end{itemize}
458\end{frame}
459
460
461\begin{frame}{Bibliography: BibTeX}
462 \begin{itemize}
463 \item Compile, generate bibliography, compile, compile
464
465 \vspace{0.3cm}
466 \item Books in \texttt{.bib} file but not cited do not appear
467
468 \vspace{0.3cm}
469 \item Citing articles and other: see \url{https://en.wikibooks.org/wiki/%
470 LaTeX/Bibliography\_Management\#Standard\_templates}
471
472 \vspace{0.3cm}
473 \item Find BibTeX citations on \url{https://scholar.google.com}
474 \end{itemize}
475\end{frame}
476
477\end{document}
478

Generated with cgit - Back to sebastiano.tronto.net