More on Math Syntax

Posted by (user deleted) on 15 Oct 2008 01:06, last edited by Helmut_pdorf on 16 Oct 2008 09:13

Tags: equation formula math

rating: +2+x

A brief tutorial on using math symbols and equations in wikidot

In the following writeup, I explain the wiki syntax for entering mathematical symbols and equations. A rudimentary knowledge of typesetting math with $\LaTeX$ will help you understand the writeup much easier.

Inline Equations

In $\LaTeX$, in-line math commands begin and end with $. In wikidot, one enters inline math by enclosing the $\LaTeX$ commands including the $ symbols with [[ and ]]. So, for example, if you want the in-line equation $\alpha + \beta = \gamma$, we would type the following: [[$ \alpha + \beta = \gamma$]]. Note that in $\LaTeX$, you would type just $ \alpha + \beta = \gamma$ without the double square brackets.

Alternatively, you can click on the in-line equation button in the wikidot editor to enter inline equations. When you click on this button, the editor will insert the string [[$ insert LaTeX equation here $]] at the current position of the cursor. All you then have to do is replace "insert LaTeX equation here" with $\LaTeX$ commands.

Display Math (Equations)

Single Line Equations

In $\LaTeX$, one can use the equation environment to display single-line equations. For example,

\begin{equation}
    S_{ij,j} + \rho b_i = 0
\end{equation}

would display(1)
\begin{align} S_{ij,j} + \rho b_i = 0 \end{equation} \end{align}

Note the equation number displayed on the right. If you want to reference this number anywhere in the text, you can use the \label tag. In $\LaTeX$, you would include this in the equation environment as follows:

\begin{equation}\label{equil}
    S_{ij,j} + \rho b_i = 0
\end{equation}

which would appear as(2)
\begin{align} S_{ij,j} + \rho b_i = 0 \end{align}

The equation number can now be referenced with \ref{equil} or even better, \eqref{equil}. Note that the text (tag) used to label equations (here, "equil") can be anything. Of course, for each equation, you would want to use different tags. So, suppose that we would like to reference the equation number in a follow-up text:

Note that, since $i$ is a free index, Equation \eqref{equil} represents three equations (equilibrium equations).

which would appear as "Note that, since $i$ is a free index, equation 2 represents three equations (equilibrium equations)."

In Wikidot, typing equations is made considerably simpler. The simplest way is to click on the "square root of x" button in the edit menu. This action would insert the necessary tags and all that you need to be concerned about is the $\LaTeX$ syntax for the actual equations, i.e., the stuff between the \begin{equation} and \end{equation} environment tags. Let's look at an example. In wikidot math syntax, equation 2 can be entered by first clicking on the mathematical expression button (the "square root of x" button) which would insert the following code:

[[math]]
insert LaTeX equation here
[[/math]]

We then replace the "insert LaTeX equation here" by our equation:

[[math equil]]
    S_{ij,j} + \rho b_i = 0
[[/math]]

Note that I also added the optional "equil" label to the [[math]] block tag. The label can then be used to reference equation numbers. Again, wikidot provides an easy way to reference equations by providing the "Eq. (n)" button in its edit menu. Upon clicking on this button, you will be given a list of all the labels present in the current document and you can choose the one that you want to autoreference.

Multiline Equations

If you have equations that span multilines or if you want to have numbered multiline equations, you can use the align environment or split construction in $\LaTeX$.

\begin{equation}
 \begin{split}
    \mathbf{T n} &= \left[T_{ij} \mathbf{e}_i \otimes \mathbf{e}_j \right] n_k \mathbf{e}_k \\
                        & = T_{ij} n_k \left(\mathbf{e}_i \otimes \mathbf{e}_j\right) \mathbf{e}_k \\
                        & = T_{ij} n_j (\mathbf{e}_i
 \end{split}
\end{equation}

which would be displayed as(3)
\begin{split} \mathbf{T n} &= \left[T_{ij} \mathbf{e}_i \otimes \mathbf{e}_j \right] n_k \mathbf{e}_k \\ & = T_{ij} n_k \left(\mathbf{e}_i \otimes \mathbf{e}_j\right) \mathbf{e}_k \\ & = T_{ij} n_j \mathbf{e}_i \end{split}

The \\ at the end of each line represent line breaks for equations. The & before = sign in each line is there to say that all the equations should be aligned with the = sign as a reference.

In Wikidot, you would simply type the following:

[[math]]
 \begin{split}
    \mathbf{T n} &= \left[T_{ij} \mathbf{e}_i \otimes \mathbf{e}_j \right] n_k \mathbf{e}_k \\
                        & = T_{ij} n_k \left(\mathbf{e}_i \otimes \mathbf{e}_j\right) \mathbf{e}_k \\
                        & = T_{ij} n_j \mathbf{e}_i
 \end{split}
[[/math]]

Arrays

If you want to matrices to be displayed, you can use the $\LaTeX$ array environment. For example, to get

(4)
\begin{align} \left[ \begin{array}{ccc} T_{11} & T_{12} & T_{13} \\ T_{21} & T_{22} & T_{23} \\ T_{31} & T_{32} & T_{33} \end{array} \right] \end{align}

one would type

[[math]]
\left[
  \begin{array}{ccc}
    T_{11} & T_{12} & T_{13} \\
    T_{21} & T_{22} & T_{23} \\
    T_{31} & T_{32} & T_{33} 
  \end{array}
\right]
[[/math]]

Let's dissect the above code. \left[ and \right] produce the large square brackets around the matrix. The matrix contents are output using the array environment. Each matrix component is separated by & and each row is separated by \\. Each letter in {ccc} represents a column and that all the entries in each column should be centered. If you want left or right alignment for any of the columns, you would replace the corresponding c by l or r. The number of letters in braces immediately following \begin{array} represent the number of columns.

Similarly, if you want the following equation

(5)
\begin{align} \left\{ \begin{array}{c} t_1 \\ t_2 \\ t_3 \end{array} \right\} = \left[ \begin{array}{ccc} T_{11} & T_{12} & T_{13} \\ T_{21} & T_{22} & T_{23} \\ T_{31} & T_{32} & T_{33} \end{array} \right] \left\{ \begin{array}{c} n_1 \\ n_2 \\ n_3 \end{array} \right\} \end{align}

you would use the following code:

[[math]]
 \left\{
 \begin{array}{c}
    t_1 \\ t_2 \\ t_3
 \end{array}
 \right\} =
 \left[ 
 \begin{array}{ccc}
    T_{11} & T_{12} & T_{13} \\
    T_{21} & T_{22} & T_{23} \\
    T_{31} & T_{32} & T_{33} 
 \end{array} 
 \right]
 \left\{
 \begin{array}{c}
    n_1 \\ n_2 \\ n_3
 \end{array}
 \right\}
[[/math]]

Note that in the above, to get curly braces, we used \left\{ and \right\} instead of \left{ and \right}. The reason for this is that { and } have special meaning in $\LaTeX$ and therefore, to typeset the braces, you have to use \{ and \}. This will allow the special meaning to be "escaped".
Add a New Comment

Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.