4 views

Uploaded by bharathstays

- Sequence and Series Class 11 Maths NCERT Solutions
- easychair-a4
- Auto Pst PDF
- BibTeX Tips and FAQ
- Writer 2 Latex User Manual Screen
- Installing TeX Live 2013 on Salix OS 14.0.1 via ISO Image
- Stat 117 Syllabus
- Make Plot
- Cfg Guide
- Mathematics P1 Exemplar 2014 Eng
- instraut
- siunitx.pdf
- Assign 1.docx
- MongoDB Reference Manual Master
- ApostolAnalysisch7
- bzyl
- swp.txt
- pure_ch13
- INFINITE SERIES OBJECTIVE.doc
- Array

You are on page 1of 4

You are here: Resources » LaTeX Guide » Math

LaTeX:Math

From AoPSWiki

LaTeX

About - LaTeX on AoPS - Downloads - Basics - Math - Examples - Pictures - Layout - Symbols - Commands -

Packages - Help

This article will detail how to work with math mode in LaTeX and how to display equations, formulas, and

mathematical expressions in general.

Math Mode

LaTeX uses a special math mode to display mathematics. To place something written in TeX in math mode,

use $ signs to enclose the math you want to display. For example, open a new source file in TeXnicCenter and

type or copy/paste the following:

\documentclass{article}

\begin{document}

The solution to $\sqrt{x} = 5$ is $x=25$.

\end{document}

Save the document (press Ctrl-S or click File, then Save) as 'mymath' (don't include the quote marks in the

name) in a folder of your choice. The file will appear in your folder as 'mymath.tex.'

Compile the document just as you compiled your first document. When you view the output file, you should see

If you remove the $ symbols from your source file then try to compile, you should get 'Missing $ inserted' error

messages in the Output window of TeXnicCenter (try it and see - you may have to scroll up in the Output

window to see the errors).

Nearly all mathematical items, such as variables, expressions, equations, etc., should be written in math

mode. In fact, most math will generate errors if you don't remember to put it in math mode.

Display Math

As we saw above, when using $math stuff here$ to typeset math, the resulting math expression appears right

in the text at the location of the $...$. Sometimes we want to break some of the math out of the text and give

it its own special line. To do so, we use \[math stuff here\] or $$math stuff here$$ to put the math text in

display math mode:

\documentclass{article}

\begin{document}

The solution to \[\sqrt{x} = 5\] is \[x=25.\]

\end{document}

After you compile this and view it, you should see:

Notice that the equations are on their own lines and are centered. As a matter of style, usually we put this

display math on their own lines in the source file, like this:

LaTeX:Math - AoPSWiki http://www.artofproblemsolving.com/Wiki/index.ph...

\documentclass{article}

\begin{document}

The solution to

\[

\sqrt{x} = 5

\]

is

\[

x=25.

\]

\end{document}

to display mathematics. This approach also creates a label, which we can refer to later if we like. Make sure

you read our notes about referencing before using these labels for references - it's much better to use \label

and \ref than to refer to the equations by number in your source file.

\documentclass{article}

\begin{document}

\begin{equation}

2+2=4

\end{equation}

\end{document}

Notice the (1) out to the right when you compile the above. Once again, rather than typing (1) in your source

file to refer to this equation, use LaTeX referencing commands.

Generally, you'll only use \begin{equation} when you need the label.

Sometimes we have complicated expressions that we don't want to put on their own lines, but that doesn't

render well with $...$ mode. For example:

\documentclass{article}

\begin{document}

Evaluate the sum $\sum_{i=0}^n i^3$.

\end{document}

gives us

That summation symbol is a little ugly. We can make it prettier by using \displaystyle:

\documentclass{article}

\begin{document}

Evaluate the sum $\displaystyle\sum\limits_{i=0}^n i^3$.

\end{document}

Notice that the summation symbol looks much nicer now - adding the \displaystyle at the beginning of your

math (inside the $...$) will often make complicated math render more nicely. Note that it is not necessary to

use \displaystyle when using display mode (\[ and \] or \begin{equation} and \end{equation}).

A pair of very useful tools for displaying equations well are the "align" and "align*" environments. They allow

you to neatly align a string of equations:

LaTeX:Math - AoPSWiki http://www.artofproblemsolving.com/Wiki/index.ph...

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}

2x^2 + 3(x-1)(x-2) & = 2x^2 + 3(x^2-3x+2)\\

&= 2x^2 + 3x^2 - 9x + 6\\

&= 5x^2 - 9x + 6

\end{align*}

\end{document}

There are a few things to notice here. First, the align command requires that you use the package amsmath

(and there's no reason to not use this package). Second, the * after align prevents line numbers from popping

up after each line - try removing both of the *s from the source file and compile to see equation numbers. Next,

notice that each line is of the form

The & symbols separate the columns. There must be two columns (i.e. one & symbol). The \\ tells LaTeX that

you are finished with this line and are on to the next. Notice that there's no \\ on the last line; the

\end{align*} tells LaTeX that you're finished. As you see above, you can leave some columns blank. As a style

issue, notice that we start a new line in our source file after each \\. We could run all the lines together, but

that makes editing very difficult.

Typically, we use relational symbols like =, >, or < immediately following the &; align ensures that these

symbols are arranged into a vertical column as you see above. That's why we like align.

Finally, notice that there are no $ symbols, $$ ... $$, or \[ ... \], yet everything is rendered in math mode. This

happens because align automatically puts everything in math mode - you don't need $s or \[ ... \] tags.

Finally, note that in an align environment, you can use the \nonumber command if you want only some lines to

be numbered. For example,

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}

