{"id":32285742,"url":"https://github.com/andreas-schwenk/tex","last_synced_at":"2025-10-23T01:51:26.378Z","repository":{"id":106202107,"uuid":"609051497","full_name":"andreas-schwenk/tex","owner":"andreas-schwenk","description":"Tiny TeX to SVG typesetter; written in Dart. https://pub.dev/packages/tex","archived":false,"fork":false,"pushed_at":"2024-01-10T11:53:52.000Z","size":3434,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-01-10T12:52:39.852Z","etag":null,"topics":["dart","dart-package","svg","tex","typesetting"],"latest_commit_sha":null,"homepage":"https://andreas-schwenk.github.io/tex/","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreas-schwenk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-03T09:21:13.000Z","updated_at":"2024-01-05T07:57:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"d49bd5d4-6d51-475c-86f2-3adb9d1b4b17","html_url":"https://github.com/andreas-schwenk/tex","commit_stats":{"total_commits":116,"total_committers":1,"mean_commits":116.0,"dds":0.0,"last_synced_commit":"0e0d965d90c1d7e4c2fa47b751f21ba7c27c0a8e"},"previous_names":[],"tags_count":25,"template":null,"template_full_name":null,"purl":"pkg:github/andreas-schwenk/tex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreas-schwenk%2Ftex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreas-schwenk%2Ftex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreas-schwenk%2Ftex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreas-schwenk%2Ftex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreas-schwenk","download_url":"https://codeload.github.com/andreas-schwenk/tex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreas-schwenk%2Ftex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280546410,"owners_count":26348722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dart-package","svg","tex","typesetting"],"created_at":"2025-10-23T01:51:21.010Z","updated_at":"2025-10-23T01:51:26.370Z","avatar_url":"https://github.com/andreas-schwenk.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"text-align: center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/andreas-schwenk/tex/main/docs/tex-logo.svg?v=2\" style=\"max-width: 256px;\"/\u003e\n\u003c/div\u003e\n\n`tex` is a tiny TeX engine that creates SVG images from TeX strings.\nCurrently, only the math environment (e.g. `$ f(x) = x^2 $`) is supported.\nCompared to other TeX renderers, this package does NOT rely on JavaScript or any other dependencies.\n\nYou will find a playground at [https://andreas-schwenk.github.io/tex](https://andreas-schwenk.github.io/tex). Alternatively, open file `/docs/index.html` in your browser. A local web server is not required.\n\n**Warning: this package is under development. Many more TeX macros will be supported soon**\n\n## Features\n\n- Rendering of SVG images from TeX sources\n- All data is packed into code. There is no need to load anything at runtime.\n\n## Getting started\n\nAdd the package into your package's `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  tex: ^1.0.2\n```\n\nMake sure to use the most recent version from [https://pub.dev/packages/tex](https://pub.dev/packages/tex).\n\n## Usage\n\nThe following example creates an SVG image data string from a TeX string.\n\n```dart\nimport 'package:tex/tex.dart';\n\nvoid main() {\n  // set the equation to render\n  var src = \"\\\\sum_{k=1}^n \\\\frac{1}{k(k+1)} = \\\\frac{n}{n+1}\";\n  // instantiate tex\n  var tex = TeX();\n  // set the RGB color (red color)\n  tex.setColor(157, 59, 50); \n  // set the scaling factor\n  tex.scalingFactor = 2.0;\n  // create SVG data\n  var svgImageData = tex.tex2svg(src, displayStyle: true);\n  // check for errors\n  if (tex.success()) {\n    // prints \"\u003csvg ...\";\n    print(svgImageData);\n  } else {\n    // error handling\n    print('Errors occurred: ${tex.error}');\n  }\n}\n```\n\nOutput SVG:\n\n\u003cimg src=\"https://raw.githubusercontent.com/andreas-schwenk/tex/main/img/example2.svg\" style=\"height:48px; background-color: white;\"/\u003e\n\n## Website integration\n\nThis example displays an equation as inline math in fluent text. The complete code can be found in directory `/examples/web`.\n\nCSS:\n```css\n.equation {\n  padding-left: 1px;\n  padding-right: 1px;\n  display: inline-block;\n  vertical-align: middle;\n}\n```\n\nHTML:\n```html\n\u003cp\u003e\n  Einsteins famous equation is\n  \u003cspan id=\"einstein\" class=\"equation\"\u003e\u003c/span\u003e.\n\u003c/p\u003e\n```\n\nDart:\n```dart\nimport 'dart:html';\nimport 'dart:convert';\n\nimport 'package:tex/tex.dart';\n\nvoid main() {\n  setEquationToSpan(\"#einstein\", \"E=mc^2\");\n}\n\nvoid setEquationToSpan(String spanId, String src) {\n  // instantiate tex\n  var tex = TeX();\n  // set the scaling factor\n  tex.scalingFactor = 1.0;\n  // create SVG data from TeX data\n  var svg = tex.tex2svg(src, displayStyle=false);\n  // debug output\n  print(svg);\n  // successful?\n  if (tex.success()) {\n    // create an image element\n    var svgBase64 = base64Encode(utf8.encode(svg));\n    var img = document.createElement('img') as ImageElement;\n    img.src = \"data:image/svg+xml;base64,$svgBase64\";\n    img.style.verticalAlign = \"bottom\";\n    // get the span element and add the image\n    var span = querySelector(spanId) as SpanElement;\n    span.innerHtml = '';\n    span.append(img);\n  }\n}\n```\n\n## Flutter\n\nThe following code excerpt creates a Span Widget that displays inline math. We use the package `flutter_svg` to render SVG images.\n\n```dart\nimport 'package:tex/tex.dart';\nimport 'package:flutter_svg/flutter_svg.dart';\n\n...\n// create a target widget element\nWidget equationWidget;\n// instantiate TeX\nvar tex = TeX();\n// set the scaling factor\ntex.scalingFactor = 1.1;\n// create SVG data from TeX data\nvar svg = tex.tex2svg(texSrc);\nif (tex.success() == false) {\n  // in case of errors: generate a TextSpan\n  // element containing an error description.\n  equationWidget = TextSpan(\n    text: tex.error,\n    style: TextStyle(color: Colors.red),\n  );\n} else {\n  // in case everything works: create a WidgetSpan\n  // element containing an SVG image.\n  var width = tex.width.toDouble()\n  equationWidget = WidgetSpan(\n    alignment: PlaceholderAlignment.middle,\n    child: SvgPicture.string(svg, width: width),\n  );\n}\n...\n```\n\n## Additional information\n\nFile `meta/glyphs.csv` specifies the glyphs.\n\nFor building the fonts, [python3](https://www.python.org) and [node](https://nodejs.org/en/) must be installed. This is only required for developers of this package.\n\n```bash\n./build.sh\n```\n\n## License of MathJax\n\nThis package extracts SVG image data of glyphs from [MathJax](https://www.mathjax.org). All rights remain to the authors. MathJax is licensed under the Apache2 license. You will find a copy of Apache2 license in folder `/licenses/mathJax/` of this repository.\n\nAll extracted data from MathJax can be found in variable `svgData` of file `/lib/src/svg.dart`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreas-schwenk%2Ftex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreas-schwenk%2Ftex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreas-schwenk%2Ftex/lists"}