An Introduction to L A TEX Ryan C. Trinity University Math Majors Seminar September 12, 2017
What is L A TEX? L A TEX is a typesetting system/language used for the production of technical (mathematical) documentation. In mathematics, statistics, computer science, engineering, chemistry, physics, economics, quantitative psychology, philosophy, and political science, L A TEX is the standard for the preparation of presentations, publications, and other documents. Unlike WYSIWYG word processors like Microsoft Word, L A TEX uses source files (.tex files) written in specialized syntax that are then translated by a L A TEX compiler into output documents (e.g..pdf or.dvi files) suitable for publication. Complicated technical documents are much more easily produced using L A TEX than a traditional word processor.
Obtaining L A TEX L A TEX source files can be created using any text editor. MiKTeX and TeX Live are L A TEX compilers freely available online. There are also combined editor/compiler packages available: TeXShop and MacTeX for OS X, or protext for Windows can be downloaded for free. Latexian for OS X, or WinEdt for Windows can be purchased for a small fee. For the price of an email address, an online editor/compiler is available through www.overleaf.com.
A simple document After logging in to overleaf.com, click on choose the Blank Paper template. and You ll then see the following code in the left-hand pane of your window: \documentclass{article} \usepackage[utf8]{inputenc} \begin{document} (Type your content here.) \end{document} A typeset version of this source code appears in the right-hand pane.
Entering mathematical expressions Inline mathematical expressions are enclosed by a pair of $. Let (G, ) be a group. Let $(G, \ast)$ be a group. Suppose that f (x) = e 3x x 2 + 3. Suppose that $f(x) = e^{3x} - x^2 + 3$. We claim that x n 0 as n. We claim that $x_n \to 0$ as $n \to \infty$. For any v R n, v, v 0. For any $\mathbf{v} \in \mathbb{r}^n$, $\langle \mathbf{v}, \mathbf{v} \rangle \ge 0$.
Remarks on math mode Macros and special characters have the form \symbolname. Whitespace is ignored. Curly braces {..} are used to group symbols, and are not typeset. The arguments to superscripts (^), subscripts (_) and other commands should be enclosed in curly braces: e^2x yields e 2 x e^{2x} yields e 2x
To display curly braces, use \{ and \}: $A = { (x,y) e^{xy} = 1 }$ yields A = (x, y) e xy = 1 $A = \{ (x,y) e^{xy} = 1 \}$ yields A = {(x, y) e xy = 1} To insert text in math mode, use \text or \mbox: $E = \{ n \in \mathbb{z} \, \, n \text{ is even} \}$ yields E = {n Z n is even}
Common symbols and functions The greek alphabet: $\alpha, \beta, \gamma, \Gamma, \delta, \Delta$ α, β, γ, Γ, δ, Special functions: $\sin x, \cos x, \log x, \sqrt{x}, \sqrt[n]{x}$ sin x, cos x, log x, x, n x Ellipsis: $a_1, a_2, \ldots, a_n$ a 1, a 2,..., a n
Large symbols Expressions including summations, fractions, integrals, etc. can look uncomfortable when typeset inline. $\sum_{n=1}^{\infty} \frac{1}{n^2}=\frac{\pi^2}{6}$ yields n=1 1 n 2 = π2 6. And $\int_{-2}^{10} \frac{x^3}{5} dx$ yields 10 x 3 2 5 dx. There are two ways around this. Option 1: Use display mode by enclosing expressions between \[ and \]. Option 2: Use \displaystyle.
An equation in display mode: \[ \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}. \] An equation in display mode: n=1 1 n 2 = π2 6. A large inline expression: $\displaystyle \int_{-2}^{10} \frac{x^3}{5} dx$. 10 x 3 A large inline expression: 5 dx. 2
Templates There s no need to start a document from scratch every time: it s usually more efficient to modify an existing file. overleaf.com offers a number of document templates and examples of papers, presentations, etc. Your professors probably have templates or sample.tex files they may be willing to share... Today we will be using the file in-class.tex.
Uploading a project to overleaf.com Download the file in-class.zip from Dr. s website: http://gotu.us/drgq2 From the My Projects page on overleaf.com, click the upload button (next to ) and select Upload Zip from the drop down menu. Locate in-class.zip and drag it into the pop-up window (or click the Choose File button to do it the old fashioned way). After a few moments, the editing (left) and preview (right) panes should open automatically.
In-class exercises After changing the author s name to your own, scroll to the appropriate regions and code the following: (a) f (x) = 3 x 3 + 1 $f(x) = \sqrt[3]{x^3 + 1}$ (b) dy dx = tan x + x 4/3 $\displaystyle \frac{dy}{dx} = \tan x + x^{4/3}$
(c) Γ(s) = 0 e x x s 1 dx $\displaystyle \Gamma(s) = \int_0^{\infty} e^{-x} x^{s-1} \, dx$
Parentheses Consider the expression ( x 2 + y 3 ) 2. \[ \frac{x}{2} + \frac{y}{2} )^2 \] yields ( x 2 + y 2 )2, which is clearly unsatisfactory. Use \left and \right to scale parentheses (and other delimiters): \[ \left( \frac{x}{2} + \frac{y}{3} \right)^2 \]
Matrices A matrix can be built using the array environment. \[ \left( \begin{array}{cc} 0 & 1 \\ 1 & -q \end{array} \right) \] yields ( 0 1 1 q ) The & is an alignment tab, and \\ indicates the end of a row.
Another exercise Code the following [ 1 2 3 A = 0 0 a 23 ] \[ A = \left[ \begin{array}{ccc} 1 & 2 & -3 \\ 0 & 0 & a_{23} \end{array} \right] \]
Theorem environments Theorem (Bézout s Identity) Let m, n Z. There exist r, s Z so that gcd(m, n) = rm + sn. \begin{thm}[b\ ezout s Identity] Let $m, n \in \mathbb{z}$. There exist $r,s \in \mathbb{z}$ so that \[ \gcd(m,n) = rm+sn. \] \end{thm}
Another exercise Code the following. Theorem (Triangle Inequality) For any a, b C, we have a + b a + b. \begin{thm}[triangle Inequality] For any $a,b \in \mathbb{c}$, we have $ a+b \le a + b $. \end{thm}
Inserting figures Here s a figure: Figure: A surface in R 3 \begin{figure} \includegraphics[width=1.5in]{mountain_pass.eps} \caption{a surface in $\mathbb{r}^3$} \end{figure}
Final exercise Use the file dirichlet.eps to produce the following output. Δ 2u= 0 ux,y ( )=f( x,y) Figure: A generic Dirichlet problem in R 2 \begin{figure} \includegraphics[width=2in]{dirichlet.eps} \caption{a generic Dirichlet problem in $\mathbb{r}^2$} \end{figure}
Multiline equations The split environment is one way to align multiple display mode equations. x 3 1 x 1 = (x 1)(x 2 + x + 1) x 1 = x 2 + x + 1 \[ \begin{split} \frac{x^3-1}{x-1} &= \frac{(x-1)(x^2 + x + 1)}{x-1} \\ &= x^2 + x + 1 \end{split} \]
Equation references Suppose we d like to number and later refer to an inset equation. g(n) = d n f (d) (1) Here s a reference to equation (1). \begin{equation}\label{divisorsum} g(n) = \sum_{d n} f(d) \end{equation} Here s a reference to equation \eqref{divisorsum}.
L A TEX automatically keeps track of and increments equation labels. If g is defined by (1) then f (n) = d n µ(d)g ( n d ). (2) Equation (2) is called the Möbius inversion formula. If $g$ is defined by \eqref{divisorsum} then \begin{equation}\label{inversion} f(n) = \sum_{d n} \mu(d) g\left( \frac{n}{d} \right). \end{equation} Equation \eqref{inversion} is called the \em{m\"{o}bius inversion formula.}
Beamer Beamer is a L A TEX document style used to create presentations. Each slide is enclosed by \begin{frame} and \end{frame}. Items can be subsequently revealed on a slide in various ways, e.g. \pause, \onslide, \only, etc. One can also easily include figures using \includegraphics.
Sample beamer slide with a subtitle This is a slide. First item Second item
Sample slide code \begin{frame} \frametitle{sample beamer slide} \framesubtitle{with a subtitle} This is a slide. \pause \begin{itemize} \item First item \pause \item Second item \end{itemize} \end{frame}
Need more help? We ve only scratched the surface of L A TEX s capabilities. If you need additional help: Online: try googling latex (command name). In person: ask your peers or any math professor! Anything you re trying to do with L A TEX someone else has probably already done. Don t reinvent the wheel!