LaTeX environment
JLaTeXMath provides a number of different environments to work with. Each environment begins and ends in the same manner:
\begin{environment}[options]
...
\end{environment}
The following environments are supported:
• tabular | • array | • matrix (and variants) | • eqnarray |
• align | • cases | • split | • multline |
1. Tabular and Array
The tabular and array environment work in similar way and can be used to typeset material with optional horizontal and vertical lines. The options are:
Example 1:
l | left-justified column | c | centered column | r | right-justified column |
| | vertical line | || | double vertical line | & | column separator |
\\ | start new row | \hline|| horizontal line |
\begin{tabular}{| l |c ||r |}
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
Other example, using \multicolumn
and array is the following.
Example 2:
\begin{array}{|c|c|}
\hline
\multicolumn{2}{|c|}{\text{Title}} \\
\hline
x & y\\ \hline
a & b\\
c & c\\
d & e\\ \hline
\end{array}
If you need to add column separator (+
for example) and space (1cm), use:
@{{\hspace{1cm}+\hspace{1cm}}}
Example 3:
\begin{tabular}{r@{{\hspace{1cm}+\hspace{1cm}}}l}
1 & 23 \\
45 & 678 \\
910 & 1112 \\
\end{tabular}
2. Matrix
A basic matrix may be created using the matrix environment. The structures are similar to table-array, entries are specified by row, with columns separated using
Example:
&
and new rows separated with \\
.
Matrices are usually enclosed in delimiters (default none) of some kind, and while it is possible to use the \left
and \right
commands.
The predefined environments which automatically include delimiters:
pmatrix | ( ) | bmatrix | [ ] | Bmatrix | { } |
vmatrix | | | | Vmatrix | || || |
\mathsf{A}_{m,n} =
\begin{Vmatrix}
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{Vmatrix}
2.1 Small Matrix
Sometimes you need to write a matrix within text, for this environment we have smallmatrix. This works the same way the matrix environment, for example:
\mathsf{M} =
\left\{
\begin{smallmatrix}
a & b \\
c & d
\end{smallmatrix}
\right\}
3. Eqnarray
This environment is designed to write multiline equations or equations that exceed the width of line, it behaves like an array of three columns where the Vrst aligned right, center second and third left. The equations we want to present in this way must be enclosed between
\begin{eqnarray}
and \end{eqnarray}
Example:
\begin{eqnarray}
y & = & (x+1)^2 \\
& = & x^2+2x+1
\end{eqnarray}
5. Cases
For piece-wise functions, or definitions, use the cases environment.
Example:
\left\vert x\right\vert =
\begin{cases}
\hphantom{-}x &,\, \text{if }x\geq 0 ,\\
-x&,\, \text{if }x<0
\end{cases}
6. Split
For splitting a long math block.
Example:
\begin{split}
a & = b+c-d \\
& \quad +e-f \\
& = g+h\\
& = i
\end{split}
7. Multiline
For multiple lines of math.
Example:
\begin{multline}
\left(a+b+c+d+e\right)^2 = a^2+b^2+c^2+d^2+e^2 \\
+2ab+2ac+2ad+2ae+2bc+2bd+2be+2cd+2ce+2de
\end{multline}