问题
Trying to use the Django-MathJax application to do exactly what it says on the tin: enable MathJax within a Django project. I've followed their installation directions, and have installed the application, and changed my Django configuration files as such:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'django_mathjax',
)
MATHJAX_ENABLED=True
I then go to one of my pages and set it up as follows:
{% extends "root.html" %}
{% load mathjax %}
{% block nav %}
<li><a href="/about">About</a></li>
<li class="active"><a href="/contact">Contact</a></li>
{% endblock %}
{% block content %}
{% mathjax_scripts %}
<div class="row">
<div class="col-lg-9">
<h1>Contact</h1>
<p>
Text text text text text.
<ol>
<li>Item one </li>
<li>Item two</li>
</ol>
</p>
<h1>Other things</h1>
<p>
Texty texty text so much text $$1 + 1 = 2$$, and thus it was written.
</div>
</div>
{% endblock %}
That should have the "1 + 1 = 2" show up formatted correctly, but instead it just shows up as, well, two dollar signs on either end of 1+1=2. Anyone know what I'm doing wrong? I'm not so much a front end developer, so I'm fumbling about in the dark a bit.
回答1:
The problem is that the documentation doesn't explain that the MATHJAX_CONFIG_FILE is needed for version <= 0.0.4, this is fixed in the version 0.0.5 that have a default value for MATHJAX_CONFIG_FILE.
you can solve it adding MATHJAX_CONFIG_FILE="TeX-AMS-MML_HTMLorMML" in your settings.py (this is the default value for the version 0.0.5).
来源:https://stackoverflow.com/questions/24746098/django-mathjax-not-displaying-correctly