Difference between revisions of "LaTeX:Commands"

(Matrices)
(Other Functions)
Line 179: Line 179:
  
 
== LaTeX ==
 
== LaTeX ==
===Other Functions===
+
===Other Functns===
{| class="latextable"
+
{| class="la
!Symbol !! Command!!Symbol !! Command!!Symbol !! Command
+
|<math>\arg</math>||\arg||<math>\te
|-
 
|<math>\arg</math>||\arg||<math>\textstyle\deg</math>||\deg||<math>\textstyle\det</math>||\det
 
|-
 
| <math>\dim</math>||\dim||<math>\textstyle\exp</math>||\exp||<math>\textstyle\gcd</math>||\gcd
 
|-
 
|<math>\hom</math>||\hom||<math>\inf</math>||\inf||<math>\ker</math>||\ker
 
|-
 
| <math>\textstyle\lg</math>||\lg||<math>\liminf</math>||\liminf||<math>\limsup</math>||\limsup
 
|-
 
| <math>\textstyle\max</math>||\max||<math>\textstyle\min</math>||\min||<math>\Pr</math>||\Pr
 
|-
 
| <math>\sup</math>||\sup||<math>\smiley</math>||\smiley
 
 
|}
 
|}
 
Some of these commands take subscripts in the same way sums, products, and logarithms do. Some render differently in display mode and inline math mode.
 
Some of these commands take subscripts in the same way sums, products, and logarithms do. Some render differently in display mode and inline math mode.
{| class="latextable"
+
| </math>\dim_x<math>||\dim_x||</math>\textstyle\gcd_x<math>||\gcd_x||</math>\inf_x$||\inf_x
!Symbol !! Command!!Symbol !! Command!!Symbol !! Command
 
 
|-
 
|-
| <math>\dim_x</math>||\dim_x||<math>\textstyle\gcd_x</math>||\gcd_x||<math>\inf_x</math>||\inf_x
 
|-
 
| <math>\liminf_x</math>||\liminf_x||<math>\limsup_x</math>||\limsup_x||<math>\textstyle\max_x</math>||\max_x
 
|-
 
| <math>\textstyle\min_x</math>||\min_x||<math>\Pr_x</math>||\Pr_x||<math>\sup_x</math>||\sup_x
 
|}
 
  
 
==Matric
 
==Matric
\left(e & f <br />g & h & i \end{array}
+
 
\right)\]
 
 
is given by the equation
 
is given by the equation
\[ f(\lambda)
+
\[ f(\la
= \left|
 
</nowiki>
 
</pre>
 
More simply, we can use the sh
 
The characterislynomial <math>f(\lamda)</math> of the
 
$3 \timeb & -c <br />-d & \lambda - e & -f <br />-g & -h & \lambda - i
 
\end{vmaix}.\]
 
</nowiki></pr
 
  
 
==Text Styles in Math Mode==
 
==Text Styles in Math Mode==

Revision as of 00:22, 8 October 2023

LaTeX
About - Getting Started - Diagrams - Symbols - Downloads - Basics - Math - Examples - Pictures - Layout - Commands - Packages - Help

This page introduces various useful commands for rendering math in LaTeX, as well as instructions for building your own commands.

Subscripts and Superscripts

Subscripts and superscripts (such as exponents) can be made using the underscore _ and caret ^ symbols respectively.

Symbol Command Symbol Command
$2^{2}$ 2^2 $\textstyle a_i$ a_i
$\textstyle 2^{23}$ 2^{23} $\textstyle n_{i-1}$ n_{i-1}
$a^{i+1}_3$ a^{i+1}_3 $x^{3^2}$ x^{3^2}
$2^{a_i}$ 2^{a_i} $2^a_i$ 2^a_i

Notice that we can apply both a subscript and a superscript at the same time. For subscripts or superscripts with more than one character, you must surround what you want to be the exponent/superscript with curly braces. For example, x^10 produces $x^10$, while x^{10} produces $x^{10}$.

Math Commands

Here are some commonly used math commands in LaTeX:

Fractions

Symbol Command
$\frac {1}{2}$ \frac{1}{2} or \frac12
$\frac{2}{x+2}$ \frac{2}{x+2}
$\frac{1+\frac{1}{x}}{3x + 2}$ \frac{1+\frac{1}{x}}{3x + 2}


Notice that with fractions with a 1-digit numerator and a 1-digit denominator, we can simply group the numerator and the denominator together as one number. However, for fractions with either a numerator or a denominator that requires more than one character (or if the numerator starts with a letter), you need to surround everything in curly brackets.

Use \cfrac for continued fractions.

Expression Command
$\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}}$ \cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}}

Radicals

Symbol Command
$\sqrt{3}$ \sqrt{3}
$\sqrt{x+y}$ \sqrt{x+y}
$\sqrt{x+\frac{1}{2}}$ \sqrt{x+\frac{1}{2}}
$\sqrt[3]{3}$ \sqrt[3]{3}
$\sqrt[n]{x}$ \sqrt[n]{x}

Sums, Products, Limits and Logarithms

