Difference between revisions of "LaTeX:LaTeX on AoPS"
(→Equalities and Inequalities) 
(→Equalities and Inequalities) 

Line 151:  Line 151:  
<li>  <li>  
−  <b>Definition by Cases</b>:  +  <b>Definition by Cases</b>: To define, say, a function by cases, we use the <code>cases</code> environment. The code 
+  <pre>  
+  <cmath> \delta(i,j) = \begin{cases} 0 & \text{if } i \neq j \\ 1 &\text{if } i = j \end{cases} </cmath>  
+  </pre>  
+  gives us  
+  <cmath>  
+  \delta(i,j) = \begin{cases} 0 & \text{if } i \neq j \\ 1 &\text{if } i = j. \end{cases}  
+  </cmath>  
<br/><br/></li>  <br/><br/></li>  
Revision as of 14:13, 2 October 2015
LaTeX 
About  Getting Started  Diagrams  Symbols  Downloads  Basics  Math  Examples  Pictures  Layout  Commands  Packages  Help 
This article explains how to use LaTeX in the AoPSWiki, the AoPS Community, and the AoPS Classroom. See Packages to know which packages are prebuilt into the AoPS site.
Contents
Getting Started with LaTeX
The Very Basics
LaTeX uses a special "math mode" to display mathematics. There are two types of this "math mode":

Inline math mode. In inline math mode, we use
$
signs to enclose the math we want to display, and it displays inline with our text. For example, typing$\sqrt{x} = 5$
gives us 
Display math mode. In display math mode, we enclose our code in double dollar signs, and it displays the math centered and on its own line. For example,
$$\sqrt{x} = 5$$
gives us Besides displaying inline vs. displaying centered and on a new line, the two modes render differently in other ways. Note that$\sum_{k=1}^n k^2$
gives us whereas$$\sum_{k=1}^n k^2$$
gives us
Basic Expressions

Multiplication: Sometimes, when we're multiplying, we don't need a multiplication symbol. For instance, we can write instead of without ambiguity. However, when you're multiplying numbers, for instance, a multiplication symbol comes in handy. The standard symbol is given by
$\cdot$
. For example,$12\cdot\frac{1}{2}$
gives us 
Fractions: We can make fractions via
$\frac{...}{...}$
. For instance,$\frac{x+y}{2}$
will give us 
Roots: Square roots in are pretty simple; we just type
$\sqrt{...}$
. For instance,$\sqrt{2}$
gives us Cube roots, fourth roots, and so on are only slightly more difficult; we type$\sqrt[n]{...}$
. For instance,$\sqrt[4]{xy}$
gives 
Superscripts and Subscripts: To get superscripts (or exponents), we use the caret symbol
^
. Typing$x^2+y^2$
gives Subscripts are obtained via an underscore (holding shift and the minus sign on most keyboards). For instance,$a_k$
yields 
Groups: Most operations in (such as superscripts and subscripts) can only see the "group" of characters immediately following it. We use curly braces
{...}
to indicate groups longer than one character. For instance, if we wrote$x^2015$
, we'd expect to get but we instead get This is because each character in the string2015
is in its own group until we tell that2015
should be one whole group. To convey this information to , we write$x^{2015}$
and we get
Beyond the Basic Expressions

Grouping Expressions: Our ordinary parentheses
(...)
and brackets[...]
work to group expressions in . For instance,$(x+y)[z+w]$
gives us We can also group expressions using curly braces, but we can't just type{...}
. Rather, we must type\{...\}
. This is because uses plain curly braces for other things, such as fractions and superscripts and subscripts.
When we put (vertically) large expressions inside of parentheses (or brackets, or curly braces, etc.), the parentheses don't resize to fit the expression and instead remain relatively small. For instance,$$f(x) = \pi(\frac{\sqrt{x}}{x1})$$
comes out as To automatically adjust the size of parentheses to fit the expression inside of them, we type\left(...\right)
. If we do this for our equation above, we get We can use\left
and\right
for all sorts of things... parentheses (as we saw), brackets$\left[...\right]$
, braces$\left\{...\right\}
, absolute values$\left...\right$
, and much more (norms, floor and ceiling functions, inner products, etc.). 
Lists: To make a list, such as a sequence, we use
\dots
. For example,$a_0,a_1,\dots,a_n$
will give us 
Sums: There are two basic ways to write out sums. First, we can use
+
and\cdots
. An example of this way would be$a_1+a_2+\cdots+a_n$
This will give us Second, we could use summation notation, or\sum
. Such an example is$\sum_{i=0}^n a_i$
, giving Note the use of superscripts and subscripts to obtain the summation index. 
Products: Again, there are two basic ways to display products. First, we can use
\cdot
and\cdots
. An example is$n! = n\cdot(n1)\cdots 2\cdot 1$
, which of course gives The alternative is to use product notation with\prod
. For instance,$n! = \prod_{k=1}^n k$
, giving
Equalities and Inequalities

Inequalities: the commands
>, <, \geq, \leq,
and\neq
give us and respectively. 
Aligning Equations: To align multiple equations, we use the
align*
environment. For example, we might type a system of equations as follows:\begin{align*} ax + by &= 1 \\ cx + dy &= 2 \\ ex + fy &= 3. \end{align*}
(You do not need dollar signs.) The
&
symbol tells where to align to and the \\ symbols break to the next line. This code will output An example of a string of equations is:\begin{align*} ((2x+3)^3)' &= 3(2x+3)^2 \cdot (2x+3)' \\ &= 3(2x+3)^2 \cdot 2 \\ &= 6(2x+3)^2. \end{align*}
Again, the
&
symbol tells where to align to, and the \\ symbols break to the next line. This code outputs 
Numbering Equations: To number equations, we use the
align
environment. This is the same environment as thealign*
environment, but we leave the*
off. The*
suppresses numbering. To number one equation, the code\begin{align} ax + by = c \end{align}
will produce We don't have to use
&
or \\ since there is nothing to align and no lines to break. To number several equations, such as a system, the code\begin{align} ax + by &= c \\ dx + ey &= f \\ gx + hy &= i \end{align}
will produce In general,
align
will autonumber your equations from first to last. 
Comments in Equations: Again, we use the
align*
environment. The code\begin{align*} ax + by &= c & \text{because blah} \\ dx + ey &= f & \text{by suchandsuch} \end{align*}
will produce (You can use
align
to get numbering and comments!) 
Definition by Cases: To define, say, a function by cases, we use the
cases
environment. The code<cmath> \delta(i,j) = \begin{cases} 0 & \text{if } i \neq j \\ 1 &\text{if } i = j \end{cases} </cmath>
gives us
Making Figures Using Asymptote
LaTeX can also be used to draw figure and diagrams on the AoPS site using a language called Asymptote. See Asymptote to learn more.
That's all there is to invoking LaTeX on the AoPS site. Of course, you'll want to do more than square roots! You can read through the Symbols and Commands pages to learn how to render other symbols with LaTeX. You can also click on formulas created by others to see the code they've used.