Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: treo on June 18, 2004, 04:25:16 PM

Title: LATEX Parsing
Post by: treo on June 18, 2004, 04:25:16 PM
hi,
I'd like to add this feat. to my forum,
I have root access to the server so there is no problem in installing it.
But how do I add the parsing best?
Title: Re: LATEX Parsing
Post by: Oldiesmann on June 19, 2004, 10:38:13 AM
What exactly is LATEX? Can you give us a link for more info?
Title: Re: LATEX Parsing
Post by: Orstio on June 19, 2004, 12:13:29 PM
LaTeX is a math environment that makes pretty equations on the web:

http://crab.rutgers.edu/~karel/latex/class4/class4.html

It is an option in vBulletin.  It is used a lot at http://www.physicsforums.com .  If you go there and do a search for LaTeX you will see many examples.

There is a php LaTeX renderer for download here:

http://www.mayer.dial.pipex.com/tex.htm#latexrender
Title: Re: LATEX Parsing
Post by: treo on June 27, 2004, 09:54:32 AM
I've done that little modding :)

What you need is (debian packages ;) ):
tetex
tetex-extra
gs
imagemagick

and

http://www.mayer.dial.pipex.com/latexrender.zip

Rename otherPHP to latex, and edit latex.php.
Upload the latex folder to the Sources Folder and make chmod 777 tmp and chmod 777 pictures.
Try Out wether it works with the example.php. If it works delete example.php and do that change:

in Subs.php add after line 727:
include_once('Sources/latex/latex.php');
$message = latex_content($message);

Now you can use [tex][/tex] in your posts.
Additionally someone could create a button for it and add it to the template.

EDIT:
If you want to see it in action:
http://10e.ath.cx/index.php/topic,34.0
Title: Re: LATEX Parsing
Post by: Anguz on June 29, 2004, 06:18:12 AM
nice :)

/me wishes he could understand those formulas
Title: Re: LATEX Parsing
Post by: Jeff Lewis on June 29, 2004, 08:28:55 AM
Someone should throw that together into a MOD package ;)
Title: Re: LATEX Parsing
Post by: treo on June 29, 2004, 05:00:42 PM
tell me how and I'll do it myself ;)
And by now I have fund some things which have to be changed when modding because I first put it into the wrong line,
cause there are some bugs wenn using it over more than one line.
I'll have to repair it tomorow than I also will change that manual to build it in ;)
Title: Re: LATEX Parsing
Post by: Oldiesmann on June 30, 2004, 09:35:42 AM
Quote from: Anguz on June 29, 2004, 06:18:12 AM
nice :)

/me wishes he could understand those formulas

I understand it perfectly (for the most part). I'll explain them for you (I won't go into too much detail on the third thing because it's pretty complicated)

\sqrt(number) displays the formula for the square root of the number
\frac {numerator} {denominator} displays the fraction with the specified numerator (top number) and denominator (bottom number)

not sure what \displaystyle is

The third thing is calculus related. Basically, that means that the area under the curve created by graphing that function (the big x4(1-x)4 over 1+x2 fraction thing) from x=0 to x=1 is approximately 22/7 - pi. It's called an integral. If I tried to explain it to you, I'd probably end up confusing you even more, so I won't even try.
Title: Re: LATEX Parsing
Post by: Anguz on June 30, 2004, 11:23:54 AM
thank you for taking your time to tell me Oldiesmann

and happy birthday! (^_^)

Quote from: treo on June 29, 2004, 05:00:42 PM
tell me how and I'll do it myself ;)
And by now I have fund some things which have to be changed when modding because I first put it into the wrong line,
cause there are some bugs wenn using it over more than one line.
I'll have to repair it tomorow than I also will change that manual to build it in ;)

cool... get it to work as well as possible before releasing it and then you can get an existing package and see how it's done, a good one for that is [Unknown]'s named Say Something! he wrote it with the purpose of showing how it's done iirc
Title: Re: LATEX Parsing
Post by: Orstio on July 01, 2004, 09:07:24 PM
For those who do not have tetex, or as in my case, are on a server where the host has disabled exec(), you can also use the mimetex version available in the download link that Treo provided.

