Mathex: Generating latex math from Pharo.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Mathex: Generating latex math from Pharo.

Julien Delplanque
Hi everyone,

Some time ago, I asked for a framework that would allow me to write
valid latex math from Pharo
(in a similar way that I used to do with pylatex in Python) see the
thread here:
http://forum.world.st/Generate-latex-from-Pharo-td4826739.html.

Damien Cassou pointed me the Pillar-ExporterLaTeX package to do it, so I
used it to create the
Mathex package that you can get here:
https://github.com/juliendelplanque/mathex
or by evaluating:

Metacello new
     baseline: 'Mathex';
     repository: 'github://juliendelplanque/mathex/repository';
     load.

for tests:

Metacello new
     baseline: 'MathexTests';
     repository: 'github://juliendelplanque/mathex/repository';
     load.

 From now, it does not support all the possible math commands of latex
but you can already do things like:

(Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.

and get:

\begin{equation}
\phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}

Also, and in fact this is the kind of feature I was looking for, you can
export a Matrix into latex math like this:

(Matrix diagonal: #(42 42 42)) asMathex asString.

Each command/operation is represented by an object in the package.
To understand how I implemented that have a look on the
MObject>>#doesNotUnderstand: where I explain it.

I will soon work on an importer that will create, automatically, latex
command as objects from a file that describe
how to do it.

What do you think about this?

Hope this package could helps someone else one day.

Julien

Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Ben Coman
On Sun, Sep 6, 2015 at 10:15 PM, Julien Delplanque <[hidden email]> wrote:

> Hi everyone,
>
> Some time ago, I asked for a framework that would allow me to write valid
> latex math from Pharo
> (in a similar way that I used to do with pylatex in Python) see the thread
> here:
> http://forum.world.st/Generate-latex-from-Pharo-td4826739.html.
>
> Damien Cassou pointed me the Pillar-ExporterLaTeX package to do it, so I
> used it to create the
> Mathex package that you can get here:
> https://github.com/juliendelplanque/mathex
> or by evaluating:
>
> Metacello new
>     baseline: 'Mathex';
>     repository: 'github://juliendelplanque/mathex/repository';
>     load.
>
> for tests:
>
> Metacello new
>     baseline: 'MathexTests';
>     repository: 'github://juliendelplanque/mathex/repository';
>     load.
>
> From now, it does not support all the possible math commands of latex but
> you can already do things like:
>
> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.
>
> and get:
>
> \begin{equation}
> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}
>
> Also, and in fact this is the kind of feature I was looking for, you can
> export a Matrix into latex math like this:
>
> (Matrix diagonal: #(42 42 42)) asMathex asString.
>
> Each command/operation is represented by an object in the package.
> To understand how I implemented that have a look on the
> MObject>>#doesNotUnderstand: where I explain it.
>
> I will soon work on an importer that will create, automatically, latex
> command as objects from a file that describe
> how to do it.
>
> What do you think about this?
>
> Hope this package could helps someone else one day.

I don't have an immediate need, but its cool and good to know its
there for when I do.

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Damien Cassou-2
In reply to this post by Julien Delplanque
Hi Julien,

Julien Delplanque <[hidden email]> writes:

> Hi everyone,
>
> Some time ago, I asked for a framework that would allow me to write
> valid latex math from Pharo
> (in a similar way that I used to do with pylatex in Python) see the
> thread here:
> http://forum.world.st/Generate-latex-from-Pharo-td4826739.html.
>  From now, it does not support all the possible math commands of latex
> but you can already do things like:
>
> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.
>
> and get:
>
> \begin{equation}
> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}


I think that's great news! One of Pillar's feature requests is to let
users write LaTeX (e.g., formulas) in their pillar document and get nice
results in all exports (LaTeX, HTML, ePub...):
https://github.com/pillar-markup/pillar/issues/18. I'm not sure how this
request fits in your work, but there might be some intersection.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Julien Delplanque
On 07/09/15 13:56, Damien Cassou wrote:

> Hi Julien,
>
> Julien Delplanque <[hidden email]> writes:
>
>> Hi everyone,
>>
>> Some time ago, I asked for a framework that would allow me to write
>> valid latex math from Pharo
>> (in a similar way that I used to do with pylatex in Python) see the
>> thread here:
>> http://forum.world.st/Generate-latex-from-Pharo-td4826739.html.
>>   From now, it does not support all the possible math commands of latex
>> but you can already do things like:
>>
>> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.
>>
>> and get:
>>
>> \begin{equation}
>> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}
>
> I think that's great news! One of Pillar's feature requests is to let
> users write LaTeX (e.g., formulas) in their pillar document and get nice
> results in all exports (LaTeX, HTML, ePub...):
> https://github.com/pillar-markup/pillar/issues/18. I'm not sure how this
> request fits in your work, but there might be some intersection.
>
I guess if a latex math parser is created, it is possible to use objects
from Mathex to represent an equation as Mathex objects.

After that the translation to html should be easy.

Maybe I'll give a try if I have some time.

Julien

Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Damien Cassou-2

Julien Delplanque <[hidden email]> writes:

