Latex formula editor ?

157 views
Skip to first unread message

Stef Mientki

unread,
Dec 13, 2010, 7:31:13 PM12/13/10
to wxpython-users
hello,

is there a formula editor availabale for wxPython,
that converts Latex formula to png files.
(so they can be embedded in html)

thanks,
Stef Mientki

Tim Roberts

unread,
Dec 13, 2010, 8:40:33 PM12/13/10
to wxpytho...@googlegroups.com
Stef Mientki wrote:
> hello,
>
> is there a formula editor availabale for wxPython,
> that converts Latex formula to png files.
> (so they can be embedded in html)

I would be gob-smacked if you could find anything pre-built for this.
It's not a simple task. If you know TeX and LaTeX are installed, you
can certainly write your own scripts to do the conversion, but the
TeX/LaTex installation on my hard disk is about 650MB.

OpenOffice has an equation writer that might be usable in other
contexts. That's worth checking.

--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Mike Driscoll

unread,
Dec 14, 2010, 10:22:31 AM12/14/10
to wxPython-users
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.


You can use Python to script OpenOffice, so that might be doable.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

dhyams

unread,
Dec 14, 2010, 11:43:29 AM12/14/10
to wxpytho...@googlegroups.com
If you can live with a subset of Latex, check out matplotlib. It's a plotting package, but you can have it render straight to screen or png.

Tim Roberts

unread,
Dec 14, 2010, 12:46:09 PM12/14/10
to wxpytho...@googlegroups.com
dhyams wrote:
> If you can live with a subset of Latex, check out matplotlib. It's a
> plotting package, but you can have it render straight to screen or
> png. --

Oooh, that's a great hint -- I wish I had remembered that first. Here's
a link to a sample:

http://matplotlib.sourceforge.net/users/usetex.html#usetex-tutorial

dhyams

unread,
Dec 14, 2010, 4:20:17 PM12/14/10
to wxpytho...@googlegroups.com
Actually, I don't know if it will help the original poster; he said that he wanted an editor, and certainly matplotlib cannot help with that.  I should have read more closely :/

Stef Mientki

unread,
Dec 14, 2010, 4:35:03 PM12/14/10
to wxpytho...@googlegroups.com
On 14-12-2010 22:20, dhyams wrote:
Actually, I don't know if it will help the original poster; he said that he wanted an editor, and certainly matplotlib cannot help with that.  I should have read more closely :/ --
To unsubscribe, send email to wxPython-user...@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
thank you all for your comment,
a quick and dirty summary
- Latex itself is much to heavy
- Openoffice component could be a good candidate, but I know nothing of OO, so getting out some small component seems a lot of hassle
- MatPlotLib could work, but requires a working Latex ( so too heavy)
- Mimetex.exe seems to be a very good candidate, small and fast. I'm not sure this will work on other than Windows

With mimetex and 30 lines of code, I made a first version of a real-time formula editor dialog.

cheers,
Stef


Josh English

unread,
Dec 14, 2010, 10:41:40 PM12/14/10
to wxpytho...@googlegroups.com
This is SWEET. It is, however, unfair of you not to share.

Did you find mimetex.exe as a download, or did you have to compile it? 

Josh


On Tue, Dec 14, 2010 at 1:35 PM, Stef Mientki <stef.m...@gmail.com> wrote:

thank you all for your comment,
a quick and dirty summary
- Latex itself is much to heavy
- Openoffice component could be a good candidate, but I know nothing of OO, so getting out some small component seems a lot of hassle
- MatPlotLib could work, but requires a working Latex ( so too heavy)
- Mimetex.exe seems to be a very good candidate, small and fast. I'm not sure this will work on other than Windows

With mimetex and 30 lines of code, I made a first version of a real-time formula editor dialog.




Christopher Barker

unread,
Dec 15, 2010, 12:59:10 AM12/15/10
to wxpytho...@googlegroups.com, Stef Mientki
On 12/14/10 1:35 PM, Stef Mientki wrote:
> a quick and dirty summary
> - Latex itself is much to heavy

yup -- I saw some folks working on a project to make a TeX designed for
embedding a couple years ago -- it might be worth googling for.

> - MatPlotLib could work, but requires a working Latex ( so too heavy)