You'll need the precompiled mimetex.cgi binary, which is not easy to come by, but I did find one, so I've provided a Linux version: DOWNLOAD LINK (http://www.everything-science.com/mimetex.zip). 

If you need another version, go here:

http://moodle.org/download/mimetex/

right-click on the file that you need, and save as mimetex.cgi .

Upload this file to your cgi-bin and CHMOD to 755.

Just like Treo's version:

Upload the mimetex folder inside your Sources folder.  CHMOD the pictures folder to 777.

Edit mimetex.php to your server settings.

Try example.php .  If it works, do the mod:

in Subs.php, after line 728 add:

include_once('Sources/mimetex/mimetex.php');
$message = mimetex($message);

You can see it in action here:

LINK (http://www.everything-science.com/components/com_smf/index.php?topic=5207.msg49324)


Title: Re: LATEX Parsing
Post by: Anguz on July 01, 2004, 09:20:58 PM
great! thanks for your help

I downloaded the one you provided with this link
http://www.everything-science.com/mimetex.zip
and added it as an attachment to this post

/me remembers the YaBB SE mod threads with broken links (^^;)
Title: Re: LATEX Parsing
Post by: Orstio on July 01, 2004, 10:08:33 PM
Quote* Anguz remembers the YaBB SE mod threads with broken links (^^;)

Thanks for attaching the file here;  I would have, but I'm not able to post attachments.  I also remember the broken links at YaBB SE, and also at the YaBB Mod forums.
Title: Re: LATEX Parsing
Post by: stevem on July 15, 2004, 01:38:06 PM
Quote from: treo on June 27, 2004, 09:54:32 AM
I've done that little modding :)
...
If you want to see it in action:
http://10e.ath.cx/index.php/topic,34.0

Just come across your post. Would you mind if I put a link to http://10e.ath.cx/index.php on the LatexRender (http://www.mayer.dial.pipex.com/tex.htm#latexrender) page, plus put a copy of your modding instructions in the download (with attribution of course), so that others can benefit from it?

Steve Mayer
Title: Re: LATEX Parsing
Post by: stevem on July 15, 2004, 01:44:02 PM
Quote from: Orstio on July 01, 2004, 09:07:24 PM
For those who do not have tetex, or as in my case, are on a server where the host has disabled exec(), you can also use the mimetex version available in the download link that Treo provided.
...
You can see it in action here:

LINK (http://www.everything-science.com/components/com_smf/index.php?topic=5207.msg49324)

Same request  :) to put a copy of your instructions in LatexRender download plus a link to the forum.

Thanks
Title: Re: LATEX Parsing
Post by: Orstio on July 15, 2004, 06:18:27 PM
I have no problem with anyone using the instructions to get mimetex working with SMF, and links are always appreciated. ;)

I guess we should also extend a thank you for the download package. :D
Title: Re: LATEX Parsing
Post by: treo on July 16, 2004, 08:22:14 AM
stevem:
Soon I will make an Mod Demo Board where all my mods are in it,
10e.ath.cx is going down, because the class doesen't exist any more
Title: Re: LATEX Parsing
Post by: stevem on July 16, 2004, 08:37:03 AM
Let me know when you are ready and if you want a link. Meanwhile can I use your instructions or would you prefer I wait until the demo board is ready?
Title: Re: LATEX Parsing
Post by: treo on July 19, 2004, 05:12:35 AM
http://demoboard.hostspace.ath.cx/index.php?topic=2.0
Here is a slighty better description for installing it:


What you need is (debian packages):
tetex
tetex-extra
gs
imagemagick

and

http://www.mayer.dial.pipex.com/latexrender.zip

Safe Mode must be off

From the latexrenderer.zip take only the otherPHP/latexrenderer folder,
edit the latex.php in it so it fits your environment
Rename the latexrenderer folder to latex and put it into your Sources folder.

chmod 777 latex
chmod 777 latex/pictures
chmod 777 latex/tmp

try out wether it works with the example.php (open http://www.example.com/board/Sources/example.php), if it works delete example.php

In Subs.php:
Search for( should be at line 726):                 }
        }
        $message = substr(implode('', $parts), 1);

        // Fix things.
        $message = str_replace(
                array('{<{', '}>}', '  ', "\r", "\n"),

and replace it with:
                }
        }
        $message = substr(implode('', $parts), 1);
        include_once('Sources/latex/latex.php');
        $message = latex_content($message);
        // Fix things.
        $message = str_replace(
                array('{<{', '}>}', '  ', "\r", "\n"),


Now you can use [tex][/tex] in your Board.
Title: Re: LATEX Parsing
Post by: stevem on July 19, 2004, 06:17:28 AM
Thanks. I will put your instructions in the latexrender download plus the link to the demo board.

It shouldn't be necessary to chmod the latex folder, since the program only writes to pictures and tmp (unless you've discovered otherwise?).
Title: Re: LATEX Parsing
Post by: ccheaton on December 06, 2004, 08:56:26 PM
How can I determine, through cPanel, if I have these installed?
tetex
tetex-extra
gs
imagemagick
Title: Re: LATEX Parsing
Post by: Anguz on December 06, 2004, 11:09:07 PM
Maybe with a PHP info file?

