Posted: Aug 16, 2015 4:14 am
chango369 wrote:Pulsar's Latex Tutorial Part 6 - reboot

Pulsar wrote:

Code: Select all
$\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 6}$ Colors

MathJax allows different colors, with the command \color{color}{text} (this syntax is different from standard Latex). I don't know which colors are permitted, but all of these work ( NO THEY DON'T ), and probably more:

Code: Select all
$\color{red}{b} \color{darkred}{b} \color{pink}{b} \color{blue}{b} \color{lightblue}{b} \color{green}{b} \color{darkgreen}{b} \color{yellow}{b} \color{orange}{b} \color{cyan}{b} \color{magenta}{b} \color{violet}{b} \color{purple}{b} \color{brown}{b} \color{white}{b} \color{grey}{b} \color{black}{b}$

NOTE: Some of colors didn't render. Arrays

The \begin{array}{} \end{array} environment is very useful to create content in several rows and columns. Each column can be left-, right- or center- aligned, which has to be specified with l,r,c respectively inside the brackets following \begin{array}. For example, \begin{array}{l r c} starts an array with three columns; column 1 is left-aligned, column 2 is right-aligned and column 3 is center-aligned. Columns are separated with the ampersand & symbol, and a row is ended by a linebreak \\. Two common examples are

Code: Select all
$f(n) = \left\{ \begin{array}{l l} n/2 & \quad \mbox{if n is even}\\ -(n+1)/2 & \quad \mbox{if n is odd}\end{array}\right.$ and matrices

Code: Select all
$A_{m,n} = \left(\begin{array}{cccc} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{array}\right)$ In fact, these examples are so common that Latex contains special commands for them: the first example can be written with the \begin{cases} \end{cases} environment, which also takes care of the initial left bracket (and notice that the lines are slightly closer to each other). No column format specification is needed: cases always defines two left-aligned columns.

Code: Select all
$f(n) =\begin{cases} n/2 & \quad \mbox{if n is even}\\ -(n+1)/2 & \quad \mbox{if n is odd}\end{cases}$ Matrices can be defined with the \begin{pmatrix} \end{pmatrix} environment, which includes the parentheses, and defines every column as center-aligned:

Code: Select all
$A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix}$

[img]http://latex.numberempire.com/render?A_%7Bm%2Cn%7D%20%3D%20%5Cbegin%7Bpmatrix%7D%20%20a_%7B1%2C1%7D%20%26%20a_%7B1%2C2%7D%20%26%20%5Ccdots%20%26%20a_%7B1%2Cn%7D%20%5C%5C%20%20a_%7B2%2C1%7D%20%26%20a_%7B2%2C2%7D%20%26%20%5Ccdots%20%26%20a_%7B2%2Cn%7D%20%5C%5C%20%20%5Cvdots%20%20%26%20%5Cvdots%20%20%26%20%5Cddots%20%26%20%5Cvdots%20%20%5C%5C%20%20a_%7Bm%2C1%7D%20%26%20a_%7Bm%2C2%7D%20%26%20%5Ccdots%20%26%20a_%7Bm%2Cn%7D%20%5Cend%7Bpmatrix%7D&sig=a25bb9b35dfe77e3a6cb1f2113be1fc0/img]

Apart from pmatrix, there are also matrix, bmatrix, vmatrix, Bmatrix, Vmatrix, and smallmatrix.

Code: Select all
$\begin{matrix} a & b \\ c & d \end{matrix}\qquad \begin{bmatrix} a & b \\ c & d \end{bmatrix}\qquad \begin{vmatrix} a & b \\ c & d \end{vmatrix}\qquad \begin{Bmatrix} a & b \\ c & d \end{Bmatrix}\qquad \begin{Vmatrix} a & b \\ c & d \end{Vmatrix}\qquad \begin{smallmatrix} a & b \\ c & d \end{smallmatrix}$ With the array environment, one can simulate multi-line text:

Code: Select all
\begin{array}{r}\text{Right-aligned}\\\text{text, nothing}\\\text{really important}\end{array}\quad \textit{and} \quad \begin{array}{c}\text{Center-aligned}\\\text{text, nothing}\\\text{really important}\end{array}\quad \textbf{and} \quad \begin{array}{l}\text{Left-aligned}\\\text{text, nothing}\\\text{really important}\end{array} This example also contains the \textit{} and \textbf{} commands, to write italics and bold text.

Finally, the array environment can serve to create a simple table. One can add vertical lines by adding | symbols in the column format header, and horizontal lines with the \hline command inside the array.

Code: Select all
$\begin{array}{|c|r|}\text{symbol} & \quad\text{value} \\\hline\pi & 3.1415 \\e & 2.7182\end{array}$ -------------------------------------------------------------------------

I think I have now covered most of the Latex formatting that is currently possible with MathJax.

A full overview of Latex commands supported by MathJax can be found here:

http://www.mathjax.org/docs/1.1/tex.html#supported-latex-commands

If you have any comments, questions or additions, feel free to post!