The Joy of LaTeX: Baby Steps

WordPress.com supports LaTeX!

I went to the WordPress.com forums to ask for help displaying mathematical formulas. A kind soul responded that WordPress supports LaTeX, a tool I had heard of, so powerful that it could be used to prepare a dissertation for a Mathematics Ph.D.

Great! Except that I had never used LaTeX. But armed with the link from the forums and this online reference, I was able to puzzle out what I needed. If you are interested, here are a few nuggets I found.

Preliminaries

LaTeX is a markup language. You use regular text to indicate placement and size of symbols, Greek letters, functions, superscripts, etc.

Within you WordPress post, LaTeX expressions occur between $latex and a closing $. These expression delimiters can occur on the same line or on different lines, embedded in text or stand-alone.

When adding LaTeX expressions to your blog post, you should use the HTML tab of the editor, so that your expressions are not escaped.

You can include optional styling specifications between an ampersand and the trailing $ For example, to request a size of 4 (really big), for function f of x you would use $latex f(x)&s=4$, which would render as:

f(x)

Examples

Here are some examples of what LaTeX can do, and how to do it.

x^2

…is generated from

$latex
x^2
&s=2$

An inline reference to function f(x)

is generated from:

An inline reference to function $latex f(x)$...

The {(n + 1)}^{th} value of x is x_{n + 1}

is generated from:

The $latex {(n + 1)}^{th}$ value of $latex x$ is $latex x_{n + 1}$

The formula for variance:

\frac{\Sigma(x - \mu)^2}{N}

is generated from:

$latex
\frac{\Sigma(x - \mu)^2}{N}
&s=2$

An alternative formula for variance:

\frac{\Sigma(x^2)}{N} - \frac{(\Sigma(x))^2}{N^2}

is generated from

$latex
\frac{\Sigma(x^2)}{N} - \frac{(\Sigma(x))^2}{N^2}
&s=2$

Summary

  • Embed LaTeX expressions between $latex and $
  • The delimiters $latex and closing $ can be on the same line or different lines.
  • Styling parameters for LaTeX can be specified between an ampersand and the closing $. E.g, $latex x&s=5$ sets the size to 5 (very large).
  • Minus sign is hyphen, plus sign is plus sign, super-script is caret, subscript is underscore.
  • Braces are used to group, e.g., expressions in a subscript: $latex x_{n – 1}$ for x_{n - 1}.
  • Greek letters are spelled out and preceded by a back-slash. Initial cap for upper case. E.g., $latex \Sigma$ renders as \Sigma; all lower-case for lowercase Greek letter. E.g., $latex \pi$ renders as \pi.
  • Online reference for LaTeX is here.

Happy typesetting!

Advertisements

2 thoughts on “The Joy of LaTeX: Baby Steps

  1. rstinejr says:

    Every time I tweak this code, I unescape my references to LaTeX syntax and end up rendering the processed strings rather than the LaTeX source. I’ve repaired that every time I’ve noticed; sorry if you have caught the post in an in-between state. At this point, I think I’m going to try to leave the thing alone.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s