Reputation: 111
I want to display math equations dynamically:
Here is the successful output of a LaTeX equation:
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',
),
),
);
When I try to pass the String variable "formula" in LaTeX, I can't get it to render:
String a = '10';
String formula = ' \(' + a + 'x^2\)';
output.add(
TeXViewDocument(
formula,
style: TeXViewStyle.fromCSS(
'padding: 15px; color: black; background: white',
),
),
);
How can I get my string variables to be rendered to LaTeX? I have tried using jsonEncode() or some other tricks to work with a raw string but nothing has worked. I checked the flutter_tex documentation but there are no examples passing variables for LaTeX output.
Upvotes: 1
Views: 864
Reputation: 1507
Did you try something like this?
String a = '10';
String formula = "\\(${a}x^2\\)";
Upvotes: 4