LaTeX:Commands - AoPSWiki
From AoPSWiki
Page Tools
Page Discussion View source History
Contents
1 Math Commands 1.1 Exponents and Subscripts 1.2 Fractions 1.3 Radicals 1.4 Sums, Products, Limits and Logarithms 1.5 Mods 1.6 Combinations 1.7 Trigonometric Functions 1.8 Calculus 1.9 Overline and Underline 1.10 Other Functions 2 Matrices 3 Text Styles in Math Mode 4 How to Build Your Own Commands 5 See Also
Personal tools
Log in
Navigation
Main page C ommunity portal Recent changes Random page Help
Toolbox
What links here Related changes Special pages Printable version Permanent link
Math Commands
Here are some commonly used math commands in LaTeX.
SymbolCommand \frac{1}{2}
Fractions
\frac{2}{x+2} \frac{1+\frac{1}{x}}{3x + 2} Most fractions look better in display mode (remember, you don't need the declaration if you are in \[...\] or $$...$$ mode.) You can use \dfrac as a shortcut: SymbolCommand \dfrac{1}{2} \dfrac{2}{x+2} \dfrac{1+\frac{1}{x}}{3x + 2}
www.artofproblemsolving.com/Wiki/index.php/LaTeX:Commands
1/5
12/27/12
Symbol Command \sqrt{2} \sqrt{x+y} \sqrt{x+\frac{1}{2}} \sqrt[3]{3} \sqrt[n]{x}
LaTeX:Commands - AoPSWiki
Radicals
We use _ to get the 'bottom' parts of summations, products, and limits, as well as the subscripts of logarithms. We use ^ to get the 'top' parts of sums and products. (Integration symbols work the same way, as you'll see in the calculus section.) Click here for a few other commands which take 'bottom' parts. Symbol Command \sum_{i=1}^{\infty}\frac{1}{i} \prod_{n=1}^5\frac{n}{n-1} \lim_{x\to\infty}\frac{1}{x} \log_n n^2 Some of these are prettier in display mode: Symbol Command \sum_{i=1}^{\infty}\frac{1}{i} \prod_{n=1}^5\frac{n}{n-1} \lim_{x\to\infty}\frac{1}{x} Note that we can use sums, products, and logarithms without _ or ^ modifiers. SymbolCommand \sum\frac{1}{i} \frac{n}{n-1} \log n^2 \ln e Symbol Command 9\equiv 3 9\equiv 3 9\equiv 3 9\equiv 3
Mods
\bmod{6} \pmod{6} \mod{6} \pod{6}
SymbolCommand \binom{9}{3} \binom{n-1}{r-1} These often look better in display mode: Symbol Command \dbinom{9}{3} \dbinom{n-1}{r-1}
Combinations
SymbolCommandSymbolCommandSymbolCommand \cos \sin \tan \sec \csc \cot \arccos \arcsin \arctan \cosh \sinh \tanh \coth Here are a couple examples: Symbol Command \cos^2 x +\sin^2 x = 1 \cos 90^\circ = 0
Trigonometric Functions
Calculus
Below are examples of calculus rendered in LaTeX. Most of these commands have been introduced before. Notice how definite integrals are rendered (and the difference between regular math and display mode for definite integrals). The , in the integrals makes a small space before the dx. Symbol Command \frac{d}{dx}\left(x^2\right) = 2x \int 2x\,dx = x^2+C \int^5_1 2x\,dx = 24
www.artofproblemsolving.com/Wiki/index.php/LaTeX:Commands
2/5
12/27/12
LaTeX:Commands - AoPSWiki
\frac{1}{4\pi}\oint_\Sigma\frac{1}{r}\frac{\partial U}{\partial n} ds
SymbolCommandSymbolCommandSymbol Command \arg \deg \det \dim \exp \gcd \hom \inf \ker \lg \liminf \limsup \max \min \Pr \sup
Some of these functions take 'bottom' parts just like sums and limits. Some render differently in display mode and regular math mode. SymbolCommandSymbol CommandSymbolCommand \dim_x \gcd_x \inf_x \liminf_x \min_x \limsup_x \Pr_x \max_x \sup_x
Matrices
We can build an array or matrix with the \begin{array} command, and use \left and \right to properly size the delimiters around the matrix:
Tecaatrsi plnma $(lmd) o te h hrceitc oyoil f\aba$ f h $ \ie 3 mti 3 tms $ arx \ [ \et lf( \ei{ra}cc bgnary{c} a&b&c\ \ d&e&f\ \ g&h&i\n{ra} edary \ih)] rgt\ i gvnb teeuto s ie y h qain \ f\aba [ (lmd) =\et lf| \ei{ra}cc bgnary{c} \aba-a&- &- \ lmd b c \ - &\aba-e&- \ d lmd f \ - &- &\aba-i\n{ra} g h lmd edary \ih|\ rgt.]
More simply, we can use the shortcut commands in the amsmath package:
Tecaatrsi plnma $(lmd) o te h hrceitc oyoil f\aba$ f h $ \ie 3 mti 3 tms $ arx \ [ \ei{mti} bgnparx a&b&c\ \ d&e&f\ \ g&h&i \n{mti}\ edparx ] i gvnb teeuto s ie y h qain \ f\aba [ (lmd) =\ei{mti} bgnvarx \aba-a&- &- \ lmd b c \ - &\aba-e&- \ d lmd f \ - &- &\aba-i g h lmd \n{mti}\ edvarx.]
You can read more about how the array command works here (it works the same as tabular). We can also use this environment to typeset any mathematics that calls for multiple columns, such as funky function definitions like this one:
\ fx =\et{\ei{ra}l} [ () lf\ bgnary{l
www.artofproblemsolving.com/Wiki/index.php/LaTeX:Commands
3/5
12/27/12
x7&\bxi $<x}\ + mo{f 5 $;\ x23&\bxi $3\ex\e5}\ ^mo{f l l $;\ - &\bxi $ <-$.edary \ih.\ x mo{f x 3}\n{ra} rgt ]
LaTeX:Commands - AoPSWiki
But it would be better to use the cases environment and \text command that the amsmath package provides:
\ [ fx =\ei{ae} () bgncss x7&\eti $<x} \ + tx{f 5 $; \ x23&\eti $3\ex\e5}\ ^tx{f l l $;\ - &\eti $ <-$. x tx{f x 3} \n{ae} edcss \ ]
gives
The \newcommand declarations are in the preamble. Each is of the form \newcommand{name of new command}[number of arguments]{definition} The name of the new command, which must begin with a \, is the name you'll use in the document to use the command. The number of arguments is how many inputs will be sent to the command. The definition is just normal LaTeX code, with #1, #2, #3, etc., placed where you want the inputs to go when the new command is called. New commands can be used for all sorts of purposes, not just for making math commands you'll use a lot easier to call. For example, try this:
\ouetls[1t{ril} dcmncas1p]atce \spcaeasah ueakg{mmt} \dpgwdh85n pfaeit .i \dpghih 1i pfaeegt 1n \ecutrpo_u} nwone{rbnm \ecutrpo_u}1 stone{rbnm{} \ecmad\rb[]\isi \isi\rbcpo_u}\tpone{rbnm # nwomn{po}5{bgkp bgkpaai{rbnm.secutrpo_u} 1 \a\oaera[]mdkpA\#\fl B\#\fl prnpgbek4\esi . 2hil . 3hil C\#\fl D\#\fl E\NT} . 4hil . 5hil . OA
www.artofproblemsolving.com/Wiki/index.php/LaTeX:Commands
4/5
12/27/12
\ei{ouet bgndcmn} \rbWa i $+$}4{}6{} po{ht s 22?{}5{}7 \rbWa i $sr{0}?{1{0{}1 po{ht s \qt10$}8}1}9{}
LaTeX:Commands - AoPSWiki
\rbEaut $dslytl\u_n1^ify\rc1{^}. po{vlae \ipasyesm{=}\nt fa{}n2$} {\ipasyefa{}e$ {\ipasyefa{}\i$ $dslytl\rc1{}} $dslytl\rc2{p}} {\ipasyefa{p^}8$ {\ipasyefa{p^}6$ $dslytl\rc\i3{}} $dslytl\rc\i2{}} \n{ouet eddcmn}
In the example above, we create a new command called \prob. Each time we call \prob, we supply 5 arguments, one for the question and one for each of the multiple choices. In the preamble and the definition of \prob, you'll see a few new LaTeX commands: \newcounter{prob_num} creates a counter variable called prob_num \setcounter{prob_num}{1} setsprob_num to equal 1. In the definition of \prob, the \bigskip and \medskip commands create vertical space. \arabic{prob_num} prints out the current value of the counter prob_num as an arabic numeral. \stepcounter{prob_num} increments the counter prob_num by 1. \nopagebreak[4] tells LaTeX not to break the page between the problem and the choices unless it really, really, really has to. The \hfill commands put roughly equal space between the choices. Once you build a body of custom commands that you will be using in many LaTeX documents, you should learn about creating your own package so you don't have to copy all your custom commands from document to document.
See Also
Next: Packages Previous: Symbols Retrieved from "http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Commands" Category: LaTeX This page was last modified on 25 July 2012, at 17:06. This page has been accessed 875,546 times. Privacy policy About AoPSWiki Disclaimers
www.artofproblemsolving.com/Wiki/index.php/LaTeX:Commands
5/5