$\LaTeX$ Template (v 1.3.0)

Chencheng Zhang
April 20, 2025

Abstract

This is a html-based $\LaTeX$ template for writing articles. This website is based on this outstanding repository, to whose author(s) we extend our sincere gratitude.

  • The repository: git@github.com:zhangchenchengSJTU/jekyll-latex.git.

对原模板的若干修改

(Add blocks). 本模板添加了若干数学公式环境, 例如

    This is a lemma.

    This is a proof.

    This is a corollary.

    This is a definition. 作者有意将 bottom-margin 调整至 2em.

    This is an example.

    This is a solution.

    This is a problem.

    This is a proposition.

    This is a slogan.

    This is a note.

    This is a question.

对 block 之图标, 样式, 编号逻辑等, 可在 _sass/main.scss_plugins/latex.rb 中修改.

(Block 内正常 markdown 语法). 数学环境中可直接使用 markdown 语言. 方法是将原插件 _plugins/latex.rb 中的

    class DefinitionBlock < Liquid::Block
      def render(context)
        text = super
        "<div class='definition'>#{text}</div>"
      end
    end
  end

添加 Jekyll::Converters::Markdown 过滤器. 最终效果是

    class DefinitionBlock < Liquid::Block
      def render(context)
        text = super  # 获取块内原始内容
        site = context.registers[:site]  # 获取 Jekyll 的 site 对象
        converter = site.find_converter_instance(Jekyll::Converters::Markdown)  # 获取 Markdown 转换器
        converted_content = converter.convert(text.strip)  # 将内容转换为 HTML
        "<div class='definition'>#{converted_content}</div>"  # 包裹转换后的内容
      end
    end

同时完美解决了下划线问题. 例如

  • 输入 1: $a_1$ and $a_2()_5$ and $(a_3)_2$
  • 输出 1: $a_1$ and $a_2()_5$ and $(a_3)_2$
  • 输入 2: _1_ + $2_3$ + 66_
  • 输出 2: 1 + $2_3$ + 66_

实现方式是脚本 _plugins/消灭傻逼下划线.rb, 让 markdown 文本努力变成过滤器能识别的样子.

(编号). 解决了原模板中无序编号显示有序的 🐛.

Why this template?

The real numbers $ℝ$ are uncountable.

By Cantor’s diagonal argument, we can show that the set of real numbers is uncountable.

$$ \begin{bmatrix} a_{1,1} & a_{1,2} & a_{1,3} & \cdots \\ a_{2,1} & a_{2,2} & a_{2,3} & \cdots \\ a_{3,1} & a_{3,2} & a_{3,3} & \cdots \\ ⋮ & ⋮ & ⋮ & ⋱ \end{bmatrix}. $$

\begin{equation} \mathtt{equation} 环境使用 𝒜 𝔟 ⊭ \frac 汉 字 也不会报错. \end{equation}

$$ \begin{aligned} 多行公式, & align\\ 显然. & Q.E.D. \end{aligned} $$

