【问题标题】:Display a string variable in LaTeX using flutter_tex package (Dart)使用flutter_tex包(Dart)在LaTeX中显示字符串变量
【发布时间】:2021-12-26 06:45:36
【问题描述】:

我想动态显示数学方程式:

这是一个 LaTeX 方程的成功输出:

output.add(
    TeXViewDocument(
      r"""<p> When \(a \ne 0 \), there are two solutions to \(x^2 + bx + c = 0\) </p>""",
      style: TeXViewStyle.fromCSS(
        'padding: 15px; color: black; background: white',
      ),
    ),
  );

当我尝试在 LaTeX 中传递字符串变量“公式”时,我无法让它渲染:

String a = '10';
String formula = ' \(' + a + 'x^2\)';
output.add(
  TeXViewDocument(
    formula,
    style: TeXViewStyle.fromCSS(
      'padding: 15px; color: black; background: white',
    ),
  ),
);

如何让我的字符串变量呈现到 LaTeX?我曾尝试使用 jsonEncode() 或其他一些技巧来处理原始字符串,但没有任何效果。我检查了 flutter_tex 文档,但没有为 LaTeX 输出传递变量的示例。

【问题讨论】:

    标签: flutter dart latex mathjax katex


    【解决方案1】:

    你尝试过这样的事情吗?

    String a = '10';
    String formula = "\\(${a}x^2\\)";
    

    【讨论】:

    • 成功了!!!尝试了很多不同的东西,但我很高兴有一个解决方案。非常感谢
    猜你喜欢
    • 2017-04-05
    • 2020-04-19
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 2020-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多