<?php echo phpinfo(); ?>
Title: Re: LATEX Parsing
Post by: ccheaton on December 06, 2004, 11:15:08 PM
Hmm... I don't see any of that stuff listed when I look at the phpinfo file.  I emailed the admins at the hosting company.
Title: Re: LATEX Parsing
Post by: stevem on December 07, 2004, 01:33:25 PM
Yes, the hosting company will be able to tell you. You could also upload the example page from LatexRender and see what happens. That will tell you which bits are working and hence what is installed.

You may have to persuade your host to install the programs. If they don't agree to do so then you could use mimetex instead.
Title: Re: LATEX Parsing
Post by: ccheaton on December 14, 2004, 11:00:34 PM
Hmm.  Well, I can't figure this out.  The hosting company installed tetex for me, and said that everything else was installed (assuming that by 'gs' earlier, 'gd' was what the original poster meant to write).

I get a bunch of errors like this:
Quote
Warning: unlink(/home/myname/public_html/mydomain/Sources/latex/tmp/1f5b103e2cd542e8ca36ee50040c8e6c.aux): No such file or directory in /home/myname/public_html/mydomain/Sources/latex/class.latexrender.php on line 289
Title: Re: LATEX Parsing
Post by: stevem on December 15, 2004, 04:15:12 AM
gs means Ghostscript which is only required if you use GIF format rather than PNG for the images.

To see what's going on, comment out the 6 lines at the end of class.latexrender.php that start with unlink (do this by putting // at the start of each line). Then run the system and have a look in the tmp directory at the files in there. If Latex has been installed there will be a .log file and reading it will tell you what has happened. Also check what other files have been created: there should be files with extensions of log,aux,dvi,ps and gif or png.
Title: Re: LATEX Parsing
Post by: ccheaton on December 15, 2004, 07:25:44 AM
Well, there's error_log, index.php, and 8cac9ddb0af82890eb7225ca9e5a7bf6.tex.

However, the owner of the hosting company said that he installed tetex the other day.  Maybe my paths here are wrong?
Quote
    var $_latex_path = "/usr/bin/tetex";
    var $_dvips_path = "/usr/bin/dvips";
    var $_convert_path = "/usr/bin/convert";
    var $_identify_path="/usr/bin/identify";
Title: Re: LATEX Parsing
Post by: stevem on December 15, 2004, 12:58:04 PM
Since there's no 8cac9ddb0af82890eb7225ca9e5a7bf6.log file Latex hasn't been run. The paths you are using are the standard ones for Linux but
var $_latex_path = "/usr/bin/tetex";
should read
var $_latex_path = "/usr/bin/latex";
That's because latex is the name of the program to be run whereas tetex is the name of the whole distribution.
If this still doesn't generate a longfilename.log file ask your host whether the paths are correct or whether latex etc has been put elsewhere.

