Giter VIP home page Giter VIP logo

django_mathlatex's Introduction

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:

<p>
Einstein said that {% math %}E = mc^2{% endmath %}.
</p>

<p>
We can say more:
</p>
{% 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 %}
<p>
The following equation illustrates mass-energy equivalence:
</p>
<img src="{{ einstein.image.url }}" alt="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}}

django_mathlatex's People

Contributors

emesik avatar gurobokum avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.