> On 07/09/15 13:56, Damien Cassou wrote:
>> Julien Delplanque <[hidden email]> writes:
>>>
>>> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.
>>>
>>> and get:
>>>
>>> \begin{equation}
>>> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}
>>
>> I think that's great news! One of Pillar's feature requests is to let
>> users write LaTeX (e.g., formulas) in their pillar document and get nice
>> results in all exports (LaTeX, HTML, ePub...):
>> https://github.com/pillar-markup/pillar/issues/18. I'm not sure how this
>> request fits in your work, but there might be some intersection.
>>
> I guess if a latex math parser is created, it is possible to use objects
> from Mathex to represent an equation as Mathex objects.
>
> After that the translation to html should be easy.
>
> Maybe I'll give a try if I have some time.

we could ask the Pillar users to write using Mathex directly so we don't
have to write a LaTeX parser. The only remaining thing is to generate
png pictures from Mathex objects for inclusion in HTML.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Julien Delplanque


On 08/09/15 16:36, Damien Cassou wrote:

> Julien Delplanque <[hidden email]> writes:
>
>> On 07/09/15 13:56, Damien Cassou wrote:
>>> Julien Delplanque <[hidden email]> writes:
>>>> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.
>>>>
>>>> and get:
>>>>
>>>> \begin{equation}
>>>> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}
>>> I think that's great news! One of Pillar's feature requests is to let
>>> users write LaTeX (e.g., formulas) in their pillar document and get nice
>>> results in all exports (LaTeX, HTML, ePub...):
>>> https://github.com/pillar-markup/pillar/issues/18. I'm not sure how this
>>> request fits in your work, but there might be some intersection.
>>>
>> I guess if a latex math parser is created, it is possible to use objects
>> from Mathex to represent an equation as Mathex objects.
>>
>> After that the translation to html should be easy.
>>
>> Maybe I'll give a try if I have some time.
> we could ask the Pillar users to write using Mathex directly so we don't
> have to write a LaTeX parser. The only remaining thing is to generate
> png pictures from Mathex objects for inclusion in HTML.
>
Oh yeah, it would be easier to set up I guess :)

Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Offray
Hi,

On 08/09/15 13:02, Julien Delplanque wrote:

>
>
> On 08/09/15 16:36, Damien Cassou wrote:
>> Julien Delplanque <[hidden email]> writes:
>>
>>> On 07/09/15 13:56, Damien Cassou wrote:
>>>> Julien Delplanque <[hidden email]> writes:
>>>>> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation asString.
>>>>>
>>>>> and get:
>>>>>
>>>>> \begin{equation}
>>>>> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}
>>>> I think that's great news! One of Pillar's feature requests is to let
>>>> users write LaTeX (e.g., formulas) in their pillar document and get
>>>> nice
>>>> results in all exports (LaTeX, HTML, ePub...):
>>>> https://github.com/pillar-markup/pillar/issues/18. I'm not sure how
>>>> this
>>>> request fits in your work, but there might be some intersection.
>>>>
>>> I guess if a latex math parser is created, it is possible to use
>>> objects
>>> from Mathex to represent an equation as Mathex objects.
>>>
>>> After that the translation to html should be easy.
>>>
>>> Maybe I'll give a try if I have some time.
>> we could ask the Pillar users to write using Mathex directly so we don't
>> have to write a LaTeX parser. The only remaining thing is to generate
>> png pictures from Mathex objects for inclusion in HTML.
>>
> Oh yeah, it would be easier to set up I guess :)
>
>

Or maybe use mathjax instead of png to generate math on HTML:

https://www.mathjax.org/

Cheers,

Offray



Reply | Threaded
Open this post in threaded view
|

Re: Mathex: Generating latex math from Pharo.

Julien Delplanque


On 08/09/15 21:20, Offray Vladimir Luna Cárdenas wrote:

> Hi,
>
> On 08/09/15 13:02, Julien Delplanque wrote:
>>
>>
>> On 08/09/15 16:36, Damien Cassou wrote:
>>> Julien Delplanque <[hidden email]> writes:
>>>
>>>> On 07/09/15 13:56, Damien Cassou wrote:
>>>>> Julien Delplanque <[hidden email]> writes:
>>>>>> (Phi equal: ((1 asMathex + 5 asMathex sqrt) // 2)) equation
>>>>>> asString.
>>>>>>
>>>>>> and get:
>>>>>>
>>>>>> \begin{equation}
>>>>>> \phi=\frac{ 1 +\sqrt{ 5 }}{ 2 }\end{equation}
>>>>> I think that's great news! One of Pillar's feature requests is to let
>>>>> users write LaTeX (e.g., formulas) in their pillar document and
>>>>> get nice
>>>>> results in all exports (LaTeX, HTML, ePub...):
>>>>> https://github.com/pillar-markup/pillar/issues/18. I'm not sure
>>>>> how this
>>>>> request fits in your work, but there might be some intersection.
>>>>>
>>>> I guess if a latex math parser is created, it is possible to use
>>>> objects
>>>> from Mathex to represent an equation as Mathex objects.
>>>>
>>>> After that the translation to html should be easy.
>>>>
>>>> Maybe I'll give a try if I have some time.
>>> we could ask the Pillar users to write using Mathex directly so we
>>> don't
>>> have to write a LaTeX parser. The only remaining thing is to generate
>>> png pictures from Mathex objects for inclusion in HTML.
>>>
>> Oh yeah, it would be easier to set up I guess :)
>>
>>
>
> Or maybe use mathjax instead of png to generate math on HTML:
>
> https://www.mathjax.org/
>
> Cheers,
>
> Offray
>
>
>
Yes or even directly generate MathML it should not be difficult to implement
as an extension of Mathex.