\documentclass{article} 		% see Section 1.3

% See lines 57-68 of mymacros.sty for a different/better way of including 
% packages. 
% We leave these here merely to point out the sections wherein we use these
% packages. 
\usepackage{amsfonts, amsmath, amssymb, amsthm}	% math symbols, environments, etc. 
\usepackage{graphicx, float} 	% for inserting pictures
	\graphicspath{{images/}} 		% set the path from which LaTeX pulls images
\usepackage{mathrsfs} 			% see Theorem 1, Section 3.1
\usepackage{kbordermatrix} 		% see Section 3.2.4
	\renewcommand{\kbldelim}{(} % left delimiter, default is [
	\renewcommand{\kbrdelim}{)} % right delimiter, default is ]
\usepackage{units, xcolor} 		% see Section 6
\usepackage{fancyvrb} 			% see Section 6.3
\usepackage{mymacros}			% includes macros from mymacros.sty
% ignore this stuff------------
\usepackage{footnote}
	\makesavenoteenv{tabular}
\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
	linkcolor=blue,
	urlcolor=blue,
}
\usepackage[affil-it]{authblk}
%------------------------------

\newcommand{\sddots}{\rotatebox{-30}{$\ddots$}} % see Section 3.2.4

\begin{document}
\begin{titlepage}
	\title{\bfseries \LaTeX\ for Undergraduates\footnote{
			This paper was jointly written by the TTU Math Club; however, any singular first-person pronouns refer to Andrew. \par
			Throughout this paper, there are some commands from the accompanying \texttt{mymacros} package, but we forgo further reference to \texttt{mymacros.sty}. If you use a command from this tutorial in another document and it says the command is undefined, you probably need to install \texttt{mymacros} and include it in the preamble. 
		}
	}
	\author{Patrick Bartol, Will Irvin, Andrew Lounsbury, \\
	Josie Millican, Madison Pearson, John Puckett, \\
	Adriana Rosalia, Alizza Schremp, Ryland Smith
	}
	\affil{Math Club \\
		Tennessee Technological University \\
		Cookeville, TN, 38505
	}
	\date{Fall 2020 -- Spring 2021}
	\maketitle
	
	\vspace{0.625in}
	To put a title on a simple homework assignment, you only need lines \texttt{33}-\texttt{41} and \texttt{46}-\texttt{47} in the code (\texttt{LaTeX\_for\_Undergraduates.tex}) instead of an entire \texttt{titlepage}, but you don't necessarily have to use this method. You can put the title, your name, and the date on the paper however you'd like. \\

	As you read this, use the keyboard shortcut Ctrl + F to search for specific things in the code so that you can compare the code precisely to what's being printed. 
	\vspace{0.875in}
	\begin{center}
		\includegraphics[width=0.15\textwidth]{TechSignatureSeal_Purple_RGB.jpg}
	\end{center}
\end{titlepage}

\tableofcontents