Quotethe owner of the hosting company said that he installed teTeX the other day
Lots of people are looking for a good company that supports LaTeX. Assuming you get it all working, is it the sort of company that sells to the general public and would you recommend their service to others? Ignore this or PM me if you'd rather not answer publically ;)
Title: Re: LATEX Parsing
Post by: ccheaton on December 15, 2004, 01:59:47 PM
Hey Steve... I'm working on getting it running.  The folks at the hosting company have been unresponsive for the past day or two.  I'll let you know if I get it working.  I had /usr/bin/latex, but just switched it to tetex to see if it would run.  No dice, so far.
Title: Re: LATEX Parsing
Post by: stevem on December 15, 2004, 02:29:36 PM
At http://www.linux.com/howtos/TeTeX-HOWTO-9.shtml and lots of other places they use /usr/lib/teTeX/bin for the paths so you would use
var $_latex_path = "/usr/lib/teTeX/bin/latex";
var $_dvips_path = "/usr/lib/teTeX/bin/dvips";
var $_convert_path = "/usr/lib/teTeX/bin/convert";
var $_identify_path= "/usr/lib/teTeX/bin/identify";

Worth a try while you wait for a reply.
Title: Re: LATEX Parsing
Post by: ccheaton on December 15, 2004, 06:13:09 PM
Ok, after some discussion with them, I'm now getting the files that you mentioned previously, but still getting an error.  Now the error is:

Quote
Warning: copy(9ede2d4d1a980ca952f8cc680009883f.png): failed to open stream: No such file or directory in /home/myname/public_html/mydomain/Sources/latex/class.latexrender.php on line 271

attached is the log file.  Let me know if you need to see another file.  Looks like latex is running now, but the images aren't generated?

BTW, the log might be from a different attempt than the text that I pasted.
Title: Re: LATEX Parsing
Post by: stevem on December 16, 2004, 05:09:49 AM
Yes the log confirms that LaTeX is working correctly and given the lack of other error messages everything is being created except the final image. That is done by ImageMagick's convert command. That's partly my fault, since the paths I wrote above are for tetex rather than Imagemagick  :'(
Change
var $_convert_path = "/usr/lib/teTeX/bin/convert";
var $_identify_path= "/usr/lib/teTeX/bin/identify";

to give the correct paths for Imagemagick's convert and identify programs. Usually it is
var $_convert_path = "/usr/bin/convert";
var $_identify_path="/usr/bin/identify";

but it may be elsewhere on your server.
Title: Re: LATEX Parsing
Post by: ccheaton on December 17, 2004, 10:38:30 AM
Ok.  I asked the people, and they said that those files are in place and that the paths are correct, so that must mean that something else is incorrect.  What do I need to send you in order for you to see what's going on?
Title: Re: LATEX Parsing
Post by: stevem on December 17, 2004, 12:16:45 PM
Concentrate on getting the example program, working because that won't be complicated by having another PHP program to interact with. Even better, the demo program includes extra error messages which may help.

Comment out the 6 unlink lines in class.latexrender.php, if you haven't done so already and run the program. Check which files are created in \tmp. Then repeat with changing the file format to gif. Have a look at the contents of any error.log created in \tmp

Then try using
\begin{picture}
as the LaTeX code. What error message do you get? It should say the image is 1020 x 1320
Title: Re: LATEX Parsing
Post by: ccheaton on December 17, 2004, 09:17:51 PM
When I have nothing but \begin{picture}, I get the following error. 
Quote
Warning: copy(af0601cdb2921d2b6bf5c5ea5dd48b78.gif): failed to open stream: No such file or directory in /home3/ccheaton/public_html/mydomain/Sources/latex/class.latexrender.php on line 271
Maybe I have a path set wrong? 

It just never seems to write the images to the pictures directory.  Should this line in class.latexrender.php look like this?
Quote
    var $_picture_path_httpd = "http://mydomain.com/Sources/latex/pictures";

Title: Re: LATEX Parsing
Post by: stevem on December 18, 2004, 07:46:20 AM
You don't set paths (except for latex, dvips, convert,identify) in class.latexrender.php. The lines
    var $_picture_path = "";
    var $_picture_path_httpd = "";
    var $_tmp_dir = "";

are just there to initialise the variables which are set when the class is called. You only need to put the paths in phpbb_hook_2.php or latex.php (depending what PHP program you are using).

Use
    $latexrender_path = "/home3/ccheaton/public_html/mydomain/Sources/latex";
    $latexrender_path_http = "/mydomain.com/Sources/latex";

or similar

