Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emesik/django_mathlatex
Django template tag for rendering math formulas
https://github.com/emesik/django_mathlatex
Last synced: 22 days ago
JSON representation
Django template tag for rendering math formulas
- Host: GitHub
- URL: https://github.com/emesik/django_mathlatex
- Owner: emesik
- Created: 2011-03-06T22:29:04.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-03-03T23:15:01.000Z (over 10 years ago)
- Last Synced: 2024-10-04T16:45:26.025Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 153 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
django_mathlatex
================Render PNG images of math formulas written in LaTeX notation.
It's simple as hell:::
{% load mathlatex %}
{% math %}
E = mc^2
{% endmath %}Requirements and confirguration
-------------------------------The required tools are:
* ``latex`` with ``amsmath`` package,
* ``dvipng``The configuration consists of one declaration in ``settings.py``:
::
MATHLATEX_IMAGES_DIR = 'math/' # Or wherever you wish under MEDIA_ROOT
Examples
--------Always include ``{% load mathlatex %}`` in your template.
To simply put a formula inline, write:
::
Einstein said that {% math %}E = mc^2{% endmath %}.
We can say more:
{% math %}
\left\{
\begin{array}{ll}
x = ct + x\cos(\omega t)\\
z = R\sin(\omega t)
\end{array}
\right. \Leftrightarrow
\left\{
\begin{array}{ll}
x = \frac{L}{T}t+R\cos(\omega t)\\
z = R\sin(\omega t)
\end{array}
\right. \Leftrightarrow
\left\{
\begin{array}{ll}
x = \frac{\omega t}{k}+R\cos(\omega t)\\
z = R\sin(\omega t)
\end{array}
\right.
{% endmath %}You may also obtain the instance of formula's model by assigning it to a value:
::
{% math as einstein %}E=mc^2{% endmath %}
The following equation illustrates mass-energy equivalence:
Alternatively, you may pass an equation as context variable:
::
from django.template import Template, Context
t3 = Template("{% load mathlatex %}{% math %}{{ einstein }}{% endmath %}")
ctx = Context({'einstein': 'E = mc ^ 2'})Also you could use math as filter in templates
::
{{text|math}}