Performantly render scientific equations using the KaTeX library on Android, iOS and the web platform.
Render scientific equations using the KaTeX library.
- Mathematics / Maths Equations (Algebra, Calculus, Geometry, Geometry etc...)
- Physics Equations
- Signal Processing Equations
- Chemistry Equations
- Statistics / Stats Equations
Rendering is done using KaTeX.
katex_flutter is working on Android, iOS, and the web platform. Desktop support is planned.
On mobile platofrom this package mainly depends on webview_flutter plugin.
On web platform this package directly into Flutter's platfrom view's shadow root.
Unlike flutter_tex it does not create a local web server. This increases the performance significantly and allows non-mobile platforms.
KaTeX( @required laTeX, // The LaTeX code to be rendered delimiter = '\$', // The delimiter to be used for inline LaTeX displayDelimiter = '\$\$', // The delimiter to be used for Display (centered, "important") LaTeX color = Colors.black, // Background color background = Colors.white, // Text color inheritWidth = true); // Whether to use the parent's width or only the minimum required by the equation
Use this package as a library #
Add this to your package's pubspec.yaml file:
dependencies: katex_flutter: ^2.2.0+12
You can install packages from the command line with Flutter:
flutter pub get
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
Add the following code into the
<head>...</head> section of your
<link rel="stylesheet" href="https://email@example.com/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous"> <script defer src="https://firstname.lastname@example.org/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script> <script defer src="https://email@example.com/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script> <script src="katex_flutter.js"></script>
Alternatively you could add the path to a local KaTeX library as well. Note that this will only work on web platform but not on mobile devices.
flutter pub run katex_flutter:main
This will generate the required files in your
If you want to use different LaTeX delimiters than
$ for inline and
$$ for display LaTeX in web, you should modify the
delimiters section in
web/katex_flutter.js. In future releases these manual changes will become unneccesairy. We just didn't have enough of time for coding a dynamic implimentation.
Source code #
This package was initially created for the education project TestApp.