If the picture is not there this could be for a number of reasons:
1. The picture is not being created. After commenting out the unlink lines check that the gif or png is in /tmp
2. The picture is not being copied because either the path is wrong or you haven't chmodded pictures to 777
Title: Re: LATEX Parsing
Post by: ccheaton on December 18, 2004, 09:19:43 AM
Argh.  Well, everything is chmod 777.  My class.latexrender.php contains:
Quote
    // ====================================================================================
    // Variable Definitions
    // ====================================================================================
    var $_picture_path = "";
    var $_picture_path_httpd = "";
    var $_tmp_dir = "";
    // i was too lazy to write mutator functions for every single program used
    // just access it outside the class or change it here if nescessary
    var $_latex_path = "/usr/bin/latex";
    var $_dvips_path = "/usr/bin/dvips";
    var $_convert_path = "/usr/bin/convert";
    var $_identify_path="/usr/bin/identify";
And my latex.php contains
Quote
    // adjust this to match your system configuration
    $latexrender_path = "/home3/ccheaton/public_html/mydomain/Sources/latex";
    $latexrender_path_http = "/mydomain.com/Sources/latex";

Could the problem be that the folder that contains 'mydomain' has a namestructure 'mydomain.com'?

The fact that the debug files are written to the tmp directory leads me to believe that I don't have an error in the path.  Maybe something just isn't set up properly with the host.   :-\
Title: Re: LATEX Parsing
Post by: stevem on December 18, 2004, 09:36:51 AM
According to
$latexrender_path = "/home3/ccheaton/public_html/mydomain/Sources/latex";
you have a folder called mydomain. This is accessed in a browser by going to http://your_domain_name/mydomain. This means that you should have
$latexrender_path_http = "/mydomain/Sources/latex";
I'm not sure where .com comes from.

To make this clear - suppose you have a domain name of www.thisisme.com and you have put the latex stuff in a folder called latex_stuff. Then this is seen by the server as
/home3/ccheaton/public_html/latex_stuff
and by a browser as
http://www.thisisme.com/latex_stuff
You'll notice that thisisme.com doesn't appear in the server's file structure, but is needed by the browser to find the server itself.

So I am a little confused by where you have stored the files. The path in $latexrender_path_http  should be the ones after public_html in the server folder structure.

Do feel free to email me if you wish to discuss folders etc which you don't wish to make public.
Title: Re: LATEX Parsing
Post by: ccheaton on December 18, 2004, 11:25:55 AM
I'm running several domains from the same structure, for what it's worth.  /home3/ccheaton/public_html is one domain, which has its own URL -- http://www.mydomain1.com  the subfolder /mydomain/ is another domain, http://www.mydomain2.com

So, the domain that I'm using lives in a subfolder of another domain, but has its own URL.  Get it?   :)  In this case, I'm actually going for mydomain2.com, which is in the directory /home3/ccheaton/public_html/mydomain/

Title: Re: LATEX Parsing
Post by: stevem on December 18, 2004, 12:16:11 PM
From what you've said the HTML code for the image should be generated as img src="/Sources/latex/pictures/longfilename.gif". The browser will then realise that this is a relative link to http://mydomain2.com/Sources/latex/pictures/longfilename.gif

The code knows about /pictures so all it needs is the first part which is given by
$latexrender_path_http = "/Sources/latex";

If you browse to http://mydomain2.com/Sources/latex/pictures (note: I have corrected this URL) and get anything then this is correct.

$latexrender_path = "/home3/ccheaton/public_html/mydomain/Sources/latex";
should be correct.

Don't forget to check if the png/gif is being created in /tmp

Title: Re: LATEX Parsing
Post by: ccheaton on December 18, 2004, 02:57:48 PM
Well, that's the problem.  The .png/.gif is not being generated.  Or, it's being generated but not written to the tmp directory?
Title: Re: LATEX Parsing
Post by: stevem on December 18, 2004, 03:18:55 PM
Is the .ps file being created correctly? Do you also get the .dvi file? If so, then the path to /tmp is correct but Imagemagick is not working and you must check the path to convert & identify is correct. Are you allowed shell access to check this? If so, then you can run some of the commands class.latexrender.php issues and see any errors it produces.
Title: Re: LATEX Parsing
Post by: ccheaton on December 18, 2004, 11:28:50 PM
I probably have shell access, though I haven't used it before.  I'll check into it in a few days -- right now, I have to get through final exams!   :o
Title: Re: LATEX Parsing
Post by: hefesto on April 10, 2006, 08:39:23 PM
I know that this topic is quite old, but I can't find a solution.

