【问题标题】:Changing MathJax's font size on Anki在 Anki 上更改 MathJax 的字体大小
【发布时间】:2018-12-09 23:16:04
【问题描述】:

我已经使用 Anki 和 MathJax 几个月了,但是在桌面上字体大小非常小(不过在 AnkiDroid 上很好)。我每次使用 MathJax 时都使用 \huge 来解决它,但这显然不是最好的解决方案。它还使移动设备上的所有内容都变得太大。

我的 MathJax 配置为 this post。我已经搜索了如何编辑 MathJax 的缩放和字体大小,但没有任何效果(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>

【问题讨论】:

  • 请提供现场样品。
  • 抱歉,我不知道该怎么做。但我附上了一张图片。
  • 您有指向实时页面的链接吗?这很可能是特定上下文的问题。

标签: latex mathjax anki


【解决方案1】:

到目前为止,这对我有用:

  1. 更改为 SVG。这意味着将 url 参数更改为 ?config=TeX-MML-AM_SVG,如您链接的 the article 中所述。
  2. 更改卡片开头的 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 的百分比。

【讨论】:

  • 这真是太好了。按预期工作。另外,MathJax 正在加载,所以我有点忽略了他提到 SVG 的部分...
猜你喜欢
  • 2013-10-05
  • 1970-01-01
  • 2021-10-21
  • 1970-01-01
  • 2021-10-30
  • 1970-01-01
  • 2020-12-09
  • 1970-01-01
  • 2019-09-22
相关资源
最近更新 更多