LaTeX Wiki
Register
Line 11: Line 11:
 
An "[[environment]]" is enclosed by <code>\[[begin (LaTeX command)|begin]]{''environmentname''}</code> and <code>\[[end (LaTeX command)|end]]{''environmentname''}</code>. The wiki <code><nowiki><math>...</math></nowiki></code> tags create an ''equation*'' (unnumbered equation) environment. Several environments listed here are alternatives to the unnumbered equation environment, and cannot be nested inside it, so they can't be used in a wiki.
 
An "[[environment]]" is enclosed by <code>\[[begin (LaTeX command)|begin]]{''environmentname''}</code> and <code>\[[end (LaTeX command)|end]]{''environmentname''}</code>. The wiki <code><nowiki><math>...</math></nowiki></code> tags create an ''equation*'' (unnumbered equation) environment. Several environments listed here are alternatives to the unnumbered equation environment, and cannot be nested inside it, so they can't be used in a wiki.
   
<div style="float:none; clear:both; text-align:left; border:none; background-color:#ffffff; padding:0px; width:100%; margin:0cm; margin-left:1cm; margin-right:3cm;">
+
<div style="float:none; clear:both; text-align:left; border:none; background-color:#ffffff; padding:0px; width:100%; margin:0cm; margin-left:3cm; margin-right:3cm;">
 
{| class="wikitable" border=1 cellspacing=0 cellpadding=8 style="margin: 1em 1em 1em 0;"
 
{| class="wikitable" border=1 cellspacing=0 cellpadding=8 style="margin: 1em 1em 1em 0;"
 
|- valign="bottom"
 
|- valign="bottom"

Revision as of 03:13, 8 October 2010

Using LaTeX introduces the LaTeX markup language, and provides high-level information to get you started using it, and to help you understand its syntax.

Invoking LaTeX

In a wiki, LaTeX markup is enclosed by <math> and </math> tags.

LaTeX syntax

LaTeX consists of

  • "commands" that control size and positioning of rendered text, introduced by a backslash and possibly having parameters,
  • "symbols" that control the content of rendered text, also introduced by a backslash and possibly having subscripts and superscripts.

LaTeX environments

An "environment" is enclosed by \begin{environmentname} and \end{environmentname}. The wiki <math>...</math> tags create an equation* (unnumbered equation) environment. Several environments listed here are alternatives to the unnumbered equation environment, and cannot be nested inside it, so they can't be used in a wiki.

The following LaTeX markup... ...results in this: ...and is used for this purpose:
\begin{equation}

D = b^2-4ac
\end{equation}

(not available in <math>...</math> tags) automatically numbered equation; numbers rendered in right margin
\begin{equation*}

D = b^2-4ac
\end{equation*}

(not available in <math>...</math> tags) unnumbered equation; numbers rendered in right margin
\begin{equation}\label{mylab}

D = b^2-4ac
\end{equation}

(not available in <math>...</math> tags) the number of the equation is saved as "mylab", and can be referenced later using \eqref{mylab}
\begin{split}\label{mylab}

D &= b^2\\
&-4ac
\end{split}

Failed to parse (unknown function "\begin{split}"): {\displaystyle \begin{split}\label{mylab} D &= b^2\\ &-4ac \end{split}} for very long equations, splits them across multiple lines of text, aligning them using the ampersand character
\begin{multline}

a+b+c+d+e+f\\
+i+j+k+l+m+n
\end{multline}

(not available in <math>...</math> tags) multline equations
\begin{gather}

a_1=b_1+c_1\\
a_2=b_2+c_2-d_2+e_2
\end{gather}

(not available in <math>...</math> tags) to gather equations together; rendered centered on the page
\begin{align}

a_{11}& =b_{11}&
a_{12}& =b_{12}\\
a_{21}& =b_{21}&
a_{22}& =b_{22}+c_{22}
\end{align}

(not available in <math>...</math> tags) to align pairs of equations in a table form
\begin{flalign*}

a_{11}& =b_{11}&
a_{12}& =b_{12}\\
a_{21}& =b_{21}&
a_{22}& =b_{22}+c_{22}
\end{flalign*}

(not available in <math>...</math> tags) alignment, using the full width of the page

LaTeX commands

Main article: LaTeX commands

LaTeX commands are introduced by a backslash, and possibly have parameters, which might be enclosed in curly braces. Some commands come in pairs, with a beginning command, followed by the stuff that ends up "inside" it, followed by the corresponding ending command.

Parameters

Following \commandname, or \symbolname, there may be one or more parameters. Optional parameters are enclosed in square brackets. Required parameters are enclosed in curly braces. The following example shows an extensible right arrow symbol with one optional parameter (rendered below the arrow) and one reuired parameter (rendered above it).

The following LaTeX markup... ...results in this:
\xrightarrow[T]{n\pm i-1}

Subscripts and superscripts

A subscript is denoted by the underscore character (_). A superscript is denoted by the carat (^) character. Just like the parameters of a command, the subscript or superscript can be enclosed in curly braces if it's longer than one symbol.

Subscripts and superscripts of a symbol are rendered either beneath and above the symbol, as in \sum, or to the right of the symbol, as in \sin.

For all predefined symbols, LaTeX "knows" how to render the subscripts and superscripts, but for your own custom symbols, you need to tell LaTeX which format to use with the special asterisk operator. Take a look at the \operatorname in the following table to see how this works.

The following LaTeX markup... ...results in this:
\sum_{i=0}^n a_i^2
y = \sin^2(x)
\operatorname{first}_{i=0}^n
\operatorname*{second}_{i=0}^n

Observe the use of the asterisk in \operatorname*{second} to tell LaTeX that the limits need to be below and above the operator, as in \lim, \limsup, etc.

Examples of commands, subscripts, and superscripts

The commands, \begin{split} and \end{split} form a pair. Each of them takes a parameter, "split", which says what is beginning and ending. The command \frac{numerator}{denominator} takes two parameters, and has no matching ending command.

The following LaTeX markup... ...results in this:
\begin{split}
a& =b+c-d\\
 & \quad +e-f\\
 & =g+h\\
 & =i
\end{split}
Failed to parse (unknown function "\begin{split}"): {\displaystyle \begin{split} a& =b+c-d\\ & \quad +e-f\\ & =g+h\\ & =i \end{split}}
\frac{numerator}{denominator}
\lim_{x\to 0^+} \frac{\sin^2(x)}{x}