Ah, I think you missed a feature. MPL can optionally use a full TeX
distribution as the engine, but it also has a built-in TeX
implementation with a limited feature set for equations (i.e. no
paragraph layout, etc). Depending on your needs, it may be OK -- and
it's pure Python.

http://matplotlib.sourceforge.net/users/mathtext.html

> - Mimetex.exe seems to be a very good candidate, small and fast. I'm not
> sure this will work on other than Windows

Why not -- it looks like it's ANSI C, GPL;s and there are binaries for a
bunch of OSs. It would be kind of cool to wrap it as a python extension,
rather than the CGI interface.

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

Christopher Barker

unread,
Dec 15, 2010, 2:30:14 AM12/15/10
to wxpytho...@googlegroups.com, Stef Mientki
On 12/14/10 9:59 PM, Christopher Barker wrote:
>> - MatPlotLib could work, but requires a working Latex ( so too heavy)
>
> Ah, I think you missed a feature. MPL can optionally use a full TeX
> distribution as the engine, but it also has a built-in TeX
> implementation with a limited feature set for equations (i.e. no
> paragraph layout, etc). Depending on your needs, it may be OK -- and
> it's pure Python.

OK -- I couldn't help myself, here is a quick and dirty TeX editor,
written using Matplotlib.

Enjoy!

MPL_math.png
MPLmath.py

Stef Mientki

unread,
Dec 15, 2010, 6:26:08 AM12/15/10
to wxpytho...@googlegroups.com
On 15-12-2010 04:41, Josh English wrote:
This is SWEET. It is, however, unfair of you not to share.

Did you find mimetex.exe as a download, or did you have to compile it?
first hit at google:
http://www.biostatisticien.eu/mimetex.html

cheers,
Stef

Josh

On Tue, Dec 14, 2010 at 1:35 PM, Stef Mientki <stef.m...@gmail.com> wrote:

thank you all for your comment,
a quick and dirty summary
- Latex itself is much to heavy
- Openoffice component could be a good candidate, but I know nothing of OO, so getting out some small component seems a lot of hassle
- MatPlotLib could work, but requires a working Latex ( so too heavy)
- Mimetex.exe seems to be a very good candidate, small and fast. I'm not sure this will work on other than Windows

With mimetex and 30 lines of code, I made a first version of a real-time formula editor dialog.




--
Josh English
Joshua.R...@gmail.com
http://joshenglish.livejournal.com

Stef Mientki

unread,
Dec 15, 2010, 6:30:52 AM12/15/10
to wxpytho...@googlegroups.com
On 15-12-2010 08:30, Christopher Barker wrote:
> On 12/14/10 9:59 PM, Christopher Barker wrote:
>>> - MatPlotLib could work, but requires a working Latex ( so too heavy)
>>
>> Ah, I think you missed a feature. MPL can optionally use a full TeX
>> distribution as the engine, but it also has a built-in TeX
>> implementation with a limited feature set for equations (i.e. no
>> paragraph layout, etc). Depending on your needs, it may be OK -- and
>> it's pure Python.
>
> OK -- I couldn't help myself, here is a quick and dirty TeX editor, written using Matplotlib.
Great Cristopher,
works smoother than the mimetex version (and pure Python)
Indeed I missed that MPL contained a subset of Latex.
So I think I'm going for your solution,

One other thing, does anyone know a good set with math icons.
The best I could find is
http://us.metamath.org/symbols/symbols.html#downloads

thanks,
Stef Mientki
>
> Enjoy!
>
> -Chris
>
>

Steve Barnes

unread,
Dec 15, 2010, 7:24:43 AM12/15/10
to wxpytho...@googlegroups.com
If you are using the MPL solution why not generate them on the fly or as a part of the build process – then you will be able to a) Generate the size(s) you need and b) be sure that they are all supported by MDL.
 
Just my 2p worth.
 
Gadget/Steve
thanks,
Stef Mientki
>
> Enjoy!
>
> -Chris
>
>
 
--

Stef Mientki

unread,
Dec 15, 2010, 7:52:43 AM12/15/10
to wxpytho...@googlegroups.com

