Octopress 默认不支持 LaTex 写数学公式,这里修改 Octopress 使其支持。
测试
整段 LaTex 公式
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_ 1 x_ 2 \ldots x_k \mid k \geq 0 \mbox { and each } x_i \in A \} \\
\end {align}
$$
内嵌 LaTex 公式
1
2
If $ a^ 2 = b $ and $ b = 2 $ , then the solution must be
either $ a =+ \sqrt { 2 } $ or $ a =- \sqrt { 2 } $ .
If $a^2=b$ and $b=2$, then the solution must be
either $a=+\sqrt{2}$ or $a=-\sqrt{2}$.
设置
1.用 kramdown 代替 rdiscount
修改_config.yml
把_config.yml
中所有rdiscount
替换成kramdown
。
1
2
3
4
5
6
7
8
9
10
11
12
13
--- a/_config.yml
+++ b/_config.yml
@@ -34,8 +34,8 @@ destination: public
plugins: plugins
code_dir: downloads/code
category_dir: blog/categories
-markdown: rdiscount
-rdiscount:
+markdown: kramdown
+kramdown:
extensions:
- autolink
- footnotes
在Gemfile
中把gem 'ridiscount'
改成gem 'kramdown in Gemfile
1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/Gemfile b/Gemfile
index cd8ce57..e1d8d30 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,7 +3,7 @@ source "https://rubygems.org"
group :development do
gem 'rake', '~> 0.9'
gem 'jekyll', '~> 0.12'
- gem 'rdiscount', '~> 2.0.7'
+ gem 'kramdown'
gem 'pygments.rb', '~> 0.3.4'
gem 'RedCloth', '~> 4.2.9'
2.添加 MathJax 配置在/source/_includes/custom/head.html
文件里添加1 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- mathjax config similar to math . stackexchange -->
< script type = "text/x-mathjax-config" >
MathJax . Hub . Config ({
jax : [ "input/TeX" , "output/HTML-CSS" ],
tex2jax : {
inlineMath : [ [ '$' , '$' ] ],
displayMath : [ [ '$$' , '$$' ]],
processEscapes : true ,
skipTags : [ 'script' , 'noscript' , 'style' , 'textarea' , 'pre' , 'code' ]
},
messageStyle : "none" ,
"HTML-CSS" : { preferredFont : "TeX" , availableFonts : [ "STIX" , "TeX" ] }
});
< /script>
< script src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type = "text/javascript" >< /script>
3.修复 MathJax 右击页面空白 bug2
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 c35136d..3ee3999 100644
--- a/sass/base/_theme.scss
+++ b/sass/base/_theme.scss
@@ -74,7 +74,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 {
更多信息