2x^2 + 3(x-1)(x-2) & = 2x^2 + 3(x^2-3x+2)\\

\nonumber &= 2x^2 + 3x^2 - 9x + 6\\

&= 5x^2 - 9x + 6

\end{align}

\end{document}

compiles to this:

Additional Packages

The basic LaTeX program does not include all the math you'll want to use. In order to access all the math

functions and symbols we will introduce in the guide pages, you'll have to include a number of packages. We

include these packages by using the \usepackage command between the \documentclass line and the

\begin{document} line, such as:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

We can write more than just $x$ now.

Now we can write things like $\binom{5}{3}$.

\end{document}

The package used above is part of the basic MiKTeX installation, so you don't have to download anything new

to include them. Later, you may want to read more about how to include more packages and how you can

create packages of your own.

Finally, one last point of style - notice in that last example that we put the x in math mode by writing $x$

instead of just x. Try compiling with and without the x in math mode and you'll see why. Always put your math

in math mode!

LaTeX:Math - AoPSWiki http://www.artofproblemsolving.com/Wiki/index.ph...

If you find you want to do some math typesetting that you can't find on this page, or among our discussions of

symbols or commands, try reading the user's guide for the amsmath package, which contains some of the

really fancy applications of the ams packages.

See Also

Next: Examples

Previous: Basics

Retrieved from "http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Math"

Category: LaTeX

This page was last modified on 3 August 2009, at 22:05. This page has been accessed 235,632 times.

Privacy policy About AoPSWiki Disclaimers

- Sequence and Series Class 11 Maths NCERT SolutionsUploaded byAshik Meerankutty
- easychair-a4Uploaded byRenan Siqueira
- Auto Pst PDFUploaded byEmanR
- BibTeX Tips and FAQUploaded byjfreyre
- Writer 2 Latex User Manual ScreenUploaded bygavenin
- Installing TeX Live 2013 on Salix OS 14.0.1 via ISO ImageUploaded bykalwisti
- Stat 117 SyllabusUploaded bymarkkkkkkkheeess
- Make PlotUploaded byMenil Vukovic
- Cfg GuideUploaded byKu Zijie
- Mathematics P1 Exemplar 2014 EngUploaded byianmoone001
- instrautUploaded bybauemmvss
- siunitx.pdfUploaded bychris77ve
- Assign 1.docxUploaded byAtika
- MongoDB Reference Manual MasterUploaded bylarbi
- ApostolAnalysisch7Uploaded byjeewonshin
- bzylUploaded byomicronpersei8
- swp.txtUploaded byjhon
- pure_ch13Uploaded byMayank Saini
- INFINITE SERIES OBJECTIVE.docUploaded bySreejith Vanery
- ArrayUploaded byPolaralop
- Curvas 1Uploaded bychico_oliveira
- Lesson 2.2 - 2.3Uploaded byRICHELLE GADIM
- Pre calUploaded byJulieann Aguilar
- 5535115 Addition Mathematic Form 5 Progression Module 1Uploaded byUmaish Nair
- Question 1.docxUploaded byRichard Griffin
- 3com Lbhub RepeaterUploaded byxsimio
- xymtx402403Uploaded bykmalysiakredirect
- R-adminUploaded byYosue
- ENGALGUploaded byclarkdustin1106
- Least Squares Polynomial Fitting for Sin(x)Uploaded byLee Gao

- EclipseUploaded byssoni83
- SQL-BOOKUploaded bySrinivas Reddy
- Cert Quiz ABAPUploaded byEmilS
- ABAP 7.40 Quick ReferenceUploaded bybravevn
- 01 - Mrezna Infrastruktura_Presentation 02_09Uploaded byPetar Stupar
- Computer Science & Application Paper-IIIUploaded byshahissh
- Complete Guide to J2ME PolishUploaded byadilnnj
- Shell commandsUploaded bygeek_sbc
- Clustering HomeworkUploaded byFurkan Dodurka
- Base Unit Test Paper_1QueUploaded byANUP KUMAR DAS
- suckless.orgUploaded byreconrey
- Plastic IntroUploaded bytxaosh
- Les Set Analysis_ENGUploaded byMartin Valenzuela
- OCA Flashcards1Uploaded byAlina Irina Avadanei
- JCSP NetworkingUploaded bySumit Arrawatia
- 05_ArraysAndStringsUploaded byRhea Verallo
- Exception Handling inJAvAUploaded byVinayKumarSingh
- Arrays or PointersUploaded byAmr Hazem
- BirlaSoft_PlacementPapersUploaded byChandrasekhar Uchiha
- 01. Pengenalan PythonUploaded bySiti Nurizzatin Kamala
- yql-opendatatables-v0.0.2.pdfUploaded byelisa
- Embedded1111Uploaded by2013uec1496
- RAM StatementsUploaded byPunithRossi
- Bdc Faqs(Important)Uploaded bySagar Kachare
- ssd3-Chapter0Uploaded byapi-3714422
- Directvhdl ReadmeUploaded byHui Fong
- Python ValuesUploaded byChevva Spandana
- Asg Brief.docUploaded byعبدالرحيم اودين
- COUNTIF in Excel - Count if Not Blank Greater Than Duplicate or UniqueUploaded byP Singh Karki
- Dspd Cse-4 Course File 09-10Uploaded byBhagyashrisuryawnshi