\documentclass[]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{hyperref}
\setcounter{section}{-1}
\lstset{
language=TeX,
basicstyle=\ttfamily
}
%opening
\title{Berkeley Splash | \LaTeX{} for Dummies}
\author{Bryan Ngo}
\date{2019-11-02}
\begin{document}
\maketitle
\section{Why \LaTeX{}?}
\LaTeX{} is one of the most powerful typesetting programs in the world.
One of the main differences between \LaTeX{} and more mainstream word processors is that it is \emph{not} WYSIWYG\footnote{What You See Is What You Get}, or the assumption that whatever the user sees on their screen is exactly what the document looks like in real life.
\LaTeX{}, on the other hand, is quite the opposite.
Typesetting on \LaTeX{} is more like "coding" a document, with the user having to repeatedly compile their document.
Many of you may be wondering, "Why should I use this instead of MS Word/Google Docs/\{insert word processor here\}?" Well \ldots
\begin{figure}[h!]
\centering
\includegraphics[width=0.8\textwidth]{latex_virgin_chad.png}
\caption{[OC] An extremely nuanced and definitely unbiased comparison of MS Word and \LaTeX{}.}
\label{fig:virgin-chad}
\end{figure}
In all seriousness, if you plan to pursue a career in STEM, especially math or hard science, it's definitely worth getting an early start in learning, as its use is ubiquitous in academia.
Plus, you can flex on all your classmates by doing all your work in \LaTeX{}!
\section{Creating an Overleaf account}
Start by going to \url{https://www.overleaf.com/register} and create an account.
This should bring up the Projects page. \\
\\
In many ways, Overleaf is the Google Docs of \LaTeX{}, with features like collaborative editing and cloud sync.
What's more, it's completely online, so no need to download clunky packages.
\begin{figure}
\centering
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{project_landing.png}
\caption{The landing page for Overleaf.}
\label{fig:project-landing}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{example_doc.png}
\caption{The Overleaf typesetting environment.}
\label{fig:example-doc}
\end{minipage}
\end{figure}
\section{Starting a new document}
All \LaTeX{} documents are derived from this basic template:
\begin{lstlisting}
\documentclass[]{}
% preamble
...
\begin{document}
...
\end{document}
\end{lstlisting}
The \textbf{class} defines how \LaTeX{} decides to format your document.
For example, this document is formatted using the \lstinline|article| class.
This class will be the main focus of today because it serves as a great blank canvas and will be where much of your typesetting happens. \\
\\
That being said, there are a plethora of classes included with Overleaf to mess around with, like \lstinline|moderncv| (for making really nice CVs/resumés) or \lstinline|beamer| (for making slideshows), so go nuts! \\
\\
The section between \lstinline|documentclass[]{}| and \lstinline|\begin{document}| is called the \textbf{preamble}. This will be where you import your packages and options for formatting are typed.
\subsection{Syntax}
Almost all \LaTeX{} commands follow this syntax:
\begin{lstlisting}
\commandname[]{}
\end{lstlisting}
There's the name of the command, options for changing its behavior, and the actual input parameters.
For example, \lstinline|\sqrt{2}| returns \(\sqrt{2}\), while \lstinline|\sqrt[3]{2}| returns \(\sqrt[3]{2}\).
Keep in mind not every command has options or even parameters.
\section{How to import packages}
\LaTeX{} on its own may make beautiful-looking documents, but the real power of the system is its flexibility, specifically the ability to import \textbf{packages}.
Packages are imported in the preamble using the command \lstinline|\usepackage{}|.
If you've ever imported libraries in Python or other programming languages, the mechanism is very much the same.
Some common packages include \href{https://www.ctan.org/pkg/amsmath}{\texttt{amsmath}} (important math tools), \href{https://www.ctan.org/pkg/graphicx}{\texttt{graphicx}} (insert images and figures), and \href{https://www.ctan.org/pkg/tikz}{\texttt{tikz}} (design diagrams right in your document). \\
\\
You'll notice that these link to the CTAN.\footnote{Comprehensive \TeX{} Archive Network}
This is where almost all the \LaTeX{} packages you will ever use are stored.
It's where you will find the documentation for all packages, which you will inevitably read when you don't know what command you want.
\section{Basic math typesetting}
This is probably what you came for. \LaTeX{} is near-ubiquitous in academia and publishing because it typesets math \emph{so} well.
You can guarantee that almost all math textbooks use \LaTeX{}.
Before you even \emph{begin} typesetting math, import \lstinline|amsmath|, \lstinline|amsfonts|, and \lstinline|amssymb|.
Inline math, like \(e^{i \pi} + 1 = 0\), is typeset within \lstinline|\(...\)|. Equations, like
\[\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}\]
are typeset on their own line using \lstinline|\[...\]|.
The \texttt{amsmath} package provides a ton of very useful \textbf{environments}, such as the \lstinline|equation| and \lstinline|align|. Environments are typeset with the syntax
\begin{lstlisting}
\begin{*environment-name*}
...
\end{*environment-name*}
\end{lstlisting}
The \lstinline|equation| environment allows for numbered equations:
\begin{equation}
\iint_{Q} \nabla \times \mathbf{F} \, dS = \oint_{C} \mathbf{F} \cdot d\mathbf{r}
\end{equation}
The \lstinline|align| environment allows for multi-lined equations with line breaks using \lstinline|\\| and alignment character \lstinline|&|:
\begin{align}
2x + 5 &= 6 \\
2x &= 1 \\
x &= \frac{1}{2}
\end{align}
The list of possibilities for math are \emph{way} too long for me to cover here, so take a look at \textit{A Quick Guide to \LaTeX{}} in the class documents for a near-full list.
Some style guide tips and common mistakes:
\begin{itemize}
\item always use \lstinline|\(...\)| and \lstinline|\[...\]| over \lstinline|$...$| and \lstinline|$$...$$|
\item use \lstinline|\sin(x)| instead of \lstinline|sin(x)| when writing trig functions; the difference is pretty clear (\(\sin(x)\) vs. \(sin(x)\))
\item take advantage of spacing; the quick guide gives a list of common spacing commands.
\item try to add spacing between your symbols; this will make things easier for people going through the source later (e.g. \lstinline|e^{i\pi}+1=0| vs. \lstinline|e^{i \pi} + 1 = 0|)
\end{itemize}
\section{Resources for further learning}
\begin{itemize}
\item \href{https://en.wikibooks.org/wiki/LaTeX}{\LaTeX{} Wikibook}: great source of in-depth explanations of packages and environments
\item \href{https://www.overleaf.com/learn}{Overleaf tutorials}: great place for less technically-worded yet useful tutorials
\item \href{https://tex.stackexchange.com/}{\TeX{} StackExchange}: usually the first result for \LaTeX{} questions on Google, great place for answers to quick technical questions
\item \href{https://www.reddit.com/r/LaTeX/}{r/LaTeX}: good place for casual discussion and questions.
\end{itemize}
\end{document}