jqMath:如何着色jqMath表中的分数

时间:2013-05-02 20:56:19

标签: javascript css math latex mathjax

在使用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表(并且有),但是我想将所有的数学保持在一起,看起来像未来校对的数学问题。此外,将问题放在表中只会给页面添加不必要的标记,从而增加页面下载时间。

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

1 个答案:

答案 0 :(得分:0)

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

正如您所说,最佳解决方案是将CSS类或ID添加到特定的数学子表达式中。 jqMath highlight box like bbox in MathJax/MathJs的答案显示了如何执行此操作。

如果您设置<fmath>样式,请注意此类“假数学”标记不会在具有原生MathML的Firefox等浏览器中使用 - jqMath使用标准<math>标记。