Using Kramdown to Enable LaTeX Equations on Octopress

Following these instructions I was able to get $\LaTeX$ equations interpreted and rendered correctly when posting to Octopress. It consists of installing the kramdown Markdown interpreter, updating the _config.yml and Gemfile, and putting the MathJax CDN and configs in source/_layouts/default.html.

For example, this block of code (taken from the aforementioned site):

1
2
3
4
5
6
7
$$
\begin{align}
\mbox{Union: } & A\cup B = \{x\mid x\in A \mbox{ or } x\in B\} \\
\mbox{Concatenation: } & A\circ B  = \{xy\mid x\in A \mbox{ and } y\in B\} \\
\mbox{Star: } & A^\star  = \{x_1x_2\ldots x_k \mid  k\geq 0 \mbox{ and each } x_i\in A\} \\
\end{align}
$$

is translated into this:

QAPLA’!

EDIT: I forgot to metion something that causes a little trouble when editing the Gemfile. When replacing gem 'rdiscount' with gem 'kramdown', the version number after the '~>' needs to be replaced as well. At the time of writing putting the current version number (0.14.1) for kramdown causes an error when running rake generate:

1
2
3
4
5
6
7
$ rake generate
You have requested:
  kramdown ~> 0.14.1

The bundle currently has kramdown locked at 0.13.8.
Try running `bundle update kramdown`
Run `bundle install` to install missing gems.

To fix this, replace gem 'kramdown', '~> 0.14.1' with gem 'kramdown', '~> 0.13.8' in the Gemfile. Running rake generate is now successful:

1
2
3
4
5
6
$ rake generate
## Generating Site with Jekyll
unchanged sass/screen.scss
Configuration from /path/to/Octopress/_config.yml
Building site: source -> public
Successfully generated site: source -> public

Comments