# LaTeXcalc
## What is this?
LaTeXcalc is a LaTeX-Calculation-library for python3.
This calculates a mathematical formula written as a LaTeX-string.
It can use a given value-dict for variables in the formula.
The return-value is int or float.
## Supported features
LaTeXcalc can handle the following LaTeX-operations:
- apply `+`, `-`, `*`, `/` operators and the `-` as algebraic sign
- multiplication and division first, then addition and subtraction
- power `^`
- brackets `()`, `[]` and `{}` (also with `\left(`..`\right)`)
- squareroot `\sqrt{}`
- trigonometric functions like `\sin` or `\arctan` (radian measure)
- exponential numbers linke `1e+12`
- `\ln` (natural log), `\log` (base 10) and `e^`
- `\pi` or `pi` and `e` as default-values `math.pi` and `math.e`
- `\frac{}{}` (works as abbreviated `\frac 1 2` as well)
make sure you always use `*` (or `\cdot`), because `xy` != `x*y`, in that case xy would be a value!
## How to use
You can install this by using pip: `pip install latexcalc` or alternatively by including the folder `latexcalc` in your python3-project.
Then all you need to do is
```
import latexcalc
c = latexcalc.calc('\sqrt{3^2+4^2}')
# or with variables:
c = latexcalc.calc('\sqrt(a^2+b^2)', {'a':3,'b':4})
print(c) # 5.0
```
## Limitations
All testet cases work, but there might still be wrong calculations in
special cases, so test it for your needs!
## Anything wrong? Something missing?
Feel free to submit an issue if you find a bug or if you think something important is missing.
Just check out the latest code on GitHub and test your issue as it is done for some cases in the `test.py`. Then please add a Line for the `test.py` to your report to show the desired operation!
## Alternatives
There are some other libraries out there doing similar things, but at time of writing I didn't find anything that fulfilled my needs (lightweight, working with variables, ...).
So depending on your requirements this or maybe something else might be the right choise, thank's for cheching this out!
Raw data
{
"_id": null,
"home_page": "https://github.com/polarwinkel/latexcalc",
"name": "latexcalc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7, <4",
"maintainer_email": "",
"keywords": "TeX,LaTeX,latexcalc,texcalc,calctex,calclatex,calculate",
"author": "Dirk Winkel",
"author_email": "it@polarwinkel.de",
"download_url": "https://files.pythonhosted.org/packages/0d/31/f48e7f213feab83284bc2ce1a489a0b5a6fa1f05723096e80ff77133ca11/latexcalc-0.8.1.tar.gz",
"platform": null,
"description": "# LaTeXcalc\n\n## What is this?\n\nLaTeXcalc is a LaTeX-Calculation-library for python3.\n\nThis calculates a mathematical formula written as a LaTeX-string.\nIt can use a given value-dict for variables in the formula.\nThe return-value is int or float.\n\n## Supported features\n\nLaTeXcalc can handle the following LaTeX-operations:\n\n- apply `+`, `-`, `*`, `/` operators and the `-` as algebraic sign\n- multiplication and division first, then addition and subtraction\n- power `^`\n- brackets `()`, `[]` and `{}` (also with `\\left(`..`\\right)`)\n- squareroot `\\sqrt{}`\n- trigonometric functions like `\\sin` or `\\arctan` (radian measure)\n- exponential numbers linke `1e+12`\n- `\\ln` (natural log), `\\log` (base 10) and `e^`\n- `\\pi` or `pi` and `e` as default-values `math.pi` and `math.e`\n- `\\frac{}{}` (works as abbreviated `\\frac 1 2` as well)\n\nmake sure you always use `*` (or `\\cdot`), because `xy` != `x*y`, in that case xy would be a value!\n\n## How to use\n\nYou can install this by using pip: `pip install latexcalc` or alternatively by including the folder `latexcalc` in your python3-project.\n\nThen all you need to do is\n\n```\nimport latexcalc\n\nc = latexcalc.calc('\\sqrt{3^2+4^2}')\n# or with variables:\nc = latexcalc.calc('\\sqrt(a^2+b^2)', {'a':3,'b':4})\nprint(c) # 5.0\n```\n\n## Limitations\n\nAll testet cases work, but there might still be wrong calculations in\nspecial cases, so test it for your needs!\n\n## Anything wrong? Something missing?\n\nFeel free to submit an issue if you find a bug or if you think something important is missing.\n\nJust check out the latest code on GitHub and test your issue as it is done for some cases in the `test.py`. Then please add a Line for the `test.py` to your report to show the desired operation!\n\n## Alternatives\n\nThere are some other libraries out there doing similar things, but at time of writing I didn't find anything that fulfilled my needs (lightweight, working with variables, ...).\nSo depending on your requirements this or maybe something else might be the right choise, thank's for cheching this out!\n",
"bugtrack_url": null,
"license": "",
"summary": "LaTeXcalc is a LaTeX-Calculation-library for python3 accepting an optional values-dict for variables",
"version": "0.8.1",
"project_urls": {
"Bug Reports": "https://github.com/polarwinkel/latexcalc/issues",
"Homepage": "https://github.com/polarwinkel/latexcalc",
"Source": "https://github.com/polarwinkel/latexcalc"
},
"split_keywords": [
"tex",
"latex",
"latexcalc",
"texcalc",
"calctex",
"calclatex",
"calculate"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a63322fe70b9032e773adff9a732aeddcecd768b8c6998f17d0587ff77854d64",
"md5": "883f1d9776f096e8bb4e1c72502bc472",
"sha256": "b7e0ab1ee8a72432932c40b8617f3b88fb75a892d64f9d6ae6e0b9115c4a63e3"
},
"downloads": -1,
"filename": "latexcalc-0.8.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "883f1d9776f096e8bb4e1c72502bc472",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7, <4",
"size": 17538,
"upload_time": "2023-11-22T12:38:24",
"upload_time_iso_8601": "2023-11-22T12:38:24.176347Z",
"url": "https://files.pythonhosted.org/packages/a6/33/22fe70b9032e773adff9a732aeddcecd768b8c6998f17d0587ff77854d64/latexcalc-0.8.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0d31f48e7f213feab83284bc2ce1a489a0b5a6fa1f05723096e80ff77133ca11",
"md5": "7b88972cec5f7da74aec6d58fbe693cb",
"sha256": "87c2e418cab0e03868d0cd73605c93ac83bed91781b90c871ed988f42089fc80"
},
"downloads": -1,
"filename": "latexcalc-0.8.1.tar.gz",
"has_sig": false,
"md5_digest": "7b88972cec5f7da74aec6d58fbe693cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7, <4",
"size": 16895,
"upload_time": "2023-11-22T12:38:27",
"upload_time_iso_8601": "2023-11-22T12:38:27.132971Z",
"url": "https://files.pythonhosted.org/packages/0d/31/f48e7f213feab83284bc2ce1a489a0b5a6fa1f05723096e80ff77133ca11/latexcalc-0.8.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-22 12:38:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "polarwinkel",
"github_project": "latexcalc",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "latexcalc"
}