blob: 1ec7d8bda59ce0081f6496988b42188e51bce23a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
Mathhack Instructions
=====================
Formula syntax is everything LaTeX supports in math mode. This is supported
for the LaTeX writer and for anything else by converting with LaTeX (and some
external_ commands) to *images*.
There are now other solutions (see the FAQ entry__) that employ dialects of
LaTeX for translation to MathML so you should consider limiting yourself to
the intersection of the syntaxes if you want to allow all possible convertions.
__ http://docutils.sourceforge.net/
FAQ.html#how-can-i-include-mathematical-equations-in-documents
Just write::
text... :texmath:`formula` ...text
or simply::
text... `formula` ...text
for inline formulas; for display formulas use a directive::
.. texmath:: formula
Inline formulas can also be written with substitution references::
text... |name| ...text
.. |name| texmath:: formula
Now you take this (in file foo.txt) and run::
mathhack.py foo.txt | rst2latex.py - foo.tex
which converts the roles/directives to ``raw:: latex`` directives or::
imgmathhack.py foo.txt | html.py - foo.html
which runs TeX (generating images into a subdirectory!) and converts
the roles/directives into ``img::`` directives. Quick, dirty and
convenient ;-).
To allow including preprocessed files, do::
mathhack.py included.txt > included.txt.mathhack
imgmathhack.py included.txt > included.txt.imgmathhack
and include ``included.txt.mathhack`` (imgmathhack.py will mangle this to
include ``included.txt.imgmathhack`` automatically). My makefile_ can do all
this for you (just set ENABLE_MATHHACK=1).
.. _makefile: ../make/Makefile.docutils
.. _external:
Note that the `<imgmathhack.py>`_ script relies on some external commands (see
the comments at its top). `tex_to_images` seems to be separately availiable
from the `speech_tools CVS`__
__ http://cvs.sf.net/viewcvs.py/*checkout*/emu/speech_tools/scripts/tex_to_images.prl?rev=HEAD
Also note that the scripts use regexps to "parse" the roles/directives, so
expect some bugs (e.g. don't try to split a formula into multiple lines inside
a table cell...).
|