在 Anki 上更改 MathJax 的字体大小
Changing MathJax's font size on Anki
几个月来我一直在使用 Anki 和 MathJax,但桌面上的字体大小非常小(不过在 AnkiDroid 上很好)。我每次使用 MathJax 时都使用 \huge 来绕过它,但这显然不是最好的解决方案。它还使移动设备上的所有内容都太大了。
我的 MathJax 的配置与 this post. I've searched how to edit MathJax's scaling and font size but nothing worked (e.g. 中的一样),它大部分都以破坏它而告终。
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
showProcessingMessages:false,
tex2jax:{
inlineMath: [['$','$']],
displayMath:[['$$','$$']],
processEscapes:true
}
});
另外,我的卡设置:
.card {
font-family: arial;
font-size: 20px;
text-align: center;
color: black;
background-color: white;
}
.cloze {
font-weight: bold;
color: blue;
}
默认大小(太小)和\huge(更合理):
我知道这应该很容易。如果可能的话,也许会大大减少 MathJax 的缩放比例。
编辑:Alistair Martin 基本上解决了它(桌面和 AnkiDroid 都很好)。它是这样工作的:
<script type="text/x-mathjax-config">
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
messageStyle: 'none',
showProcessingMessages: false,
tex2jax: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
processEscapes: true
},
SVG: {
scale: (!!navigator.userAgent.match(/(mac)|(mobile)/i) ? 100 : 180)
}
});
</script>
<script type="text/javascript">
(function() {
if (window.MathJax != null) {
var card = document.querySelector('.card');
MathJax.Hub.Queue(['Typeset', MathJax.Hub, card]);
return;
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_SVG';
document.body.appendChild(script);
})();
</script>
到目前为止,这是对我有用的方法:
- 更改为 SVG。这意味着将 url 参数更改为
?config=TeX-MML-AM_SVG
,如您链接的 the article 中所述。
- 更改 card/s 开头的 JS 脚本以包含 SVG 比例,其值基于设备
像这样:
<script type="text/x-mathjax-config">
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
messageStyle: 'none',
showProcessingMessages: false,
tex2jax: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
processEscapes: true
},
SVG: {
scale: (!!navigator.userAgent.match(/(mac)|(mobile)/i) ? 100 : 180)
}
});
</script>
^ 这里 100 是 Ankidroid 和 macOS 的百分比比例,180 是 Windows.
的百分比比例
几个月来我一直在使用 Anki 和 MathJax,但桌面上的字体大小非常小(不过在 AnkiDroid 上很好)。我每次使用 MathJax 时都使用 \huge 来绕过它,但这显然不是最好的解决方案。它还使移动设备上的所有内容都太大了。
我的 MathJax 的配置与 this post. I've searched how to edit MathJax's scaling and font size but nothing worked (e.g. 中的一样),它大部分都以破坏它而告终。
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
showProcessingMessages:false,
tex2jax:{
inlineMath: [['$','$']],
displayMath:[['$$','$$']],
processEscapes:true
}
});
另外,我的卡设置:
.card {
font-family: arial;
font-size: 20px;
text-align: center;
color: black;
background-color: white;
}
.cloze {
font-weight: bold;
color: blue;
}
默认大小(太小)和\huge(更合理):
我知道这应该很容易。如果可能的话,也许会大大减少 MathJax 的缩放比例。
编辑:Alistair Martin 基本上解决了它(桌面和 AnkiDroid 都很好)。它是这样工作的:
<script type="text/x-mathjax-config">
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
messageStyle: 'none',
showProcessingMessages: false,
tex2jax: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
processEscapes: true
},
SVG: {
scale: (!!navigator.userAgent.match(/(mac)|(mobile)/i) ? 100 : 180)
}
});
</script>
<script type="text/javascript">
(function() {
if (window.MathJax != null) {
var card = document.querySelector('.card');
MathJax.Hub.Queue(['Typeset', MathJax.Hub, card]);
return;
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_SVG';
document.body.appendChild(script);
})();
</script>
到目前为止,这是对我有用的方法:
- 更改为 SVG。这意味着将 url 参数更改为
?config=TeX-MML-AM_SVG
,如您链接的 the article 中所述。 - 更改 card/s 开头的 JS 脚本以包含 SVG 比例,其值基于设备
像这样:
<script type="text/x-mathjax-config">
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
messageStyle: 'none',
showProcessingMessages: false,
tex2jax: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
processEscapes: true
},
SVG: {
scale: (!!navigator.userAgent.match(/(mac)|(mobile)/i) ? 100 : 180)
}
});
</script>
^ 这里 100 是 Ankidroid 和 macOS 的百分比比例,180 是 Windows.
的百分比比例