我想在LaTeX中显示公式,并在客户端呈现它们。这些方程有一些必须改变的变量。到目前为止,我只找到了MathJax,但它不会在值发生变化时更新它们。有像http://plnkr.co/edit/FLduwmtHfkCN5XPfzMsA?p=preview这样的例子,它是实时更改的,但它来自Angular2,并且在它的MathJax.Hub.Queue(["Typeset",MathJax.Hub, this.el.nativeElement]);中有一行奇怪的东西,这给我留下了一个错误(因为我找不到MathJax变量)。ng-katex也不起作用,因为它没有出现在我的ng-modules文件夹中,而且它的输出也很奇怪。
MathJax本身可以完美地工作,除非您在DOM中更改了某些内容
例如:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-test',
template: '
<button (click)="decrDenumerator()">-</button>
Frac: {{frac}}
<button (click)="incrDenumerator()">+</button>',
styleUrls: ['./test.component.sass']
})
export class TestComponent implements OnInit {
denumerator = 1;
frac = '$\\frac{1}{' + this.denumerator + '}$';
constructor() {
}
ngOnInit() {
}
incrDenumerator() {
this.denumerator = Math.min(10, this.denumerator + 1);
this.frac = '$\\frac{1}{' + this.denumerator + '}$';
}
decrDenumerator() {
this.denumerator = Math.max(1, this.denumerator - 1);
this.frac = '$\\frac{1}{' + this.denumerator + '}$';
}
}当单击其中一个按钮时,它只会将其显示为文本,而从MathJax生成的第一个输出将显示在它旁边。
如何才能让MathJax注意到这些更改并采取相应的行动?非常感谢。
https://stackoverflow.com/questions/47822913
复制相似问题