I've performed the first steps, and I can get the example.php file working (the equations are rendered). But I'm using SMF 1.1RC2, and I can't get it to work.

I've added the mimetex function at the end of the subs.php file, but I can't find the code to be replaced...

Thanks in advance for your help.
Title: Re: LATEX Parsing
Post by: Orstio on April 10, 2006, 09:27:44 PM
Find this in Subs.php (~line 2356):

// Cache the output if it took some time...
if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
cache_put_data($cache_key, $message, 240);


And add this immediately after it:

$message = mimetex($message);
Title: Re: LATEX Parsing
Post by: hefesto on April 10, 2006, 10:14:47 PM
Thanks very much for your quick reply, Orstio.

So, is it still necessary to add

include_once('Sources/mimetex/mimetex.php');
$message = mimetex($message);


after line 728?

Mimetex function is already added at the end of subs.php file.

It worked for the first formula, but no more. Maybe I'm using the wrong mimetex.cgi. I've tried a couple (both of them for Linux). Where should I look for the correct one?
Title: Re: LATEX Parsing
Post by: Orstio on April 10, 2006, 10:18:49 PM
QuoteSo, is it still necessary to add


Code:
include_once('Sources/mimetex/mimetex.php');
$message = mimetex($message);
after line 728?

No.  Those instructions were for SMF 1.0 RC2.
Title: Re: LATEX Parsing
Post by: hefesto on April 11, 2006, 08:31:35 AM
All right, it's working fine now (I was having a problem with file permissions).

Thanks very much Orstio  ;).
Title: Re: LATEX Parsing
Post by: Avinash4 on June 13, 2006, 12:09:25 PM
Hey, I can't get example.php working for mimetex. This is what I get:
This is just text but [Mimetex cannot convert this formula] should be shown as an image and so should [Mimetex cannot convert this formula].

Another formula is [Mimetex cannot convert this formula]

Any ideas? I followed all instructions precisely.

Also, I was wondering which is more efficient, mimetex or the latex using imagemagick + textex.
Title: Re: LATEX Parsing
Post by: stevem on June 13, 2006, 12:26:06 PM
Have you tried changing $system_disabled=0; to $system_disabled=1; in mimetex.php? Is mimtex.cgi working correctly - try http://put_your_path_here/mimetex.cgi?x^2 and see if it gives an image of x-squared.

Quote from: Avinash4 on June 13, 2006, 12:09:25 PM
Also, I was wondering which is more efficient, mimetex or the latex using imagemagick + textex.
I'm not sure what you mean by efficient. LaTex gives a much better image but, unlike mimeTeX, it requires LaTeX, ImageMagick and GhostScript to be installed on the server and not just on your part of it.
Title: Re: LATEX Parsing
Post by: Avinash4 on June 13, 2006, 12:30:20 PM
Thanks for the quick reply. When I run that this is what happens:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Title: Re: LATEX Parsing
Post by: stevem on June 13, 2006, 12:34:45 PM
Good news - that usually just means you have forgotten to change the permissions on mimetex.cgi to 755. If that's not the problem then check with your host that they haven't disabled use of cgi programs.
Title: Re: LATEX Parsing
Post by: Avinash4 on June 13, 2006, 12:37:02 PM
[R] SITE CHMOD 755 mimetex.cgi
[R] 200 Permissions changed on mimetex.cgi
[R] PASV