�
One other thing, does anyone know a good set with math icons.
The best I could find is
If you are using the MPL solution why not generate them on the fly or as a part of the build process � then you will be able to a) Generate the size(s) you need and b) be sure that they are all supported by MDL.
WelI I want to make a number of groups with different sets of math symbols,
that will act as a toolbar to insert the corresponding latex info.
So it will cost a lot of work to generate and include them all,
and probably I'll miss a few.

cheers,
Stef
�
Just my 2p worth.
�
Gadget/Steve


Stef Mientki

unread,
Dec 15, 2010, 1:29:00 PM12/15/10
to wxpytho...@googlegroups.com
On 15-12-2010 12:30, Stef Mientki wrote:
> On 15-12-2010 08:30, Christopher Barker wrote:
>> On 12/14/10 9:59 PM, Christopher Barker wrote:
>>>> - MatPlotLib could work, but requires a working Latex ( so too heavy)
>>> Ah, I think you missed a feature. MPL can optionally use a full TeX
>>> distribution as the engine, but it also has a built-in TeX
>>> implementation with a limited feature set for equations (i.e. no
>>> paragraph layout, etc). Depending on your needs, it may be OK -- and
>>> it's pure Python.
>> OK -- I couldn't help myself, here is a quick and dirty TeX editor, written using Matplotlib.
> Great Cristopher,
> works smoother than the mimetex version (and pure Python)
> Indeed I missed that MPL contained a subset of Latex.
> So I think I'm going for your solution,
Sorry, I applauded too early.
The MPL version, has a number of problems:
- it misses a number of commands, like \small , \tiny
- the image size is fixed (to the original window size ?) with a lot of white space around the formula
(therefor the image size is also much larger than necessary)

cheers,
Stef

Christopher Barker

unread,
Dec 15, 2010, 1:32:42 PM12/15/10
to wxpytho...@googlegroups.com, Stef Mientki
On 12/15/10 3:30 AM, Stef Mientki wrote:
>> OK -- I couldn't help myself, here is a quick and dirty TeX editor, written using Matplotlib.
> Great Christopher,

> works smoother than the mimetex version (and pure Python)
> Indeed I missed that MPL contained a subset of Latex.
> So I think I'm going for your solution,

I'm glad it's helpful.

You might want to take a look at:

matplotlib.mathtext.MathtextBackendBitmap()
A backend to generate standalone mathtext images. No additional
matplotlib backend is required.

That may let you eliminate the MPL figure stuff (though it's not too
much coding overhead)

One thing I didn't figure out last night was how to tell how large a
given chunk of rendered text is, so that you can do things like center
it on the Figure. Some poking into the docs and code may help figure
that out, or a question to the MPL list.

> One other thing, does anyone know a good set with math icons.
> The best I could find is

Perhaps you could generate them with MathtextBackendBitmap().

Christopher Barker

unread,
Dec 15, 2010, 1:35:15 PM12/15/10
to wxpytho...@googlegroups.com, Stef Mientki
On 12/15/10 10:29 AM, Stef Mientki wrote:
> The MPL version, has a number of problems:
> - it misses a number of commands, like \small , \tiny

well, it's certainly incomplete -- I don't know how hard it would be to
add things like that. Those particular commands could be pretty
straightforward.

If you want EVERYTHING, a full LaTeX distribution is your only option.
Though maybe mimeTeX has significantly more than MPL.

> - the image size is fixed (to the original window size ?) with a lot of white space around the formula
> (therefor the image size is also much larger than necessary)

See my previous note -- I suspect you can solve that one.

jmfauth

unread,
Dec 16, 2010, 5:33:25 AM12/16/10
to wxPython-users


On Dec 15, 12:30 pm, Stef Mientki <stef.mien...@gmail.com> wrote:

> One other thing, does anyone know a good set with math icons.
>
>

You can use instead OpenType math fonts. I have just
tested the "Cambria Math" font on wxPython 2.9.1 on
Windows 7, all the random code points in the "Mathematical
Operators Unicode code block" I randomly selected are
rendered in a StaticText, a TextCtrl or in a STC.

I have other math fonts I'm using in XeTeX. I did
not test them, they are not installed at the system
level.

jmf
Reply all
Reply to author
Forward
0 new messages