Writing in $\LaTeX$

$$\int_{0}^{\pi}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx =\frac{22}{7}-\pi$$

tl;dr

$\LaTeX$ is a programming language that outputs beautiful math for documents, like what you see above.
In $\LaTeX$, you type a code that is then compiled and rendered to form a document.

Contents

What is $\LaTeX$?
How do I use $\LaTeX$?
Nice intro, but how do I learn more?
Help!
How do I use $\LaTeX$ elsewhere?
How do I make graphics?
$\mathbf{L}\!{}_{\mathbf{Y}}\!{}\mathbf{X}$

What is $\LaTeX$?

$\LaTeX$ is a programming language. It is typically used for making technical, academic documents with complicated formulas and uncommon symbols or expressions. Most word processors are called "WYSIWYG" (What You See Is What You Get) word processors, that is, you just type stuff and what you see on the screen is what you'll get if you for example, make a pdf of it, print it out. However, $\LaTeX$ is NOT a WYSIWYG word processor! You make a code of what you want the document to show, you run the code, and the output is a pretty document. Coding intimidates most people, but with practice, it becomes pretty straightforward.

How do I use $\LaTeX$?

To use $\LaTeX$, first you have to download an appropriate text editor. There are a bunch of programs that will do it, and I'll leave it up to you to decide what works best on your computer. I use a program called Texmaker that I think is pretty baller, but here is a comparison of them all.

Next, there is some basic syntax that you need to know. Backslash (\) indicates a command. Curly braces ({}) indicate what is contained by the command. Square braces ([]) indicate a property of what is contained by the curly braces. An example is \mathtt{\documentclass[12pt]{article}}. The command is \documentclass, which tells the text editor what kind of document I'm making. Then, I tell it that I'm writing an article with {article}. Then I tell it that the article is in 12pt font using [12pt].

You have to do a couple of things in $\LaTeX$ that you don't really think about when typing in Word, for example, you first have to tell $\LaTeX$ what kind of document you're making (an article, a book, etc.) by saying \documentclass{article} (the most common case), and to start making the document you say $\backslash$begin{document}, and of course, there must be an $\backslash$end{document} as well (in general, every begin command has to have an end command.) More generally speaking, the document formatting properties are placed in the preamble, and then the document is made.

LaTeX code example

In the preamble, you tell the text editor what kind of document you're making, what packages you're using, you give your work a title, you tell it who the authors are, you can do some formatting, and you can even make shortcut commands! Packages allow the use of certain commands or they are used for formatting. For example \usepackage{fullpage} tells the text editor to use the full page when generating the pdf, and \usepackage{graphicx} allows images to be inserted into the document.

With the preamble written, next is the document. When writing a $\LaTeX$ document, there is typically so much math that you can think of $\LaTeX$ as being divided into two separate worlds: a word world and a math world. The word world is pretty simple: just type words like you would anywhere else. However, the math world is a little more complicated.

There are several styles in the math world: in-line, environment, and equations. In-line is where math is inserted in the middle of the text. This is signified in the code by enclosing the mathy stuff in dollar signs. For example, a 2.002 lab report I wrote involved the tensile strength of a material, which I denoted by the lowercase Greek letter sigma and a subscript "TS," so a sample $\LaTeX$ sentence would be : "Blah blah blah words blah blah $\$$ \sigma_{TS} $\$ $ blah blah blah." It's mathy, so it's in dollar signs, I used \sigma to make a sigma symbol, _ to make a subscript, and I enclosed TS in curly braces {}, which results in $\sigma_{TS}$ (note that $\$$ \sigma_TS $\$ $ results in $\sigma_TS$)

Environment is where the math is separate from the text. This is signified in the code by enclosing mathy stuff between $\backslash$[ and $\backslash$]. For example, it can be awkward to put some long formula in-line with text, like $\int_{0}^{\pi}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx =\frac{22}{7}-\pi$. Instead, you can make it stand on its own, like this: $$\int_{0}^{\pi}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx =\frac{22}{7}-\pi$$

To take the ideas of environments a bit further, there is also the equations command. The syntax is $\backslash$begin{equation} and $\backslash$end{equation}. This basically does the same thing as environments, but it also gives the equation a number. When you have several of these equations in your document, it automatically numbers them. This is especially useful in technical papers when there are several important equations to track. Further, you can assign the equation a label. Let's say you're writing a technical paper and you want to say, "…according to equation (6.4), we see that..." With labels, you just write "…according to equation \label{some_equation}, we see that…" That way, if the order or amount of equations change, then you the "6.4" will also change!

Nice intro, but I wanna learn more!

Here’s a link to the document that I use as a reference for using $\LaTeX$. It's a really good reference, quite comprehensive. I printed it out at the Student Center and had it bound at CopyTech for ~$3. Totally worth it.

Help! I broke it. :(

First, try comparing it to code that already works, like the example listed above. Then, check syntax (make sure parentheses are balanced, etc.) Then, try commenting out parts that you're unsure about to narrow down the problem. Then, if everything seems fine in terms of syntax, but it still doesn't work, make sure that you used the appropriate package in the preamble. Make sure that files don't have spaces or dots. Also, remember that the file directory system is case-sensitive. If you have any questions or comments, just send me an email. If it's a simple conceptual question on how to implement something, the reference I listed above probably has the answer. If it's an error, email me the code and although may not know how to fix it, I'll try my best to help.

I have a reasonable grasp on $\LaTeX$, but how do I use it elsewhere?

Using $\LaTeX$ in MATLAB

Using $\LaTeX$ in MATLAB is important for figures, like the one shown below. Using $\LaTeX$ in MATLAB is as easy as using $\LaTeX$ commands themselves; just type them in MATLAB for your title, xlabel, ylabel, etc. MATLAB recognizes most commands.

Using $\LaTeX$ in Powerpoint

For this, I typically use LaTeXiT because I've gotten faster at typing equations in $\LaTeX$ than in Microsoft Equation Editor. LaTeXiT generates a scalable vector image that can be dragged and dropped into Powerpoint presentations or Word documents.

Using $\LaTeX$ in html

There's this great program called MathJax that does everything for you. Since I edit my html directly, I just copied and pasted a script and everything worked just fine.

Using $\LaTeX$ in email

I use Thunderbird as an email client, and for that there is a plugin called LaTeX It! that allows you to embed $\LaTeX$ in an email. This is great for when you have to send an email to a professor or a colleague that involves a bunch of funny symbols. For using $\LaTeX$ in Gmail, there is this.

How do I make graphics?

I hear that Geogebra is the program that is typically used. It's like MS Paint for mathematicians. Also, Inkscape is a great open source program that is used for vector formatting pictures and it takes $\LaTeX$ input.

$\mathbf{L}\!{}_{\mathbf{Y}}\!{}\mathbf{X}$

P.S. There is a WYSIWYG-ish program called $\mathbf{L}\!{}_{\mathbf{Y}}\!{}\mathbf{X}$ that will output $\LaTeX$ documents. In my experience, it doesn't give me exactly what I want, so I transitioned more and more to using $\LaTeX$. That is, I started out by writing a whole document in $\mathbf{L}\!{}_{\mathbf{Y}}\!{}\mathbf{X}$ and making a few tweaks in $\LaTeX$, but eventually I made so many tweaks that I ended up writing in $\LaTeX$ directly. So if you want, you can use $\mathbf{L}\!{}_{\mathbf{Y}}\!{}\mathbf{X}$ as training wheels for your $\LaTeX$ bike. Enjoy.