\newpage
\section{Setting Up} \label{sec:setting-up}
\subsection{MiKTeX} \label{subsec:miktex}
Click \href{https://miktex.org/download}{here} to download MiKTeX. Install it to the default directory. When it asks if MiKTeX should install packages on the fly, say ``\textbf{yes}.''

\subsection{\LaTeX\ Editors: Visual Studio Code} \label{subsec:editors}
We recommend Visual Studio Code for Windows users and (maybe) Mac users.\footnote{
	If you can't or don't want to use VS Code, see \href{https://en.wikipedia.org/wiki/Comparison_of_TeX_editors}{here} and \href{https://tex.stackexchange.com/questions/339/latex-editors-ides}{here}.
} 
To download the User Installer for VS Code, click \href{https://code.visualstudio.com/download}{here}. When it gives the option to add the ``Open with Code'' action to file and directory context menus, \textbf{check both} boxes. \par
Open \texttt{LaTeX\_for\_Undergraduates.tex} in VS Code. With the \includegraphics[scale=0.06]{marketplace.png} button on the left sidebar, install the following:
\begin{enumerate}
	\item[]
	LaTeX Workshop

	\item[]
	Code Spell Checker

	\item[]
	Notepad++ keymap
\end{enumerate}

Initially, there is a wide scrollbar that shows a zoomed-out image of your code. You can toggle this under \texttt{View -> Show Minimap}. \par
Click the gear in the bottom left, select \texttt{Settings}
, and change the following:\footnote{
	There is a button at the top right that opens a \texttt{json} file with all overridden settings. 
}
\begin{center}
	\begin{tabular}{|l|l|}
		\hline
		Editor: Word Wrap & \textbf{on} \\ \hline
		Auto Find in Selection & \textbf{multiline} \\ \hline
		LaTeX Workshop $>$ Message $>$ Error: Show & \textbf{uncheck} the box \\ \hline
		Workbench: Startup Editor & \textbf{none} \\ \hline
	\end{tabular}
\end{center}

Try building the file with the green button in the top-right. \par
Windows users may receive an error in the bottom left regarding a file \texttt{perl.exe} from a programming language called \textbf{Perl}. 
Click \href{https://www.perl.org/get.html}{here} to download Perl. There is a choice between \textit{Strawberry Perl} and \textit{ActiveState Perl}. A Stack Exchange page said that ActiveState Perl is better for beginners, so it's probably fine to download that one. \par
Now, you may need to add the path to your Perl installation to the Path variable. If so, search your computer for the option to edit your \textit{Environment Variables} in your \textit{System Properties}. Select \texttt{Environment Variables...} Under \textit{System variables}, select \textbf{Path} and click \texttt{Edit...}. 
\begin{center}
	\includegraphics[width=0.85\textwidth]{perl1.png}
\end{center}
Add the path to your Perl installation with the \texttt{New} button on the right:
\begin{center}
	\includegraphics[width=0.85\textwidth]{perl2crop.png}
\end{center}
Try building the file again to ensure everything works properly. It will likely take longer than usual because it has to install the necessary packages, because it has to generate the auxiliary files for the first time, and because this is a nineteen-page document. Be sure to press the button in the top right with the magnifying glass to open the \texttt{pdf} and see the result of the compilation. 

\subsection{Creating a Document in VS Code} \label{subsec:creating-document}
Create new files and open files under \texttt{File}. Regarding the three buttons \includegraphics[scale=0.08]{compiling.png} in the top-right corner, the play button on the left compiles the file, the middle button with the magnifying glass displays the \texttt{pdf}, and the button on the right splits the editor so that you can open multiple files or open a duplicate view of the same file.\footnote{
	I've noticed that when I close my laptop with a document and its \texttt{pdf} open, that \texttt{pdf} will no longer update when I recompile. Closing the \texttt{pdf} in the viewer and opening it again seems to consistently fix this. 
} 
Note, however, that VS Code compiles every time you save. \par
View error messages by clicking the icons in the bottom-left corner. 
\begin{center}
	\includegraphics[width=0.8\textwidth]{creatingDocument.png}
\end{center}

The font size \texttt{[12pt]} is optional and may be set to sizes other than \texttt{12}. The \texttt{article} class is for regular documents.\footnote{
	The \texttt{beamer} class allows us to make presentation slides and posters in \LaTeX. 
}
The preamble is everything between \texttt{\textbackslash documentclass\{article\}} and \texttt{\textbackslash begin\{document\}}, in other words, your margins and text dimensions, which are optional, and your packages. \p
Regarding the content of the document, writing in \LaTeX\ can generally be summarized as (1) typing regular text, (2) typing math with \texttt{\$\dots\$}, (3) displaying math with \texttt{\textbackslash[\dots\textbackslash]}, and (4) learning commands and environments as you need them. Any text contained in \texttt{\textbackslash begin\{}\option{env-name}\texttt{\}\dots\textbackslash end\{}\option{env-name}\texttt{\}} is in the \option{env-name} environment. 

\newpage
\subsection{Keyboard Shortcuts in VS Code} \label{subsec:shortcuts}
Remember to make ample use of the following shortcuts. \blankline[2]
\begin{center}
	\begin{tabular}{|c||l||l|}
		\hline
		\textbf{Source}\footnote{
			VSC = VS Code; LW = \LaTeX\ Workshop; N++ = Notepad++ keymap \p
			\cby{\textbf{NOTE}}: These \LaTeX\ Workshop shortcuts must be added in the shortcut menu. 
		} & \textbf{Shortcut} & \textbf{Action} \\ \hline\hline
		VSC & Ctrl + A & highlight all \\ \hline
		N++ & Ctrl + D & duplicate \\ \hline
		LW & Ctrl + E & select current environment \\ \hline
		VSC & Ctrl + F \& Ctrl + H & search \& replace \\ \hline
		LW & Ctrl + K & kill compiler process \\ \hline
		N++ & Ctrl + Q & toggle comments \\ \hline
		LW & Ctrl + T & toggle between \texttt{\textbackslash[\dots\textbackslash]} and \\
		& & the \texttt{equation*} environment \\ \hline
		LW & Ctrl + W & wrap in environment \\ \hline
		VSC & Ctrl + Z \& Ctrl + Y & undo \& redo (even autocompletion) \\ \hline
		VSC & Double Click & highlight string \\ \hline
		VSC & Highlight + Delimiter & surround with \texttt{\{}\dots\texttt{\}}, \texttt{(}\dots\texttt{)}, \texttt{[}\dots\texttt{]}, \texttt{\$}\dots\texttt{\$} \\ \hline
		VSC & Shift + Click & highlight everything between the \\ 
		& 			  & text cursor and your mouse cursor \\ \hline
		VSC & Tab \& Shift + Tab & tab/untab multiple lines; \\
		& 				   & next/previous argument in a macro \\ \hline
		VSC & Tab or Enter & autocomplete suggested text \\ \hline
		VSC & Shift + Enter & prevent an autocompletion \\ \hline
	\end{tabular}
\end{center}

These save lots of time. If your editor doesn't have them, you may want to look through your settings and add these shortcuts or change them if they're different from what you want them to be. In VS Code, you can view your keyboard shortcuts in the settings at the bottom-left.\footnote{
	There is a button at the top right in the shortcuts menu that opens the \texttt{json} file with all overridden shortcuts. 
}

\subsubsection{Autocompletion} \label{subsubsec:autocompletion}
VS Code allows us to autocomplete any string of regular text provided the string has already been typed into the document once. It doesn't give the option to autocomplete ``Nullstellensatz'' in this document because we haven't typed it yet, but if we type ``Nullstellensatz'' again, it gives us the option. \par
For commands, autocompletion doesn't trigger in new, unsaved files nor for commands that haven't already been typed \textit{and saved} into the document once. Upon typing \texttt{\textbackslash msum} for the first time, we don't have the option to autocomplete it and successively enter its arguments, but upon adding the three \texttt{\{\dots\}} to the first instance, saving the document, and typing \texttt{\textbackslash msum} a second time, we can press Tab and VS Code automatically types \texttt{\textbackslash msum\{\rule[-1ex]{1pt}{3ex}\}\{\}\{\}} with the braces ready and the text cursor inside the first set of braces. {}

\section{Text} \label{sec:text}
Regular text is said to be in paragraph mode. 
\subsection{Formatting Text} \label{subsec:formatting-text}
Comment things out with \texttt{\%}.\footnote{
	There is a \texttt{comment} environment in the \texttt{verbatim} package for creating block comments. The benefit of this is that we can minimize environments in VS Code so that we don't have to constantly scroll through code we're not reading. We could otherwise highlight the multiple lines we want to comment out and press Ctrl + Q (or an equivalent shortcut). 
} \par
% This sentence is not in the pdf. 
Create a new line without indentation using \texttt{\textbackslash\textbackslash }. \\
Create a new paragraph with indentation either with \texttt{\textbackslash par} or by leaving an empty line in the code. \par
An empty line with a 
%
comment symbol will not create a new line. See code. 

\noindent
We can stop the indentation on an empty line like this.\footnote{
	We wouldn't use \texttt{\textbackslash par} unless we specifically wanted the indentation.
}

\begin{enumerate}
	\item[1.]
	\texttt{\textbackslash par} doesn't indent \par
	when placed in certain environments such as \texttt{enumerate}. 

	Nor does an empty line. 
\end{enumerate}

It's good to use these in such a way that makes your code look similar to what's being printed. Using \texttt{\textbackslash\textbackslash} along with an empty line will create an empty line in both your code and your document. \\

\noindent
This will produce \textit{italicized} text. \\
This will produce \textbf{boldface} text. \\
This will produce \textsc{small caps} text. \\
This will produce \texttt{typewriter (teletype)} font. \\

Changing the $\langle\textit{font-size}\rangle$ option in \texttt{\textbackslash documentclass[}$\langle\textit{font-size}\rangle$\texttt{]\{article\}} will affect the way the following sizes work. For instance, \texttt{[12pt]} makes \texttt{\textbackslash huge} and \texttt{\textbackslash Huge} appear the same. \\

\noindent
Whereof one cannot speak, thereof one must be silent. \\
Whereof one cannot speak, thereof one must be {\large silent}. \\
Whereof one cannot speak, thereof one must be {\Large silent}. \\
Whereof one cannot speak, thereof one must be {\LARGE silent}. \\
Whereof one cannot speak, thereof one must be {\huge silent}. \\
Whereof one cannot speak, thereof one must be {\Huge silent}. \\
Whereof one cannot speak, thereof one must be {\small silent}. \\
Whereof one cannot speak, thereof one must be {\tiny silent}. 

\newpage
\begin{center}
	This is centered.
\end{center}
%
\begin{flushleft}
	This is left-justified.
\end{flushleft}
%
\begin{flushright}
	This is right-justified.
\end{flushright}
%
You can insert horizontal space \hspace{1in} like this, or 
insert vertical space 
\vspace{0.5in} \\
like this. 

\subsection{Lists} \label{subsec:lists}
\begin{enumerate}
	\item[1.]
	This is \texttt{enumerate}.\footnote{
		The \texttt{enumitem} package provides additional functionality for \texttt{enumerate}.
	}
	
	\item[label \#2]
	Though it numbers items automatically, it's good to label the items so that you can tell the difference between all the \texttt{\textbackslash item}'s in your code. Note that you can change the labels with brackets. 
	
	\item[3.]
	\begin{enumerate}
		\item% a
		Once-nested \texttt{enumerate} environment 
		
		\item% b
			\begin{enumerate}
				\item% i
				Twice-nested
				
				\item% ii
				\begin{enumerate}
					\item% A
					Thrice-nested
					
					\item% B
					This is the maximum number of times you can nest them. 
				\end{enumerate}
			\end{enumerate}

	\end{enumerate}
\end{enumerate}

\begin{itemize}
	\item
	This is \texttt{itemize}.
	
	\item% dot
	Good labeling for \texttt{itemize} might be ``dot'', ``dash'', ``star'', ``point,'' but the utility of this depends on whether you put \texttt{\textbackslash item} on its own line or the same line as your text. 
	
	\item% dot
	\begin{itemize}
		\item% dash
		Once-nested \texttt{itemize} environment 
		
		\item% dash
			\begin{itemize}
				\item% star
				Twice-nested
				
				\item% star
				\begin{itemize}
					\item % point
					Thrice-nested
					
					\item% point
					This is the maximum number of times you can nest them. 
					
				\end{itemize}
			\end{itemize}
	\end{itemize}
\end{itemize}

\begin{tabular}{|l||c||r|}
	\hline
	There is also & the \texttt{tabular} & environment. \\ \hline\hline
	It's like an & array without & math mode. \\ \hline
	Each column alignment & must be & indicated. \\ \hline
	\texttt{l} = left-justified & & \\ \hline
	& \texttt{c} = centered & \\ \hline
	& & \texttt{r} = right-justified \\ \hline
\end{tabular}

\newpage
\section{Math} \label{sec:math}
Mathematical text is said to be in math mode. 
\subsection{Formatting Math} \label{subsec:formatting-math}
$Math mode is italicized by default$. \\
This will produce $\text{regular text with whitespace.}$ \\
This will produce $\textbf{bold text with whitespace.}$ \\
This will produce $\textit{italicized text with whitespace.}$ \\
This will produce $\textsc{small caps text with whitespace.}$ \\
This will produce $\mathbf{boldface math without whitespace}$.\footnote{
	See Notation 7 for a possible alternative.
} \\
This will produce $\mathrm{roman (nonitalicized\ serif\ font) text without whitespace}$. 

\begin{theorem*}[Commands \& Trouble-Shooting]
	Regarding \LaTeX\ commands, there is plenty of information at your disposal on the internet. You will likely be able to solve most of the problems you encounter and find commands and packages you need by searching for them on the internet. 
\end{theorem*}
\begin{proof}
	Search for a list of commands such as \href{https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols}{this} or \href{http://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf}{this}. Search for a package that suites your needs. Search for the error your compiler is giving. Stack Exchange, Overleaf, and Wikibooks are fantastic resources. \par
	Under the \LaTeX\ menu on the left sidebar in VS Code, there are two Snippet panels with a myriad of symbols to browse through. Relying on these menus is ill-advised, but being aware of them may still be worthwhile. Here are just a few commands worth noting: 
	\begin{enumerate}
		\item[1.]
		$\sin\theta_1 = \cos\theta_2 = \max\{0,1\} = \min\{1,2\} = 3 \bmod 2 = \sqrt[4]{1} = \pm 1$

		\item[2.]
		$\exists \ell \in \cap_{i=1}^n A_i$ such that $f \circ g(\ell) = \gcd(7,\ell) = \mathrm{lcm}(7,\ell) = 10 = \underbrace{1 + \cdots + 1}_{10 \tms}$

		\item[3.]
		\begin{enumerate}
			\item% a 
			$\dim V = \mathrm{rank}(T) + \dim\mathrm{Null}(T)$, where $T \in \mathcal{L}(V,W)$

			\item% b
			$|\mathcal{P}(S)| = 2^{|S|}$
		\end{enumerate}

		\item[4.]
		$\mathscr{L}\{f(t - a)\mathscr{U}(t - a)\}=e^{-as}F(s)$ % mathrsfs package

		\item[5.]
		$\mseti{x_n}{n}{1} \subset \R$ is such that $\inf x_n \le \sup x_n$ and $\liminf x_n \le \limsup x_n$. \qedhere % forcing the \qedsymbol to appear in the display
	\end{enumerate}
\end{proof}

\begin{notation}
	\texttt{\{\dots\}} are required around subscripts and superscripts with more than one character (except for commands such as $\infty$, greek letters, etc.)  
\end{notation}

\begin{claim*}
	The statement $x_m^{n+1} +     x_{m+1}^n     \approx 2^\pi \not< 8 \le 2^\infty$ is 
	\begin{enumerate}
		\item
			in inline math mode and 
		\item
			has none of the extra white-space from the code. 
	\end{enumerate}
\end{claim*}
\begin{proof}[Proof of (1)]
	Since blah blah blah, we have blah blee blah, which gives hm hm hm, blah blah. Hence, bloo blah blee bloo. Therefore, the statement is in inline math mode. 
	\renewcommand{\qedsymbol}{}
\end{proof}
\begin{proof}[Proof of (2)]
	Note that we temporarily changed the \texttt{\textbackslash qedsymbol} in the previous \texttt{proof} environment so that it wouldn't show up twice. Also, note that we can change the title of any environment with brackets. 
\end{proof}

\begin{proposition*}[Display-Math Mode]
	The summation
	\[
		\sum_{i=1}^n i^2 = \f{n(n+1)(2n+1)}{6} \in \Theta(n^3)
	\]
	is in display-math mode. Note that the first letters of commands for capital Greek letters are capitalized and that there are some lowercase Greek letters with variations whose commands begin with \textnormal{\texttt{var}}, such as $\varphi$ and $\varepsilon$. 
\end{proposition*}
\begin{proof}
	Omitted
\end{proof}

\begin{corollary*}[\texttt{equation} \& \texttt{multline}]
	The equations 
	\begin{equation}
		\IV{I} = \sqrt{I}
	\end{equation}
	and 
	\begin{multline}
		f_x = 3x^2y^4 + 6xy^5 + 3y^6 - 8x^3y^2 - 18x^2y^3 - 12xy^4 - 2y^5 \\
		+ 5x^4 + 12x^3y + 9x^2y^2 + 2xy^3
	\end{multline}
	are respectively in the \textnormal{\texttt{equation}} and \textnormal{\texttt{multline}} environments, which number single lines of display-math. The \textnormal{\texttt{multline}} environment is useful for splitting single lines. 
\end{corollary*}
\begin{proof}
	Omitted
\end{proof}

\begin{notation}[Extensible Block Delimiters]
	The commands \texttt{\textbackslash left} and \texttt{\textbackslash right} resize the succeeding character to fit whatever's between them. The null delimiters \texttt{\textbackslash left.} and \texttt{\textbackslash right.} respectively leave the left and right character blank, but there must be both a \texttt{\textbackslash left}\option{something} and a \texttt{\textbackslash right}\option{something}. Note that we can create extensible angle brackets with $\texttt{\textbackslash left<}$ and $\texttt{\textbackslash right>}$: 
	\[
		\left<\f{x}{2},\f{y}{2}\right> = 
		\set*{h_1\left(\f{x}{2}\right) + h_2\left(\f{y}{2}\right) \Mid h_1,h_2 \in \F[x_1,\dots,x_n]}. 
	\]
\end{notation}

\begin{notation}[Punctuation]
	When display-math mode ends a phrase, the punctuation \textit{must} be inside the display. For instance, it is true that 
	\[
		(0,1) = \bigcup_{n=1}^\infty \mpar{0 + \f{1}{n}, 1 - \f{1}{n}} \neq \varnothing, 
	\]
	but it may be true that $\gamma \in \Q$ or that $\gamma \notin \Q$. Hence, we may write $\gamma \stackrel{?}\in \Q$. 
\end{notation}

\begin{notation}[Readability]
	Separate long strings of equalities over several lines of code. It's better to write 
	\begin{verbatim}
		15
		= 10 + 5
		= 3 + 7 + 5
		= 1 + 2 + 3 + 4 + 5
	\end{verbatim}
rather than 
\begin{verbatim}
	15 = 10 + 5 = 3 + 7 + 5 = 1 + 2 + 3 + 4 + 5
\end{verbatim}
\end{notation}

\begin{notation}[Such That]
	There are two ways to say ``such that''	in a set definition. If $I,J \subseteq \F[x_1,\dots,x_n]$ are ideals, where $\F$ is a field, then 
	\[
		\sqrt{I} = \{f \in \F[x_1,\dots,x_n] : f^m \in I \fs m \in \N\}, 
	\]
	and 
	\[
		I:J = \{f \in \F[x_1,\dots,x_n] \mid fg \in I \fa g \in J\}.\footnote{
			This is not the $\vert$ character on your keyboard. It's \texttt{\textbackslash mid}. Also, note the use of \texttt{\textbackslash set} and the extensible \texttt{\textbackslash Mid} in Notation 2 above. 
		}
	\]
\end{notation}

\begin{notation}[Forcing Display-Math]
	Various notations get scrunched up in inline math: 
	$\sum_{i=1}^n$, 
	$\prod_{i=1}^n$, 
	$\bigcap_{i=1}^n$, 
	$\bigcup_{i=1}^n$, 
	$\lim_{n \to \infty}$, 
	$\sup_n (b_n)$, 
	$\int_a^b$, 
	$\max_n\{\delta_n\}$, etc. \par
	We can often override this by putting \texttt{\textbackslash limits}
	after each command.
	So, we can write 
	$\sum\limits_{i=1}^n$, 
	$\prod\limits_{i=1}^n$, 
	$\bigcap\limits_{i=1}^n$, 
	$\bigcup\limits_{i=1}^n$, 
	$\lim\limits_{n \to \infty}$,  
	$\sup\limits_n(b_n)$, 
	$\max\limits_n\{\delta_n\}$. \par
	Integrals can be put in \texttt{\textbackslash displaystyle}: $\dint{a}{b}$, but \texttt{\textbackslash limits} does provide an alternative way of writing them: $\int\limits_a^b$. \par
	This is not necessary when these are being displayed, except for \texttt{\textbackslash int\textbackslash limits}. 
	\[
		\sum_{i=1}^n,~ 
		\prod_{i=1}^n,~ 
		\bigcap_{i=1}^n,~ 
		\bigcup_{i=1}^n,~
		\lim_{n \to \infty},~
		\sup_n(b_n),~
		\max_n\{\delta_n\},~
		\int_a^b, \et
		 \int\limits_a^b
	\]
\end{notation}

\begin{notation}[Bold Math Symbols]
	In math mode, mathematical symbols will not be affected by \texttt{\textbackslash mathbf\{\}}, as in $\mathbf{\sin\pi \notin \{1, 2, 3\}}$. To remedy this, use \texttt{\textbackslash boldsymbol\{\}} as in $\boldsymbol{\sin\pi \notin \{1, 2, 3\}}$. \par
	When nesting block delimiters inside of each other, it is often beneficial to use an abbreviation of \texttt{\textbackslash boldsymbol} to bold the outer delimiters. For instance, $g^{-1}\bs((c,d)\bs)$ is a little better than $g^{-1}((c,d))$. 
\end{notation}

\subsection{Displaying Multiple Lines of Math} \label{subsec:multiple-lines}
There are several ways to display multiple lines of math. Some environments have predefined numbering. Add a \texttt{*} when you \texttt{begin} and \texttt{end} the environment to remove numbering. Note that \texttt{\textbackslash\textbackslash} creates a new row. 

\subsubsection{\texttt{gather}} \label{subsubsec:gather}
The \texttt{gather} environment is like a multiline \texttt{center} environment that is in math mode by default. Let $V_1,\dots,V_n \subseteq \F^n$ be varieties, where $\F$ is a field. Then, 
\begin{gather}
	\varnothing \subseteq V_1 \subseteq \cdots \subseteq V_n \\
	\Rightarrow \mathbf{I}(\varnothing) \supseteq \mathbf{I}(V_1) \supseteq \cdots \supseteq \mathbf{I}(V_n) \\
	\text{(toggle individual line numbers with \texttt{\textbackslash notag})} \notag \\
	\Rightarrow \mathbf{V}(\mathbf{I}(\varnothing)) \subseteq \mathbf{V}(\mathbf{I}(V_1)) \subseteq \cdots \subseteq \mathbf{V}(\mathbf{I}(V_n)) \\
	\Rightarrow \varnothing = \ol{\varnothing} \subseteq \ol{V_1} \subseteq \cdots \subseteq \ol{V_n}. 
\end{gather}
\begin{notation}[Dots]
	The command \texttt{\textbackslash ldots} produces ellipses at the bottom of the line, and \texttt{\textbackslash cdots} produces ellipses in the middle of the line. \par
	The command \texttt{\textbackslash dots} is supposed to be able to tell the difference between cases that require lower dots and cases that require center dots. There are a few instances where it doesn't get it right, but I tend to use both \texttt{\textbackslash cdots} and \texttt{\textbackslash dots}. See \S\ref{subsubsec:matrices} for an example of when \texttt{\textbackslash dots} doesn't work properly. \par
	Both \texttt{\textbackslash ldots} and \texttt{\textbackslash dots} work in paragraph and math mode, but \texttt{\textbackslash cdots} only works in math mode. 
\end{notation}

\subsubsection{\texttt{align} \& \texttt{alignat}
} \label{subsubsec:align}
The \texttt{align} and \texttt{alignat} environments are in math mode by default. 
In the \texttt{align} environment, \texttt{\&} indicates an alignment.
\begin{align*}
	f'(x) = \int f''(x)\dx % extra space before dx
	= \iint f'''(x)\dx dx 
	= \iiint f^{(4)}(x)\dx dxdx
	&= \f{d}{dx} f(x) \\
	&= \f{d^2}{dx^2} \int f(x)\dx \\
	&= \f{\del}{\del x} f(x)\dx
\end{align*}
\begin{align*}
	A &= \{x \in S \mid n_a(x) \ge 1\} &\ol A &= \{x \in S \mid n_a(x) = 0\} \\
	B &= \{x \in S \mid n_b(x) \ge 2\} &\ol B &= \{x \in S \mid n_b(x) < 2\}
\end{align*}
In the \texttt{alignat} environment, the number of alignments must be indicated, and every alignment past the first requires two \texttt{\&}'s. 
\begin{alignat*}{2}
	|\ol{A_1} \cap \ol{A_2}| 
	&= |S| &&- |A_1| - |A_2| \\
	& 	   &&+ |A_1 \cap A_2| \\
	&= 10  &&- 1 - 2 \\
	& 	   &&+ 3 \\
	&= 10
\end{alignat*}

\subsubsection{\texttt{array}} \label{subsubsec:array}
Math mode must be specified for arrays. \\
\texttt{l} = left-justified
\[
	\begin{array}{l} 
		(\forall r > 0)(\exists q \neq p)[q \in B(p,r) \cap E] \\
		\Rightarrow p \in E'
	\end{array}
\]
\texttt{c} = centered
\[
	\begin{array}{c}
		(\forall r > 0)(\exists q \neq p)[q \in B(p,r) \cap E] \\
		\Rightarrow p \in E'
	\end{array}
\]
\texttt{r} = right-justified
\[
	\begin{array}{r}
		(\forall r > 0)(\exists q \neq p)[q \in B(p,r) \cap E] \\
		\Rightarrow p \in E'
	\end{array}
\]
Arrays may also be used to display charts in math mode, and can be nested inside other arrays. For example, the Invisible Hand game $G_1$ and the Prisoner's Dilemma $G_2$ are two arrays inside of another array. 
\[
	\begin{array}{lr}
		\begin{array}{|c||c|c|}
			\hline
			G_1 & A & B \\ \hline\hline
			A & \mathbf{8},\mathbf{8} & \mathbf{6},6 \\ \hline
			B & 6,\mathbf{6} & 2,2 \\ \hline
		\end{array}
		&
		\begin{array}{|c||c|c|}
			\hline
			G_2 & A & B \\ \hline\hline
			A & 3,3 & 1, \mathbf{5} \\ \hline
			B & \mathbf{5},1 & \mathbf{2},\mathbf{2} \\ \hline
		\end{array}
	\end{array}
\]

\subsubsection{Matrices} \label{subsubsec:matrices}
Math mode must be specified for matrices. 
\begin{gather*}
	\begin{bmatrix}
		2 & 2 \\
		0 & 1
	\end{bmatrix}
	\xrightarrow{r_1 \mapsto \f{1}{2}r_1} % stretches the arrow to fit what's on it
	\begin{bmatrix}
		1 & 1 \\
		0 & 1
	\end{bmatrix}
	\xrightarrow{r_1 \mapsto -r_2 + r_1}
	\begin{bmatrix}
		1 & 0 \\
		0 & 1
	\end{bmatrix}
	\\
	\begin{pmatrix}
		2 & 2 \\
		0 & 1
	\end{pmatrix}
	\sim
	\begin{pmatrix}
		1 & 1 \\
		0 & 1
	\end{pmatrix}
	\sim
	\begin{pmatrix}
		1 & 0 \\
		0 & 1
	\end{pmatrix}
	\\
	\begin{vmatrix}
		a & b \\
		c & d
	\end{vmatrix}
	= ad-bc
\end{gather*}

Use the \texttt{array} environment to separate rows and columns in a matrix. 
\[
	[A \mid I_2] = 
	\left[
		\begin{array}{cc|cc}
			1 & 2 & 1 & 0 \\
			3 & 4 & 0 & 1
		\end{array}
	\right]
	\qquad
	\left[
		\begin{array}{c|c}
			a & b \\ \hline
			c & d
		\end{array}
	\right]
\]

Use $\cdots$, $\vdots$, and $\ddots$ to apostrophize matrix entries. Note that I made a command that rotates $\ddots$ to my liking and that \texttt{\textbackslash dots} doesn't know that it should be displaying \texttt{\textbackslash cdots}. 
\[
	\begin{bmatrix}
		\sigma_1 & 0 & \dots & & \cdots & 0 & \dots & 0 \\
		0 & \ddots & & & & \vdots & & \vdots \\
		\vdots & & \sigma_r & & & & \sddots &  \\
		0 & & & 0 & & \vdots & & \vdots \\
		0 & 0 & \dots & & \ddots & 0 & \dots & 0 
	\end{bmatrix}
\]

The \texttt{kbordermatrix} package displays matrices with row and column labels. Set the delimiters \texttt{\textbackslash kbldelim} and \texttt{\textbackslash kbrdelim} in the preamble. See line \texttt{12}. 
\[
	\kbordermatrix
	{
		  & a & b \\
		a & 1 & 0 \\
		b & 0 & 1 \\
	}
\]

\subsubsection{\texttt{cases}} \label{subsubsec:cases}
\begin{definition*}
	Let $X$ be an infinite set. Then, $d:X \times X \to \{0,1\}$ defined by 
	\[
		d(p,q) = 
		\begin{cases}
			1, & p \neq q \\
			0, & p = q
		\end{cases}
	\]
	is formatted with the \texttt{cases} environment, which requires math mode. Either $(p,q) \mapsto 0$ or $(p,q) \mapsto 1 \fa (p,q) \in X \times X$, and $d(p,q) = 0 \iff p = q$. 
\end{definition*}

\subsection{Escape Sequences and White-space in Math Mode} \label{subsec:escape}
Use \textbackslash \ to insert characters that would otherwise be used in \LaTeX\ syntax. Some examples are \_, \%, \#, \$, \{, \}, and similarly, \texttt{\textbackslash lbrack} and \texttt{\textbackslash rbrack}. \par
Additionally, there are various ways to insert a space in math mode (but some of these may also be used in paragraph mode.) 
\[
	\begin{array}{||l||c||c||}
	\hline \text{\texttt{\textbackslash !} (negative thin)} & \phi(x) \!\forall x & \rightarrow\!\leftarrow \\ \hline\hline
	\text{(normal)} & \phi(x) \forall x & \rightarrow\leftarrow \\ \hline\hline
	\texttt{\textbackslash ,} & \phi(x)\,\forall x & \rightarrow\,\leftarrow \\ \hline
	\text{\textbackslash :} & \phi(x)\:\forall x & \rightarrow\:\leftarrow \\ \hline
	\texttt{\textbackslash ;} & \phi(x)\;\forall x & \rightarrow\;\leftarrow \\ \hline
	\text{\texttt{\textbackslash} (slash space)} & \phi(x)\ \forall x & \rightarrow \ \leftarrow\\ \hline
	\sim \text{ (tilde)} & \phi(x)~\forall x & \rightarrow~\leftarrow \\ \hline
	\texttt{\textbackslash quad} & \phi(x) \quad \forall x & \rightarrow \quad \leftarrow \\ \hline
	\texttt{\textbackslash qquad} & \phi(x) \qquad \forall x & \rightarrow \qquad \leftarrow \\ \hline
	\end{array}
\]
Tildes are an example of unbreakable space, meaning the adjacent strings won't be separated over line breaks.\footnote{
	Note that, for unknown reasons, the two tildes above didn't produce the same space, so tildes are perhaps unreliable. 
} 
E.g.,\\
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string1~string2 \par
Rather than printing \hspace*{\fill} string1 \\
string2, \\
it keeps the two strings on the same line. If we remove the space between the last dash and string1, both strings will move to the previous line. This could be useful for keeping inline mathematical statements together; it may sometimes be difficult to read a formula broken up over two lines. \par
Tildes are unbreakable in math mode and in paragraph mode. Some other options here are only unbreakable in paragraph mode; e.g., (\texttt{\textbackslash ,}), (\texttt{\textbackslash :}), and (\texttt{\textbackslash ;}). 

\section{Macros} \label{sec:macros}
The syntax \texttt{\textbackslash newcommand\{\textbackslash macroname\}\{}\option{definition}\texttt{\}} creates a macro instruction invoked with \texttt{\textbackslash macroname} that inserts the \option{definition}\footnote{
	Macros can either be written on one line for potentially faster compile times or left in a readable format, but compile times won't be much faster in the former case since \LaTeX\ Workshop keeps auxiliary files. The first compilation is long, but subsequent compilations are quick because most of the compilation is already done. Hence, saving memory by reducing the number of tokens isn't very important since most of those tokens aren't recompiled. In the latter case, it's good practice to put \texttt{\%}'s at the end of most lines to prevent whitespace created by \texttt{EOL} (end of line) characters. FYI: 2 \texttt{EOL} = empty line in code = \texttt{\textbackslash par}. 
} 
wherever \texttt{\textbackslash macroname} appears. 
The syntax \texttt{\textbackslash newcommand*\{\textbackslash macroname\}[n]\{}\option{definition}\texttt{\}}\footnote{
	\texttt{*} creates a ``short'' command that invokes error messages if the \option{definition} is broken up over paragraphs (\texttt{\textbackslash par} or an empty line). The utility here is that this will also make your compiler tell you the line number if you leave an opening brace unclosed. 
}
is invoked with \texttt{n} arguments $\mathit{\langle a_1 \rangle,\dots,\langle a_n \rangle}$ as $\mathtt{\texttt{\textbackslash} macroname\{\langle\mathit{a_1}\rangle\} \cdots \{\langle\mathit{a_n}\rangle\}}$. 
In the \option{definition}, \texttt{\#i} indicates where the \texttt{i}-th argument \option{$a_i$} will be placed, and \texttt{\textbackslash hfill} inserts white-space until a space---the space in a matrix entry, for instance---is filled. 
\[
	\begin{array}{c|c|c|c|c}
		\fivevec{1}{2}{333}{44500}{5} &
		\threevecc{9}{77}{3008} &
		\fourrowvec{a}{b}{c}{d} &
		\fivetuple{1}{2}{3}{4}{5} &
		\ntuple{a}{n} \\
		 & & & & \\ \hline
		 & & & & \\
		\twobytwo{a}{b}{c}{d} &
		\threebythree{1}{2}{3}{4}{5}{6}{7}{8}{9} &
		\threebythreev{1}{0}{0}{0}{1}{0}{0}{0}{1} &
		\augthree{u_1}{u_2}{u_3} &
		\fourvectorchline{v_1^T}{v_2^T}{v_3^T}{v_4^T}
	\end{array}
\]

In general, it's good to reduce the number of keys you have to press as much as possible; however, VS Code's autocompletion already allows us to avoid typing many things. Thus, the benefit of shortening some commands with macros may merely be that it makes our code more concise, but this depends on personal preference. For instance, you may not care whether your code is populated with the few extra letters in \texttt{\textbackslash mathbf} as opposed to those in \texttt{\textbackslash mbf}. 

\subsection{Troubleshooting with \texttt{\textbackslash end\{document\}}} \label{subsec:errors}
One way to locate elusive errors is to put an \texttt{\textbackslash end\{document\}} right in the middle of the document. If the error goes away, it was in the portion of the document you cut off. Move the command up or down and repeat until you've found the error. In such a scenario it helps to have a command \texttt{\textbackslash ed} to do this testing. 

\section{Packages} \label{sec:packages}
Packages provide commands for doing various typesetting tasks. For example, the \texttt{units} package allows us to write $\nicefrac{a}{b}$ instead of $\frac{a}{b}$ and the \texttt{xcolor} package allows us to \colorbox{yellow}{highlight} things. MiKTeX can install packages so that we don't have to deal with \texttt{sty} (style) files. It should do this automatically.\footnote{
	In other words, it should do this ``on the fly.'' \par
	If not, once you've downloaded a package from \href{https://ctan.org/}{CTAN}, it should contain some \texttt{sty} files, in which case you should follow the steps laid out it \S\ref{subsec:installing-packages}. \par
	If instead of \texttt{sty} files there are \texttt{ins} (installation) files, you must run those \texttt{ins} files to produce the required \texttt{sty} files. The simplest way to do this is to open the \texttt{ins} file in your editor and compile it as you would a \texttt{tex} file. \par
	When all else fails, the makeshift way to use a package is to copy its \texttt{sty} files directly to the folder containing your \texttt{tex} file. 
}

\subsection{Creating and Manually Installing Packages} \label{subsec:installing-packages}
Macros should be written in a separate file and added to the beginning of your document. The most prudent way to do this is to create a package by giving it the \texttt{.sty} file extension and putting these two lines at the beginning: \\

\texttt{\textbackslash NeedsTeXFormat\{LaTeX2e\}} \par
\texttt{\textbackslash ProvidesPackage\{}\option{package-name}\texttt{\}} \\

Create a folder named \option{package-name} containing the file. In MiKTeX Console, go to \texttt{Settings -> Directories}. Select the \textbf{Install} directory and open it with the square button.\footnote{
	An ignominious design flaw of MiKTeX is that it creates a file \texttt{miktex-console.lock} under \texttt{C:\textbackslash Users\textbackslash$<$user\_name$>$} that prevents MiKTeX Console from opening initially. Simply delete this file and this problem shouldn't persist. 
}
\begin{center}
	\includegraphics[width=0.8\textwidth]{directories}
\end{center}
On macOS, this directory will be 
\begin{verbatim}
	/Users/<user_name>/Library/Application Support/MiKTeX/texmfs/install
\end{verbatim}
Then, place the \option{package-name} folder under \texttt{tex -> latex}, and under \texttt{Tasks} on the menubar, select \textbf{Refresh file name database}. You should now be able to use commands from \option{package-name} in any \texttt{tex} file without having to put the \texttt{sty} file in the same location. \p
It would be wise to pin the file or folder containing your commands to VS Code's icon and the File Explorer icon on your taskbar for easy access. 

\subsection{Images: \texttt{graphicx}} \label{subsec:images}
A picture of black writing on a whiteboard with the \textbf{shadows}, \textbf{contrast}, and \textbf{brightness} maximized, the \textbf{saturation} minimized, and possibly some other settings adjusted as needed---such as increasing the \textbf{brilliance} or slightly increasing the \textbf{exposure}---often gives an image whose white background nearly matches the white page and whose black writing nearly matches the black print. 
\begin{center}
	\includegraphics[scale=0.15]{whiteboard}
\end{center}
Use the \texttt{center} environment or \texttt{\textbackslash centering} if it's in a \texttt{figure} environment.\footnote{
	For subfigures, consider using the \texttt{subfigure} environment from the \texttt{subcaption} package. 
}\textsuperscript{,}\footnote{
	The option \texttt{[h]} stands for ``here'' and indicates that we want the figure to be placed exactly where it is in the code. Sometimes this is not enough, and stronger options are required. Ordered by strength, these are \texttt{[h] $<$ [!h] $<$ [H]}, where \texttt{H} comes from the \texttt{float} package.
}
\begin{figure}[H]
	\centering
	\includegraphics[width=0.6\textwidth]{triangle_figure}
	\caption{$\tr ABC$}
\end{figure}
\noindent
Set the path to the folder with your images with \texttt{\textbackslash graphicspath\{\{}\option{path}\texttt{\}\}}. \\
The file extensions of the images aren't required. \\
The \texttt{graphicx} package allows us to easily size images with \texttt{scale}, \texttt{width}, or \texttt{height}. Compare the options of the two images above. 

\subsection{Diagrams: PGF/Ti\textit{k}Z} \label{subsec:graphics}
The \texttt{pgf} and \texttt{tikz} packages provide a very complex set of commands to draw shapes, graphs, and intricate diagrams straight into the document. 
You will probably never need to use them, but as before, your best resource for learning PGF/Ti\textit{k}Z is the internet, so look for a some tutorials that might be helpful such as \href{https://www.overleaf.com/learn/latex/LaTeX_Graphics_using_TikZ:_A_Tutorial_for_Beginners_(Part_1)%E2%80%94Basic_Drawing}{this}. \par
Many packages build off of Ti\textit{k}Z so that we can use it for specific tasks without doing all the work. For examples, there are the \href{https://www.overleaf.com/learn/latex/Feynman_diagrams}{\texttt{tikz-feynman}} and \href{https://ctan.org/pkg/tikzducks}{\texttt{tikzducks}} packages. \par
Note that in the \LaTeX\ menu on the left sidebar in VS Code, under the same Snippet panels mentioned in \S\ref{subsec:formatting-math}, there are Ti\textit{k}Z panels that offer the opportunity to play around with various features from PGF/Ti\textit{k}Z. 

\subsection{Poetry in \LaTeX} \label{subsec:poetry}
The \texttt{verse} package allows us to typeset poetry in \LaTeX. See \texttt{other sample files -> verse}. 
\end{document}