math_latex_builder 1.0.3
math_latex_builder: ^1.0.3 copied to clipboard
A Dart package to programmatically build and manipulate LaTeX math expressions using a tree-based structure.
math_latex_builder #
A Dart package to programmatically build and manipulate LaTeX math expressions using a tree-based structure.
Features #
- Build complex LaTeX expressions with a simple, intuitive API.
- Navigate and edit expressions using cursor movements.
- Support for common LaTeX elements like fractions, roots, and powers.
- Written in pure Dart, making it compatible with any Dart or Flutter project.
Installation #
Add the following to your pubspec.yaml file:
dependencies:
math_latex_builder: ^1.0.3
Then run dart pub get or flutter pub get.
Usage #
import 'package:math_latex_builder/math_latex_builder.dart';
void main() {
final LaTeXTree tree = LaTeXTree();
tree.addChildLeaf(LEType.numberLeaf, "4");
tree.addChildLeaf(LEType.operatorLeaf, "+");
tree.addChildNode(LEType.fractionNode);
tree.addChildLeaf(LEType.numberLeaf, "1");
tree.addChildLeaf(LEType.numberLeaf, "5");
tree.addChildLeaf(LEType.operatorLeaf, "-");
tree.addChildNode(LEType.squareRootNode);
tree.addChildLeaf(LEType.numberLeaf, "7");
tree.moveDown();
tree.addChildNode(LEType.nthRootNode);
tree.addChildLeaf(LEType.numberLeaf, "9");
tree.moveRight();
tree.addChildNode(LEType.fractionNode);
tree.addChildLeaf(LEType.numberLeaf, "3");
tree.moveDown();
tree.addChildLeaf(LEType.numberLeaf, "8");
print("result : ${tree.toLaTeXString}");
// 4+\frac{15-\sqrt{7}}{\sqrt[9]{\frac{3}{8|}}}
}