(html 较 $\LaTeX$ 的优越性). 该模板相较传统 $\LaTeX$ 模板之优点包括但不限于

  1. 毫秒级编译时间, 以下是部分文件的编译时间:

    Filename                                                                               | Count |   Bytes |  Time
    ...                                                                                    |   ... |     ... | ...  
    _posts/Draft/2025-05-03-Forget.md                                                      |     1 |   8.49K | 0.016
    _posts/AR_theories/2025-05-04-Coxeter-Reflection.md                                    |     1 |  14.82K | 0.014
    _posts/Homological_Categorical_theories/2025-05-03-Projective_Generators.md            |     1 |   6.10K | 0.013
    _posts/AR_theories/proof/2025-04-26-Commutative_Diagram_Alg.md                         |     1 |  27.74K | 0.013
    _posts/Spectral_sequences/proof/2025-04-29-Projlim_1_Vanish.md                         |     1 |   8.53K | 0.013
    _posts/Homological_Categorical_theories/proof/2025-04-21-Finitely_Presented_Functor.md |     1 |   5.32K | 0.012
    _posts/Spectral_sequences/proof/2025-04-28-Grothendieck_Spectral_Sequence.md           |     1 |  22.04K | 0.011
    _posts/Spectral_sequences/proof/2025-04-28-Kunneth_Spectral_Seq.md                     |     1 |  11.47K | 0.011
    _posts/Spectral_sequences/2025-04-27-Complete_Z_Filtration.md                          |     1 |   2.58K | 0.010
    _posts/AR_theories/proof/2025-04-27-Harada_Sai.md                                      |     1 |   2.86K | 0.010
    _posts/Homological_Categorical_theories/proof/2025-05-03-Equi_Def_Generator.md         |     1 |   1.95K | 0.009
    index.html                                                                             |     1 |   2.84K | 0.009
    _posts/Torsion_Pairs/proof/2025-04-27-KerHom_KerExt_TP.md                              |     1 |   4.80K | 0.009
    blog/page6/index.html                                                                  |     1 |   2.84K | 0.008
    _posts/Gabriel/proof/2025-04-24-Ringel_Resolution.md                                   |     1 |   4.61K | 0.008
    ...                                                                                    |   ... |     ... | ...  
    
  2. 将设备连接至同一局域网, 实现多屏协同: 电脑代码, 平板查看编译结果 (邀请连接).
  3. 兼容 Unicode-math $ℝ$ (数学环境), ℝ (文本环境), 无需手动调整 assymb 包的兼容性问题, 或字体问题等.
  4. 兼容多国语言混排: Hello, Bonjour, Olá, Здравствуйте, $\overset{\text{こん}}{\text{今}}\overset{\text{にち}}{\text{日}}\text{は}$, $\overset{\text{안}}{\text{安}}\overset{\text{녕}}{\text{寧}} \ \text{하세요}$, السلام عليكم, नमस्ते, Γειά σας, Cześć, สวัสดี, שלום, [ɲ̟ã̠ɴ].
  5. 输出连续网页, 避免 PDF 割裂图片或公式等. 当然, 打印网页即得 PDF 文档.
  6. 使用 URL 运行图片 ($\LaTeX$ 永远无法做到, 权宜的方式是使用 write18).
  7. 发布网页, 随时随地都可查看.
  8. 插入在线图片, 甚至 gif

    cat-space

  9. 视频也行

    上当了

  10. 排版语言公式简单 (前提: 配上合适的 html 代码环境).

(在 block 外使用 markdown 与 $\LaTeX$ 写作). 在 {% — %} — {% end— %} 外可直接使用 markdown 语言与 $\LaTeX$.

Graphs

(Tikz 功能). 使用插件 quiver 画图.

图像大小容易失衡, 建议使用 mathcha 画图, 输出矩阵, 例如

$$ \begin{bmatrix} M & → & F( M) & ↠ & C( M)\\ h⇣ \ & & g⇣ \ & & f⇣ \ \\ Ω ( N) & → & P( M) & ↠ & N \end{bmatrix}. $$

或者, 直接插入图片也行.

(Use mathcha to draw picture).

image-20250423194403416

在特殊情况下, 可直接使用 tikz 环境插入 quiver 代码 (小 bug, 需要将 textcolor 替换作 color). 可以使用行内公式 (推荐使用占位符, 使图宽度为 $4$ 格) , 或是行间公式



也可以使用 mathhcha (有时大小不匹配, 请自动加上 \scalebox{0.8}):



原理: 本地插件 jekyll-tikzq.uiver 语法下的箭图编译为 PDF 文件 (存放在 ./_tikz_tmp), 并通过上古神器 pdf2svg 自动生成 svg 矢量图 (存放在 ./svg).

一个重要的问题: 网页无法正常打印 q.uiver.appiframe 标签!

个性化

(自定义 Block). 支持 Definition, Theorem, Lemma, Proof, Solution, Example, Remark, Note, Corollary, Proposition, Slogan. 实现方式如下:

  1. /_sass/main.scss 中定义 solution 的样式 (包含前, 中, 后, 以及 QED 正方形).
  2. /_plugins/latex.rb 中定义 solution 公式块环境, 此处使用 {% sol %} {% endsol %} .

(创建 block 快捷键). 假设你是 vscode 用户, 以下是创建 \def 快捷键的方式.

  1. 打开 Ctrl+Shift+P > snippets : Configure Snippets,
  2. 选择或新建 liquid.json,
  3. 输入
"def": {
  "prefix": ["\\def", "defblock"],
  "body": [
  "{% def %}",
  "$0",
  "{% enddef %}"
  ]
},

即可通过 \def + enter 快速创建 definition 块.