I did that through FTP, and still the same error  >:(
Title: Re: LATEX Parsing
Post by: Avinash4 on June 13, 2006, 12:49:40 PM
This is what tech support said:

Basil: The file /cgi-bin/mimetex.cgi is not a cgi script. It is a binary executable file. this file can not be run on our servers.
Basil: It is possible to run executables but not using a .cgi extension.
Title: Re: LATEX Parsing
Post by: stevem on June 13, 2006, 12:56:01 PM
Hmm - it may not be possible to run mimetex.cgi on your server, but before giving up contact mimeTeX's author John Forkosh (see http://www.forkosh.com/mimetex.html for his email address) and tell him what tech support say. He may be able to help.
Title: Re: LATEX Parsing
Post by: Avinash4 on June 13, 2006, 12:58:43 PM
Thanks for all the help stevem. Just one last question. If mimetex cannot run properly, if I manage to convince my host to install GhostScript and Latex, will Latex rendering work?
Title: Re: LATEX Parsing
Post by: stevem on June 13, 2006, 01:06:46 PM
Provided Latex, ImageMagick and Ghostscript are all working then you should have no trouble using LatexRender with SMF -see treo's demo at http://demoboard.hostspace.ath.cx/index.php?topic=2.0 for example.
Title: Re: LATEX Parsing
Post by: Avinash4 on July 25, 2006, 09:08:03 AM
I contacted my hosting support today about installing Latex for me, and this was their response:
Quote from:  hostgator support:
Hello,

Please confirm if you need only Latex installed. Latex has other libraries like texvc etc, are you sure you do not need those ?

Now, I have no clue what this means. I saw earlier in this thread that you need:
tetex
tetex-extra
gs
imagemagick

I know that ImageMagick is already installed. Should I tell him to install all of those plus latex. Or Just the ones above, and not Latex itself?
Title: Re: LATEX Parsing
Post by: stevem on July 25, 2006, 09:19:41 AM
Yes you do need all those installed. tetex is in fact a very common LaTeX distro for Linux/Unix so it is actually LaTeX. You don't need texvc though
Title: Re: LATEX Parsing
Post by: Avinash4 on July 25, 2006, 11:51:55 AM
Quote from: stevem on July 25, 2006, 09:19:41 AM
Yes you do need all those installed. tetex is in fact a very common LaTeX distro for Linux/Unix so it is actually LaTeX. You don't need texvc though
Thanks a lot. I'll let my host know, and hopefully they still agree to install it.
Title: Re: LATEX Parsing
Post by: Avinash4 on July 26, 2006, 08:49:36 AM
One more question, where can I find tetex-extra for RHEL (red hat linux). I only found one for debian right now. My host installed the rest, but not tetex-extra. Any ideas?
Title: Re: LATEX Parsing
Post by: Avinash4 on July 26, 2006, 09:28:42 AM
From what I can see, my example.php works fine. I was wondering what I'd have to mod is Subs.php to get it to work with SMF 1.1RC2. I'm not using the mimetex version, so I suppose it will be different from the poster above.
Title: Re: LATEX Parsing
Post by: Avinash4 on July 26, 2006, 11:28:02 AM
I kinda have it working now. However, when I create formulas in the SMF post box, it includes html in the formula. See the attachment. Any ideas why this is?

http://img231.imageshack.us/my.php?image=45ba4e04f2fd7942ecfb49e298f3be1ayf7.gif

Title: Re: LATEX Parsing
Post by: Avinash4 on July 26, 2006, 01:43:19 PM
Okay, I seem to have that fixed now. I used instructions from this page:

Quote from: schamock on June 18, 2006, 07:34:47 AM
sers
hat sich schon erledigt... hätte mir mal die latex.php richtig anschaun solln. Da sind nämlich schon Statements vorbereitet, um die HTML-Kodierung rückgängig zu machen... jaja wer lesen kann... ;)

Falls es wen interessiert, wo ich das eingefügt hab: am Anfang von parse_bbc (ca. Zeile 950). Sieht dann so aus:

