为MathJax设置CSS样式,颜色 [英] Setting CSS styles, color, for MathJax
问题描述
我正在尝试为我的MathJax输出添加样式.特别是,我想为方程式设置全局颜色(以使其与页面其余部分的样式匹配).目前,我有以下配置.
Hi I am trying to add styles to my MathJax output. In particular I would like to set a global color for my equations (so that it matches the styles on the rest of my page). Currently I have the following configuration.
<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"],
styles: {".MathJax" {color: "#CCCCCC";}}
}
});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type="text/javascript"></script>
但是,如果我在配置中包含styles
标记,则页面上的数学运算根本不会显示.另一方面,如果我将其删除,它会显示正常.
However if I include the styles
tag in my configuration the math on my page just refuses to display at all. On the other hand if I remove it, it displays fine.
我还应该注意,我曾尝试按照其他问题的建议将样式直接添加到CSS中,但这导致了同样的事情,根本没有显示任何数学运算.
I should also note that I have tried adding the styles directly to my CSS as suggested in other questions but this resulted in the same thing, no math being displayed at all.
更新:我在下面添加了:,如Davide所建议的那样,现在我的方程式已显示,但样式信息被忽略.样式似乎是从页面的主体继承的,但是将数学内容包装在具有不同样式的div中似乎也不会对其产生影响.
UPDATE: I have added the : as Davide suggests below, now my equations display but the styling information is ignored. The styling seems to be inherited from the body of the page but wrapping the math in a div with different styling doesn't seem to affect it either.
UPDATE2:我已经解决了mathjax忽略样式命令的问题.文本的颜色由CSS * {colour:#292929}中的一行全局设置.这意味着MathJax中的样式将被忽略.只需将*更改为body,即可解决a,p,h1,h2的问题.
UPDATE2: I have solved my the issue of the mathjax ignoring style commands. The color for text was globally set by a line in my CSS * { colour: #292929 }. This meant that the style from MathJax was being ignored. Simply changing * to body, a, p, h1, h2 fixed the issue.
推荐答案
在".MathJax"
之后,您缺少冒号.您的代码应为
You are missing the colon after ".MathJax"
. Your code should be
<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"],
styles: {".MathJax": {color: "#CCCCCC"}}
}
});
</script>
然后它应该对您有用.
这篇关于为MathJax设置CSS样式,颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!