Replies: 12 comments
-
did you configure the https://imfing.github.io/hextra/docs/guide/latex/#separate-paragraph |
Beta Was this translation helpful? Give feedback.
-
No ; and then I copy-paste the configuration provided in the link , and it doesn't work . Here is the result when I use |
Beta Was this translation helpful? Give feedback.
-
I tried integrating mathjax and xyjax on another theme called FixIt , and it works well Oh by the way for KaTeX the |
Beta Was this translation helpful? Give feedback.
-
@ych817 I tried it, and seems it worked fine. I needed to add a custom Below is the diff of the files I created/modified in https://github.com/imfing/hextra-starter-template diff --git a/content/_index.md b/content/_index.md
index 72f68d8..0947f48 100644
--- a/content/_index.md
+++ b/content/_index.md
@@ -1,6 +1,7 @@
---
title: My Site
toc: false
+math: true
---
This is the landing page.
@@ -12,6 +13,34 @@ This is the landing page.
{{< card link="about" title="About" icon="user" >}}
{{< /cards >}}
+When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
+$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$
+
+$$
+\begin{xy}
+\xymatrix{
+U \ar@/_/[ddr]_y \ar@{.>}[dr]|{\langle x,y \rangle} \ar@/^/[drr]^x \\
+ & X \times_Z Y \ar[d]^q \ar[r]_p & X \ar[d]_f \\
+ & Y \ar[r]^g & Z
+}
+\end{xy}
+$$
+
+$$
+\begin{xy}
+\xymatrix {
+*\txt{start} \ar[r]
+ & *++[o][F-]{0} \ar@(r,u)[]^b \ar[r]_a
+ & *++[o][F-]{1} \ar[r]^b \ar@(r,d)[]_a
+ & *++[o][F-]{2} \ar[r]^b
+ \ar `dr_l[l] `_ur[l] _(.2)a[l]
+ & *++[o][F=]{3}
+ \ar `ur^l[lll] `^dr[lll]^b [lll]
+ \ar `dr_l[ll] `_ur[ll] [ll]
+}
+\end{xy}
+$$
+
## Documentation
For more information, visit [Hextra](https://imfing.github.io/hextra).
diff --git a/hugo.yaml b/hugo.yaml
index 30f9991..9b0a988 100644
--- a/hugo.yaml
+++ b/hugo.yaml
@@ -11,6 +11,12 @@ markup:
goldmark:
renderer:
unsafe: true
+ extensions:
+ passthrough:
+ delimiters:
+ block: [['\[', '\]'], ['$$', '$$']]
+ inline: [['\(', '\)'], ['$', '$']]
+ enable: true
# enable hextra syntax highlight
highlight:
diff --git a/layouts/partials/scripts/katex.html b/layouts/partials/scripts/katex.html
new file mode 100644
index 0000000..8ee37a6
--- /dev/null
+++ b/layouts/partials/scripts/katex.html
@@ -0,0 +1,21 @@
+<script>
+ MathJax = {
+ loader: {
+ load: ['[custom]/xypic.js'],
+ paths: {custom: 'https://cdn.jsdelivr.net/gh/sonoisa/XyJax-v3@3.0.1/build/'}
+ },
+ tex: {
+ displayMath: [['\\[', '\\]'], ['$$', '$$']], // block
+ inlineMath: [['\\(', '\\)'], ['$', '$']], // inline
+ packages: {'[+]': ['xypic']},
+ processEscapes: true,
+ processEnvironments: true,
+ }
+ };
+</script>
+<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg-full.js"></script>
+<style>
+mjx-container {
+ display: inline-block;
+}
+</style>
\ No newline at end of file |
Beta Was this translation helpful? Give feedback.
-
感谢 ; ) 如另有与 mathjax 的问题我会继续在此帖下留言 |
Beta Was this translation helpful? Give feedback.
-
对了 您发给我的截图 数学公式的 baseline 似乎并没有与外部文字持平 。数学公式的 baseline 比其他文字较高 。 |
Beta Was this translation helpful? Give feedback.
-
guess we have to add some custom CSS rules to align the texts in the paragraph tag e.g. <style>
mjx-container {
display: inline-flex;
vertical-align: middle;
}
p {
display: flex;
align-items: center;
flex-wrap: wrap;
}
</style> |
Beta Was this translation helpful? Give feedback.
-
Thanks ! That looks better : ) |
Beta Was this translation helpful? Give feedback.
-
但是这样做数学公式后的空格会被吃掉 , 有没有比较恰当的解决办法呢 ? 另外注意到对于 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Another question : Under the circumstance of using |
Beta Was this translation helpful? Give feedback.
-
yep, it’s definitely possible using CSS, similar to how rendered math equations can be inlined. You can find tutorials and examples online on this or you can ask AI regarding how to write the rules |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
您好 我尝试将 katex 替换为 mathjax 并为后者添加 xyjax-v3 , 下面是我的操作 :
将 hextra 主题作为 git submodule 安装
在
./themes/hextra/assets/lib/
下新建文件夹mathjax
并从此处 下载tex-chtml-full.js
以及tex-svg-full.js
在
./themes/hextra/layouts/partials/scripts/
下新建文件mathjax.html
, 下面是文件内容 :对应地修改
./themes/layouts/partials/scripts.html
里关于katex
的部分为如下 :然而我遇到了两个问题 :
tex-svg-full.js
那么行内公式也会变成行间公式 ;如果加载的是
tex-chtml-full.js
那么公式的字体会变得很奇怪 。xyjax
在这里完全不起作用 。下面是我拿裸的html
测试的tex-chtml-full.js
/tex-svg-full.js
外加xypic.js
的效果 :下面是 hextra 的效果 :
Beta Was this translation helpful? Give feedback.
All reactions