LaTeX Wiki
(Indented tables using div with)
 
(36 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
'''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''' introduces the LaTeX markup language, and provides high-level information to get you started using it, and to help you understand its syntax.
 
__TOC__
 
__TOC__
==Invoking LaTeX==
+
==Using LaTeX==
  +
{{main|Using LaTeX to format documents}}
In a wiki, LaTeX markup is enclosed by <code><nowiki><math></nowiki></code> and <code><nowiki></math></nowiki></code> tags.
 
  +
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 <code><nowiki><math> . . . </math></nowiki></code> tags.
  +
  +
===LaTeX language===
  +
{{main|LaTeX language}}
  +
The LaTeX language consists of a "preamble" followed by "document text".
  +
  +
===Example of a minimal document===
  +
<div style="padding-left:1cm">
  +
<code>
  +
\documentclass{class}<br>
  +
… your preamble goes here …<br>
 
\begin{document}<br>
  +
… your text goes here …<br>
  +
\end{document}<br>
 
</code>
 
</div>
  +
  +
===Continuation lines===
  +
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===
  +
The <code>{{Lcmd|%|percent sign}}</code> character begins a comment. The rest of the line is ignored by the LaTeX processor. For very windy comments, the {{Lenv|comment}} environment, which comes with the {{Lpkg|verbatim}} package, can be used, like this:
  +
<code>
  +
:\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 ---------------
  +
</code>
  +
  +
===Blank lines===
  +
In [[paragraph mode]], the default mode in LaTeX, a blank line ends a paragraph. In [[math mode]], which is entered using using <code>\{{Lcmd|(|left parenthesis}}</code> or <code>\{{Lcmd|[|left bracket}}</code> or by <code>{{Lcmd|begin}}</code>ning one of the math environments, blank lines are not allowed.
  +
  +
===LaTeX subset for wiki===
  +
{{main|Using LaTeX in a wiki}}
 
In a wiki, LaTeX markup is enclosed by <code><nowiki><math> ... </math></nowiki></code> tags.
  +
  +
===Using LaTeX on Windows===
  +
{{main|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==
 
==LaTeX syntax==
 
LaTeX consists of
 
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.
 
* "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===
 
===LaTeX environments===
  +
{{main|LaTeX environment}}
 
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">
 
{| class="wikitable" border=1 cellspacing=0 cellpadding=8 style="margin: 1em 1em 1em 0;"
 
|- valign="bottom"
 
! scope="col" | The following LaTeX markup...
 
! scope="col" | ...results in this:
 
! scope="col" | ...and is used for this purpose:
 
|- valign="top"
 
| <code>\begin{equation}<br>
 
D = b^2-4ac<br>
 
\end{equation}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| automatically numbered equation; numbers rendered in right margin
 
|- valign="top"
 
| <code>\begin{equation*}<br>
 
D = b^2-4ac<br>
 
\end{equation*}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| unnumbered equation; numbers rendered in right margin
 
|- valign="top"
 
| <code>\begin{equation}\label{mylab}<br>
 
D = b^2-4ac<br>
 
\end{equation}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| the number of the equation is saved as "mylab", and can be referenced later using <code>\eqref{mylab}</code>
 
|- valign="top"
 
| <code>\begin{split}\label{mylab}<br>
 
D &= b^2\\<br>
 
&-4ac<br>
 
\end{split}</code>
 
| <math>\begin{split}\label{mylab}
 
D &= b^2\\
 
&-4ac
 
\end{split}</math>
 
| for very long equations, splits them across multiple lines of text, [[align]]ing them using the ampersand character
 
|- valign="top"
 
| <code>\begin{multline}<br>
 
a+b+c+d+e+f\\<br>
 
+i+j+k+l+m+n<br>
 
\end{multline}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| multline equations
 
|- valign="top"
 
| <code>\begin{gather}<br>
 
a_1=b_1+c_1\\<br>
 
a_2=b_2+c_2-d_2+e_2<br>
 
\end{gather}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| to gather equations together; rendered centered on the page
 
|- valign="top"
 
| <code>\begin{align}<br>
 
a_{11}& =b_{11}&<br>
 
a_{12}& =b_{12}\\<br>
 
a_{21}& =b_{21}&<br>
 
a_{22}& =b_{22}+c_{22}<br>
 
\end{align}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| to align pairs of equations in a table form
 
|- valign="top"
 
| <code>\begin{flalign*}<br>
 
a_{11}& =b_{11}&<br>
 
a_{12}& =b_{12}\\<br>
 
a_{21}& =b_{21}&<br>
 
a_{22}& =b_{22}+c_{22}<br>
 
\end{flalign*}</code>
 
| (not available in <code><nowiki><math>...</math></nowiki></code> tags)
 
| alignment, using the full width of the page
 
|}
 
</div>
 
   
 
===LaTeX commands===
 
===LaTeX commands===
Line 85: Line 56:
 
===Parameters===
 
===Parameters===
 
Following <code>\commandname</code>, or <code>\symbolname</code>, 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).
 
Following <code>\commandname</code>, or <code>\symbolname</code>, 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).
<div style="float:none; clear:both; text-align:left; border:none; background-color:#ffffff; padding:0px; width:100%; margin:0cm; margin-left:1cm">
+
<div style="float:none; clear:both; text-align:left; border:none; padding:0px; margin:0cm; margin-left:1cm;">
 
{| 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"
Line 101: Line 72:
 
Subscripts and superscripts of a symbol are rendered either beneath and above the symbol, as in <code>\sum</code>, or to the right of the symbol, as in <code>\sin</code>.
 
Subscripts and superscripts of a symbol are rendered either beneath and above the symbol, as in <code>\sum</code>, or to the right of the symbol, as in <code>\sin</code>.
   
 
<div style="float:none; clear:both; text-align:left; border:none; padding:0px; margin:0cm; margin-left:1cm;">
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 <code>\[[operatorname (LaTeX symbol)|operatorname]]</code> in the following table to see how this works.
 
 
<div style="float:none; clear:both; text-align:left; border:none; background-color:#ffffff; padding:0px; width:100%; margin:0cm; margin-left:1cm">
 
 
{| 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;"
 
|-
 
|-
Line 117: Line 86:
 
| <code>\operatorname{first}_{i=0}^n</code>
 
| <code>\operatorname{first}_{i=0}^n</code>
 
| <math>\operatorname{first}_{i=0}^n</math>
 
| <math>\operatorname{first}_{i=0}^n</math>
|-
 
| <code>\operatorname*{second}_{i=0}^n</code>
 
| <math>\operatorname*{second}_{i=0}^n</math>
 
 
|}
 
|}
 
</div>
 
</div>
   
  +
{{LaTeX Wiki:External references}}
Observe the use of the asterisk in <code>\operatorname*{second}</code> to tell LaTeX that the limits need to be below and above the operator, as in <code>\lim</code>, <code>\limsup</code>, etc.
 
  +
[[Category:User's guide]]
 
===Examples of commands, subscripts, and superscripts===
 
The commands, <code>\begin{split}</code> and <code>\end{split}</code> form a pair. Each of them takes a parameter, "split", which says what is beginning and ending. The command <code>\frac{numerator}{denominator}</code> takes two parameters, and has no matching ending command.
 
<div style="float:none; clear:both; text-align:left; border:none; background-color:#ffffff; padding:0px; width:100%; margin:0cm; margin-left:1cm">
 
{| class="wikitable" border=1 cellspacing=0 cellpadding=8 style="margin: 1em 1em 1em 0;"
 
|-
 
! scope="col" | The following LaTeX markup...
 
! scope="col" | ...results in this:
 
|-
 
| <pre>\begin{split}
 
a& =b+c-d\\
 
& \quad +e-f\\
 
& =g+h\\
 
& =i
 
\end{split}</pre>
 
| <math>\begin{split}
 
a& =b+c-d\\
 
& \quad +e-f\\
 
& =g+h\\
 
& =i
 
\end{split}</math>
 
|-
 
| <code>\frac{numerator}{denominator}</code>
 
| <math>\frac{numerator}{denominator}</math>
 
|-
 
| <code>\lim_{x\to 0^+} \frac{\sin^2(x)}{x}</code>
 
| <math>\lim_{x\to 0^+} \frac{\sin^2(x)}{x}</math>
 
|}
 
</div>
 

Latest revision as of 11:36, 31 January 2022

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

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

Main article: LaTeX language

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

Example of a minimal document

\documentclass{class}
… your preamble goes here …
\begin{document}
… your text goes here …
\end{document}

Continuation lines

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

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

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

Main article: Using LaTeX in a wiki

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

Using LaTeX on Windows

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

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

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.

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.

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

External references