【问题标题】:jqMath: How to colorize fractions inside jqMath tablesjqMath:如何为 jqMath 表中的分数着色
【发布时间】:2013-05-04 03:38:36
【问题描述】:

在使用 jqMath 编写数学时,我需要突出显示数学问题的特定部分。

/* specific to override border bottom important jqMath adds */
fmath td.redunderline { 
border-bottom: #a20000 1px solid !important; 
}
fmath td.redunderline .math-sum.red{ 
border-bottom: 0 !important; 
}

/* colorizes numerator and denominator */
.math .red-num .fm-num-frac,
.math .red-den .fm-den-frac {
    color: #a20000;
}

/* Colors for fractions in browsers that support MathML */
.math mfrac.red-num mn:nth-child(1),
.math mfrac.red-num mrow:nth-child(1),
.math mfrac.red-den mn:nth-child(2),
.math mfrac.red-den mrow:nth-child(2) {
    color:#a20000;
}

除非我在 jqMath 表中,否则所有这些都很好用。

$\table
{5x+4},=,49;
\html '<span class="red math-sum">−4</span>', ,\html '<span class="red math-sum">−4</span>';
{5x \html '<span class="red">+ 0</span>'},=,\html '<span class="red"> 45 </span>';
5x,=,45;
{\html '<span class="red-den">'{{5x}/5}\html '</span>'},=,{\html '<span class="red-den">' {45/5} \html '</span>'};
x,=,\html '<span class="red">9</span>';$

这是没有格式化分母的行:

{\html '<span class="red-den">'{{5x}/5}\html '</span>'},=,{\html '<span class="red-den">' {45/5} \html '</span>'};

如果我不分组线,它不会被 jqMath 处理,并且仍然显示大括号等。如果我将线分组,我会遇到数学问题,但是跨度中的颜色被放入另一个隐藏的行,而不是像我想要的那样包装数字。

我考虑使用 jQuery 添加样式,但是我无法在要添加类的位置标记 HTML,因为 jqMath 没有将样式放在所需的位置,这需要足够通用,以便我可以添加标签或样式以将所需的效果带入页面。不能在每个数学问题中添加 jQuery。

当然,我可以使用常规的 html 表(并且有)来做到这一点,但是我想把所有的数学放在一起,看起来像一个数学问题,以备将来验证。此外,将问题放在表格中只会给页面添加不必要的标记,增加页面下载时间。

理想的解决方案是告诉各个行如何设置自己的样式。

【问题讨论】:

  • 基于@dave-barton 的解决方案,代码清理了很多,看起来像这样:$\table x-3,=,9; \cl "red math-sum" {+3},,\cl "red math-sum" {+3}; x,=,\cl "red" 12;$

标签: javascript css math latex mathjax


【解决方案1】:

\html 创建一个完整的元素,而不仅仅是一个开始或结束标记。

正如您所说,最好的解决方案是将 CSS 类或 ID 添加到特定的数学子表达式。 jqMath highlight box like bbox in MathJax/MathJs 的答案显示了如何做到这一点。

如果您改用<fmath> 的样式,请注意这个“假数学”标签不会在具有本机 MathML 的 Firefox 等浏览器中使用 - jqMath 使用标准的 <math> 标签。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-02
    • 2016-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多