Addition on April 2, 2009

The post below was my first atempt to use LaTeX in the WordPress environment.  It shows some quick examples that I used as tests to find what works and what doesn’t work and which were the differences between  WordPress LaTeX and the standard version found at CTAN (Comprehensive TeX Archive Network). Further, I made some other posts reporting more sistematic experiments that became a reference for my own use of WordPress LaTeX.

These are the other posts:

This is the original post (with the so-called funny examples):

_________________________________________________________________________

March, 10, 2008

Now it’s time to try using WordPress blog support to LaTeX. It seems pretty easy. You only need two things:

  1. To read this announcement.
  2. To know a bit about LaTeX (find a LaTeX primer here).

Let’s try some basic thing:

\frac{100}{20} = 5

To do it just write $ latex \frac{100}{20} = 5 $ , following the indications on the announcement.

Hint: 1. to display the LaTeX syntax without parsing it just put a space between $ and latex statements.

Hint: 2. You can write the latex statements straight on the “Visual” tab of the editing interface – you don’t have to go to the “Code” tab to do it.

Let’s now do some more complex things:

$ latex \frac{x+y}{a} + \frac{x-y}{b} = \frac{b(x+y) +a(x-y)}{ab} $ gives:

\frac{x+y}{a} + \frac{x-y}{b} = \frac{b(x+y) +a(x-y)}{ab}

In order to display with a greater font size you add &s=X at the end of the expression, as shown below. The X value is illustrated in the announcement.

$ latex \frac{x+y}{a} + \frac{x-y}{b} = \frac{b(x+y) +a(x-y)}{ab} &s=1$ gives:

\frac{x+y}{a} + \frac{x-y}{b} = \frac{b(x+y) +a(x-y)}{ab}

$ latex \frac{x+y}{a} + \frac{x-y}{b} = \frac{b(x+y) +a(x-y)}{ab} &s=2$ gives:

\frac{x+y}{a} + \frac{x-y}{b} = \frac{b(x+y) +a(x-y)}{ab}

OK, now I have finished the \LaTeX for Dummies level. Let us improve a bit more !

More math statements

In the following examples, I’ve changed the color of the formula by adding the statement &fg=aa0000 before the &s=1. The string represents the RGB values of the desired color in hexadecimal notation: rrggbb. The statement fg indicates foreground color. Of course bg is used for the background. See the announcement.

$ latex a_0 x^2 + a_1 x + a_2 = 0 &fg=aa0000&s=1$ gives: a_0 x^2 + a_1 x + a_2 = 0

Warning: don’t put any spaces between statements that specify changes in the math environment. Example: &fg=aa0000&s=1 and not &fg=aa0000 &s=1.

For the next four examples, I’ve omitted the formatting statements, for the sake of clarity:

x = \frac{-b \pm \sqrt{b^2 – 4ac}}{2a} gives: x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

\int_a^b f(x)dx = {\cal F}_{a,b} gives: \int_a^b f(x)dx = {\cal F}_{a,b}

\lim\limits_{n \rightarrow \infty} \sum\limits_{i=0}^n \sum_j \alpha_{ij} gives: \lim\limits_{n \rightarrow \infty} \sum\limits_{i=0}^n \sum_j \alpha_{ij}

\frac{1}{1+ \frac{1}{1+x}}\leq y^2*\log_{n}{\delta} gives: \frac{1}{1+ \frac{1}{1+x}}\leq y^2*\log_{n}{\delta}

Math environments

Now we’ll try some multiline expressions:

$ latex (x+y)(x-y) = x^2 – xy + yx – y^2 \\ = x^2 – y^2 \\ (x+y)^2 = x^2 + 2xy + y^2 &fg=aa0000&s=1$

that gives:

(x+y)(x-y) =  x^2 - xy + yx - y^2  \\ =  x^2 - y^2 \\ (x+y)^2 = x^2 + 2xy + y^2

Notice that the expression lines are correct, however they are not properly aligned. You can do the alignment by using the statement {array}. Suppose that you want to align the = signals:

$ latex \begin{array}{ccc} (x+y)(x-y) & = & x^2 – xy + yx – y^2 \\ & = & x^2 – y^2 \\ (x+y)^2 & = & x^2 + 2xy + y^2 \end{array} &fg=aa0000&s=1$

that gives:

\begin{array}{ccc} (x+y)(x-y) & = &  x^2 - xy + yx - y^2  \\ & =  & x^2 - y^2 \\ (x+y)^2 & = & x^2 + 2xy + y^2  \end{array}

The declaration {ccc} specifies the columns in each line, as if your multiline expression could be treated as a table. The letters specify the indentation of each column: c = center, l= left, r = right.

Matrices

Here, there is an example of how to assemble a matrix:

\left| \begin{array}{cc} x_{11} & x_{12} \\ x_{21} & x_{22} \end{array} \right|

\left| \begin{array}{cc} x_{11} & x_{12} \\ x_{21} & x_{22}  \end{array} \right|

Obs – For the sake of clarity, the $ latex &fg=aa0000&s=1$ was not shown in the last declaration.

So, the ideal template to use with mathematical formulas is:

$ latex formula &fg=aa0000&s=1$

To use it, choose the font color by changing properly the values in the declaration &fg=rrggbb (remember: RGB, in hexadecimal, taking values on 00…ff) and set the font size with &s=n, being n the number indicating the size. Don’t forget that in the template above a space was put between the $ and latex, you must suppress it !