function parse_bbc($message, $smileys = true, $cache_id = '')
{
global $txt, $scripturl, $context, $modSettings, $user_info;
static $bbc_codes = array(), $itemcodes = array(), $no_autolink_tags = array();
static $disabled;

// LATEX
include_once('Sources/latex/latex.php');
$message = latex_content($message);

        ....


und die latex_content() in der latex.php sieht dann so aus:

function latex_content($text) {
// adjust this to match your system configuration
$latexrender_path = "/var/www/_smf/Sources/latex";
$latexrender_path_http = "/_smf/Sources/latex";

include_once($latexrender_path."/class.latexrender.php");

preg_match_all("#\[tex\](.*?)\[/tex\]#si",$text,$tex_matches);

$latex = new LatexRender($latexrender_path."/pictures",$latexrender_path_http."/pictures",$latexrender_path."/tmp");

for ($i=0; $i < count($tex_matches[0]); $i++) {
$pos = strpos($text, $tex_matches[0][$i]);
$latex_formula = $tex_matches[1][$i];

$latex_formula = str_replace("&amp;","&",$latex_formula);
$latex_formula = str_replace("&","&",$latex_formula);
$latex_formula = str_replace("&nbsp;"," ",$latex_formula);
$latex_formula = str_replace("<BR>","",$latex_formula);
$latex_formula = str_replace("<br />","",$latex_formula);
$latex_formula = str_replace("<P>","",$latex_formula);
$latex_formula = str_replace("</P>","",$latex_formula);

$url = $latex->getFormulaURL($latex_formula);

$alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES);
$alt_latex_formula = str_replace("\r","",$alt_latex_formula);
$alt_latex_formula = str_replace("\n","",$alt_latex_formula);

if ($url != false) $text = substr_replace($text, "<img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."' align=absmiddle>",$pos,strlen($tex_matches[0][$i]));
else $text = substr_replace($text, "[Unparseable or potentially dangerous latex formula. Error $latex->_errorcode $latex->_errorextra]",$pos,strlen($tex_matches[0][$i]));
}
return $text;
}


Everything works fine with the equations and latex...
Now, When I click my coppermine photo gallery I get:
Fatal error: Call to undefined function: latex_content() in /home/*****/public_html/smf/Sources/Subs.php on line 962. What could the problem be, judging on the code above?
Title: Re: LATEX Parsing
Post by: jmbr on December 02, 2006, 10:17:51 PM
Hi,

I wrote a small patch to SMF 1.1 to add support for mimetex.  You can fetch it from http://darcs.superadditive.com/smf-mimetex/smf-1.1-mimetex.diff
There's some more information about it at http://blog.superadditive.com/2006/12/03/quick-way-to-use-mimetex-with-smf/
Title: Re: LATEX Parsing
Post by: thylow on November 13, 2007, 04:43:52 PM
What do I do with and ERROR 4.
It says I can't create a DVI File.

http://homeworkdiscussion.com/latexrender/example.php

Here is my demo
Title: Re: LATEX Parsing
Post by: scimmiotto on May 13, 2009, 10:43:03 AM
hi
how to change color text with math expressions? with this theme

http://ingegneria.bebnet.org/index.php?topic=98.msg203#msg203

i see expressions in aliased white.
Title: Re: LATEX Parsing
Post by: apcalculus on June 24, 2009, 01:33:27 PM
thank you Orstio for the instructions.

In the mimetex instructions there is one additional change that asks replacing some text (full instructions here http://physweb.bgu.ac.il/DOWNLOADS/Mimetex/mimetex_phpbb/readme_SMF.txt )
For some reason I cannot find the text the author refers to in Subs.php. Has anybody followed those 'new' instructions and made mimetex work?

I need some help deciding if the following are correct. The location of the key files are
htdocs/cgi-bin/mimetex.cgi
htdocs/smf/  ---> parent forum folder

Are my parameters below correct?

$mimetex_path = "/cgi-bin/mimetex.cgi";
$mimetex_path_http = "http://localhost/smf/Sources//mimetex";
$mimetex_cgi_path_http="http://localhost/cgi-bin/mimetex.cgi";
$pictures_path = "/htdocs/smf/Sources/mimetex/pictures";


In Orstio's instructions it says to add two lines after line 728. In the recent Subs.php, that appears to be the middle of a function. Is that correct?

I have not had any luck with this, even after changing the settings so I'd appreciate some feedback or ideas. I am using the most recent version of SMF, downloaded yesterday.

Thanks!
Title: Re: LATEX Parsing
Post by: apcalculus on June 24, 2009, 02:28:01 PM
never mind my previous post folks. I found solution at http://custom.simplemachines.org/mods/index.php?mod=1111
Title: Re: LATEX Parsing
Post by: jaccione on August 29, 2010, 11:26:54 PM
Just found this mod and installed it on 2.0RC3, it failed on install, but is very easy to modify to work with newer version
Title: Re: LATEX Parsing
Post by: AirBeagle1 on October 19, 2010, 10:39:21 PM
Would love to know how you made it work...   Thanks! ;D