Use the commands \sum, \prod, \lim, and \log respectively. To denote lower and upper bounds, or the base of the logarithm, use _ and ^ in the same way they are used for subscripts and superscripts. (Lower and upper bounds for integrals work the same way, as you'll see in the calculus section)

Symbol Command
$\textstyle \sum_{i=1}^{\infty}\frac{1}{i}$ \sum_{i=1}^{\infty}\frac{1}{i}
$\textstyle \prod_{n=1}^5\frac{n}{n-1}$ \prod_{n=1}^5\frac{n}{n-1}
$\textstyle \lim_{x\to\infty}\frac{1}{x}$ \lim_{x\to\infty}\frac{1}{x}
$\textstyle \lim\limits_{x\to\infty}\frac{1}{x}$ \lim\limits_{x\to\infty}\frac{1}{x}
$\textstyle \log_n n^2$ \log_n n^2

Some of these are prettier in display mode:

Symbol Command
$\sum_{i=1}^{\infty}\frac{1}{i}$ \sum_{i=1}^{\infty}\frac{1}{i}
$\prod_{n=1}^5\frac{n}{n-1}$ \prod_{n=1}^5\frac{n}{n-1}
$\lim_{x\to\infty}\frac{1}{x}$ \lim_{x\to\infty}\frac{1}{x}

Note that we can use sums, products, and logarithms without _ or ^ modifiers.

Symbol Command
$\sum\frac{1}{i}$ \sum\frac{1}{i}
$\prod\frac{n}{n-1}$ \prod\frac{n}{n-1}
$\textstyle \log n^2$ \log n^2
$\textstyle \ln e$ \ln e

Mods

Symbol Command
$9\equiv 3 \bmod{6}$ 9\equiv 3 \bmod{6}
$9\equiv 3 \pmod{6}$ 9\equiv 3 \pmod{6}
$9\equiv 3 \mod{6}$ 9\equiv 3 \mod{6}
$9\equiv 3\pod{6}$ 9\equiv 3 \pod{6}

Combinations

Symbol Command
$\scriptstyle\binom{1}{1}$ \binom{1}{1}
$\scriptstyle\binom{n-1}{r-1}$ \binom{n-1}{r-1}

These often look better in display mode:

Symbol Command
$\dbinom{9}{3}$ \dbinom{9}{3}
$\dbinom{n-1}{r-1}$ \dbinom{n-1}{r-1}

Trigonometric Functions

Most of these are just the abbreviation of the trigonometric function with simply a backslash added before the abbreviation.

Symbol Command Symbol Command Symbol Command
$\textstyle \cos$ \cos $\textstyle \sin$ \sin $\textstyle \tan$ \tan
$\sec$ \sec $\textstyle \textstyle \csc$ \csc $\textstyle \cot$ \cot
$\textstyle \arccos$ \arccos $\textstyle \arcsin$ \arcsin $\textstyle \arctan$ \arctan
$\textstyle \cosh$ \cosh $\textstyle \sinh$ \sinh $\textstyle \tanh$ \tanh
$\textstyle \coth$ \coth

Here are a couple examples:

Symbol Command
$\textstyle \cos^2 x +\sin^2 x = 1$ \cos^2 x +\sin^2 x = 1
$\cos 90^\circ = 0$ \cos 90^\circ = 0

Calculus

Below are examples of calculus expressions rendered in LaTeX. Most of these commands have been introduced before. Notice how definite integrals are rendered (and the difference between inline 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$ \frac{d}{dx}\left(x^2\right) = 2x
$\int 2x\,dx = x^2+C$ \int 2x\,dx = x^2+C
$\int^5_1 2x\,dx = 24$ \int^5_1 2x\,dx = 24
$\frac{\partial^2U}{\partial x^2} + \frac{\partial^2U}{\partial y^2}$ \frac{\partial^2U}{\partial x^2} + \frac{\partial^2U}{\partial y^2}
$\frac{1}{4\pi}\oint_\Sigma\frac{1}{r}\frac{\partial U}{\partial n} ds$ \frac{1}{4\pi}\oint_\Sigma\frac{1}{r}\frac{\partial U}{\partial n} ds

$\text{TA-DA!!!}$

Overline and Underline

Symbol Command
$\overline{a+bi}$ \overline{a+bi}
$\underline{747}$ \underline{747}

LaTeX

Other Functns

==Matric is given by the equation \[ f(\la

Text Styles in Math Mode

You can render letters in various styles in math mode. Below are examples; you should be able to use these with any letters. The \mathbb requires the amsfonts package to be included in your document's preamble. Do not try to do \mathbb{year}. You'll get $\mathbb{year}$, and that looks nothing like it!

$\arg$ \arg $\te

|} Some of these commands take subscripts in the same way sums, products, and logarithms do. Some render differently in display mode and inline math mode.

|$ (Error compiling LaTeX. Unknown error_msg)
\dim_x$||\dim_x||$\textstyle\gcd_x$||\gcd_x||$\inf_x$
\inf_x
So
$$n^2 + 5 = 30\text{ so we have }n=\pm5$$

gives

Text1.gif

How to Build Your Own Commands

The command> \documength $\hypot{3}{4}$ (Error compiling LaTeX. Unknown error_msg). sqrt[3]{2}$' all the time, just to get$\cbrt{2}$.

\end{document}

</nowiki>

The \newcommand dputs will be sent to the cois called. f purposes, not just for making math commands you'll ue a lot easier to call. For example, try this:

<nowiki>
\pdfpagewidth 8.5p A.\ #2\hfill B.\ #3\hfill
C.\ #4\hfill D.\ #5\hfill E.\ NOTA}

\begin{document}

\prob{Evaluateum_{fty \frac{1}{

See Also

* Next: Packages * Previous: Symbols
Symbol Command Symbol Command Symbol Command Symbol Command