滴水穿石

海纳百川,有容乃大;壁立千仞,无欲则刚

Octopress Latex

首先安装kramdown

1
gem install kramdown

再把下面的代码添加到.theme/<使用的主题名>/source/_includes/custom/head.html文件中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript"
   src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

修改_config.yml

1
markdown: kramdown  #rdiscount

Attentation

使用kramdown时,对markdown的语法比rdiscount更加严格,例如```lang之前必须空行 以##为标题的之后不能有空行

右键点击页面消失

fix for right-click
1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/sass/base/_theme.scss b/sass/base/_theme.scss
index 9a50a8b..fc9dc37 100644
--- a/sass/base/_theme.scss
+++ b/sass/base/_theme.scss
@@ -75,7 +75,7 @@ html {
   background: $page-bg image-url('line-tile.png') top left;
 }
 body {
-  > div {
+  > div#main {
     background: $sidebar-bg $noise-bg;
     border-bottom: 1px solid $page-border-bottom;
     > div {

样例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$$
\begin{align*}
  & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right)
  = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\
  & (x_1, \ldots, x_n) \left( \begin{array}{ccc}
      \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\
      \vdots & \ddots & \vdots \\
      \phi(e_n, e_1) & \cdots & \phi(e_n, e_n)
    \end{array} \right)
  \left( \begin{array}{c}
      y_1 \\
      \vdots \\
      y_n
    \end{array} \right)
\end{align*}
$$

就会得到

1
段内插入公式:$\exp(-\frac{x^2}{2})$

段内插入公式:$\exp(-\frac{x^2}{2})$