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.

Using LaTeX[edit | edit source]

Main article: Using LaTeX to format documents

The full LaTeX language is understood by a TeX processor, and can be used to typeset complete documents. A subset of LaTeX for mathematical expressions can be invoked in a wiki using the <math> . . . </math> tags.

LaTeX language[edit | edit source]

Main article: LaTeX language

The LaTeX language consists of a "preamble" followed by "document text".

Example of a minimal document[edit | edit source]

… your preamble goes here …
… your text goes here …

Continuation lines[edit | edit source]

Any line can be continued without any special signal to the LaTeX processor. Single "newline" characters are simply ignored, except to end a comment, as described in the next section.

Comments[edit | edit source]

The % character begins a comment. The rest of the line is ignored by the LaTeX processor. For very windy comments, the comment environment, which comes with the verbatim package, can be used, like this:

\begin{comment} % --------------- multi-line comment ---------------
This text is completely ignored by LaTeX. The ability to have long-winded comments comes from the "`verbatim"' package, which provides the "`comment"' environment.
\end{comment} % --------------- end multi-line comment ---------------

Blank lines[edit | edit source]

In paragraph mode, the default mode in LaTeX, a blank line ends a paragraph. In math mode, which is entered using using \( or \[ or by beginning one of the math environments, blank lines are not allowed.

LaTeX subset for wiki[edit | edit source]

Main article: Using LaTeX in a wiki

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

Using LaTeX on Windows[edit | edit source]

Main article: Using LaTeX on Windows

If you are using the Windows Vista (or Windows 7) operating system, and you want to use LaTeX, and you want to install good software without spending any money, then you can install the open source proTeXt package edit and process LaTeX documents.

LaTeX syntax[edit | edit source]

LaTeX consists of

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

LaTeX environments[edit | edit source]

Main article: LaTeX environment

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:

D = b^2-4ac

(not available in <math>...</math> tags) automatically numbered equation; numbers rendered in right margin

D = b^2-4ac

(not available in <math>...</math> tags) unnumbered equation; numbers rendered in right margin

D = b^2-4ac

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

D &= b^2\\

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


(not available in <math>...</math> tags) multline equations


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

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

(not available in <math>...</math> tags) to align pairs of equations in a table form

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

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

LaTeX commands[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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)

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[edit | edit source]

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:
a& =b+c-d\\
 & \quad +e-f\\
 & =g+h\\
 & =i
Failed to parse (unknown function "\begin{split}"): {\displaystyle \begin{split} a& =b+c-d\\ & \quad +e-f\\ & =g+h\\ & =i \end{split}}
\lim_{x\to 0^+} \frac{\sin^2(x)}{x}

External references[edit source]

Community content is available under CC-BY-SA unless otherwise noted.