Page 37 of 39

Re: math equations (with latex)

Posted: Wed Mar 19, 2008 2:19 pm
by TheHighwayman
OK stevem,
thank you for the answer.

I'll try it and post results.

TheHighwayman

Re: math equations (with latex)

Posted: Wed Apr 30, 2008 8:32 pm
by takufner
Hi Stevem,

My first main problem was solved using the script indicated by you. Thanks.

Now, the second problem is still with me. My mimetex is not caching the images.

This is what I've done so far:

In phpbb_hook_2.php (the mimetex version) I made the changes:
1) replaced $uid by $bbcode_uid twice
2) replaced $text by $message eight times

And in includes/bbcode.php I made:

Code: Select all

}
		}
		include("/home/tutorbra/public_html/phpBB3/mimetex/phpbb_hook_2.php");
		// Remove the uid from tags that have not been transformed into HTML
		$message = str_replace(':' . $this->bbcode_uid, '', $message);
	}

	/**
	* Init bbcode cache
And I made a BBCode that does

Code: Select all

[tex]{TEXT}[/tex]
swaps to

Code: Select all

<img border="0" align="middle" alt="{TEXT}" src="http://www.tutorbrasil.com.br/cgi-bin/mimetex.cgi?{TEXT}"/>
And when I write a new post in my forum, no problem, the equation is there, but the url for the image is not from the cache, it is from the mimetex. And the cache directory (mimetex/pictures) remains empty.

I'd like to use the cache feature.

Thanks

Re: math equations (with latex)

Posted: Wed Apr 30, 2008 8:44 pm
by takufner
Hi,

I realized that there is no mention about the files phpbb_hook_1.php and mimetex.php. And the function mimetex, in mimetex.php, is the responsible in doing such caching work, isn't?

Re: math equations (with latex)

Posted: Wed Apr 30, 2008 9:14 pm
by stevem
in phpBB3 you only need phpbb_hook_2.php. mimetex.php is for the example and other non-phpbb programs. mimetex.php and phpbb_hook_2.php share the same code.

The caching is done in the line

Code: Select all

$command = "$mimetex_path -e ".$full_path_filename." ".escapeshellarg($mimetex_formula);
which gets mimetex to save the images in the pictures file.
For this to happen you need to check that you have

Code: Select all

$system_disabled=0;
and that $full_path_filename is correct. It comes from the line

Code: Select all

$full_path_filename = $pictures_path."/".$filename; 
and so $pictures_path must be correct near the top of phpbb_hook_2.php. I think that in your case it should be something like

Code: Select all

$pictures_path = ("/home/tutorbra/public_html/phpBB3/mimetex/pictures";
though I cannot be sure exactly where it is on your system
Also the /pictures directory must be writeable to so should be chmod 777.

Re: math equations (with latex)

Posted: Wed Apr 30, 2008 10:11 pm
by takufner
Hi Stevem,

Thanks for your quick reply.

All this things you said are all done and all right with my code.

I recently realized that the iteration

Code: Select all

for ($i=0; $i < count($tex_matches[0]); $i++) {
Isn't iterating because count($tex_matches[0]) is always ZERO, no matter how much TeX tags I put in my message.

I discovered this puting the line:

Code: Select all

$message = count($tex_matches[0]);
for ($i=0; $i < count($tex_matches[0]); $i++) {
I think this is the problem because the $command you told me, it's inside this "for".

I am still trying to identify something else, but with this information maybe you can give me some answer...

Thank you for your patience.

Re: math equations (with latex)

Posted: Wed Apr 30, 2008 10:44 pm
by stevem
It looks like no formula is being found. Is the line

Code: Select all

preg_match_all("#\[tex:$bbcode_uid\](.*?)\[/tex:$bbcode_uid\]#si",$message,$tex_matches);
what you have in phpbb_hook_2.php? If so, the code is not getting this far.
After this line try adding temporarily the line

Code: Select all

echo "Message is $message<br>;
That will tell you what text is being seen by phpbb_hook_2.php. You will get a whole bunch of PHP errors about headers which you can ignore (PHP is just saying it didn't expect to print text at this point) but if there is a blank message then the problem is not inside phpbb_hook_2.php.

Re: math equations (with latex)

Posted: Thu May 01, 2008 2:49 pm
by takufner
Hi Stevem,

I put the echo indicated by you and discovered that the $message, in the line where the "include" was, was already without TeX tags, they were already swaped to img html tags.

Then, I put the include in other place before the "foreach" iteration:

Code: Select all

		$undid_bbcode_specialchars = false;

		include("/home/tutorbra/public_html/phpBB3/mimetex/phpbb_hook_2.php");
		foreach ($bbcodes_set as $bbcode_id)
And now the caching is working properly.

Are there some other things that this code change could do? Or this place is ok to let the "include" line?

Re: math equations (with latex)

Posted: Thu May 01, 2008 3:21 pm
by stevem
bbcode.php seems to have changed probably causing the problem. There shouldn't be a problem with moving the include line since you don't want the search and replace functions altering the LaTeX code; but only trying it out will tell if there are any problems.

Re: math equations (with latex)

Posted: Sat May 03, 2008 6:42 pm
by takufner
I discovered that, with the include in this place, all the parenthesis are replaced for the html code. Like this, the code

Code: Select all

[tex](x-1)[/tex]
swaps to an image like this

Code: Select all

&#40;x-1&#41;
but the cache is working fine, hehehe.

Thanks

Re: math equations (with latex)

Posted: Sat May 03, 2008 7:05 pm
by stevem
Fortunately that problem is easy to solve. In phpbb_hook_2.php after the line

Code: Select all

$mimetex_formula = html_entity_decode($tex_matches[1][$i]);
add the lines

Code: Select all

$mimetex_formula = str_replace("&#40","(",$mimetex_formula);
$mimetex_formula = str_replace("&#41",")",$mimetex_formula);
You can do the same for any other similar problems.

Re: math equations (with latex)

Posted: Wed Jun 11, 2008 3:14 am
by Le File
I want to say sorry first because i post to old topic, but i'm stucked with this problem until now. I want to make Latex in my forum too, but I'm still confuse with the explanation. Some question in my mind is :
1. What should i do first?
2. Must i install latex program like TexnicCenter, or somewhat?
Thanx for your explanation

Re: math equations (with latex)

Posted: Wed Jun 11, 2008 8:47 am
by stevem
You must have root access to your server and then install TeX, ImageMagick and Ghostscript. You would need to ask your host how to do that as every system is different. You cannot do it on a hosted system where you have no root access. What operating system does your server run?
TexnicCenter is an editor for Windows which you don't need since you are editing in phpBB.
If you don't have root access consider using an external server by using mathTeX.

Re: math equations (with latex)

Posted: Wed Jun 11, 2008 12:18 pm
by Le File
My operating system is windows, and i use phpBB3.0.x, not 2.0.x. Can latexrender fit in that OS? But i'm still wonder, how the script create an image? Are you sure i shouldn't install the latex editor? Now, i use mimetex, but i can't create cgi file, how to create that? Thanx

Re: math equations (with latex)

Posted: Wed Jun 11, 2008 1:14 pm
by stevem
So your server (NOT your own private computer) runs Windows? Then install MiKTeX, Ghostscript and ImageMagick on it and then follow the instructions at LaTeX support in phpBB3 to get LatexRender to work in phpBB3.

Why would you want an editor on the server? TexnicCenter is not meant for internet use but on your own private computer. Also phpBB3 has its own editor where you type the messages like this and then LatexRender converts it to an image so there's no use for another editor.

Re: math equations (with latex)

Posted: Wed Jun 11, 2008 1:34 pm
by Le File
Yes of course MY SERVER (web hosting) use windows. Ok i'll try later. Last questions, why you don't try to use mimetex? Can Latexrender try in localhost? Thanx