LaTeX support in phpBB3

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
student12
Registered User
Posts: 17
Joined: Sun Jan 22, 2006 8:51 pm
Location: tif
Contact:

Re: LaTeX support in phpBB3

Unfortunately , i chick it now
the first field has the correct tags: $${TEXT}$$

the second field is empty,

it was contains <tex>{TEXT}</tex> but I deleted it early.
_____________

typeshige
Registered User
Posts: 1
Joined: Mon Feb 18, 2008 5:19 am

Re: LaTeX support in phpBB3

Hi. Please tell me if this is the wrong area. This is my first post and I'm brand-new to phpBB. I'm working on a project for a client that needs LaTeX support. After reading the excellent tips here, I got it working, but the gif output is essentially unreadable.

Does anyone have any tips on figuring out why it outputs so poorly? It's probably a font issue...

I'm using Gentoo Linux and TeXLive, GS all basically out of the box with as many fonts as I could install.

Thanks,
Shige

student12
Registered User
Posts: 17
Joined: Sun Jan 22, 2006 8:51 pm
Location: tif
Contact:

Now , it is working

Dear stevem, it is working far all posts, new and old.

But unfortunately, there is some issue
the tex code rendered to incorrect symbols
for example

Code: Select all

$$\begin{array}{l} \mathop {\lim }\limits_{n \to \infty } \left( {\frac{{\;\;\;a_n \;\;\;}}{{\frac{1}{n}}}} \right) = 0\quad \Rightarrow \quad \\ \\ \forall \varepsilon > 0\;;\;\exists \;n_\varepsilon \in N\;:\forall n > n_\varepsilon \Rightarrow \left( {\frac{{\;a_n \;}}{{\frac{1}{n}}}} \right) < \varepsilon \Rightarrow \\ \\ for\;\varepsilon = 1 \Rightarrow a_n < \frac{1}{n} \\ \end{array}$$
Renderd to:

and

Code: Select all

$$e^{m(m + 1)} \ge \left[ {(m + 1)!} \right]^2$$
Renderd to:

also

Code: Select all

$$S = \left( {\sqrt 2 - 1} \right)^k$$
Renderd to:

it seems latexrender convert ( to 40; and convert ) to 41;
i don't understand why this happen?

regards
_____________

stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: LaTeX support in phpBB3

The brackets ( and ) are being converted by the forum somewhere. But it is easy to repair; all you have to do is convert back again before using LaTeX.
After the line

Code: Select all

$latex_formula = html_entity_decode($tex_matches[1][$i]); add Code: Select all $latex_formula = str_replace("&#40;","(",$latex_formula);$latex_formula = str_replace("&#41;",")",$latex_formula); student12 Registered User Posts: 17 Joined: Sun Jan 22, 2006 8:51 pm Location: tif Contact: Thanks So Much i did your suggestion, and latex is working fine. thank you very much dr. stevem for your efforts and time that you have spent for help. _____________ student12 Registered User Posts: 17 Joined: Sun Jan 22, 2006 8:51 pm Location: tif Contact: Re: LaTeX support in phpBB3 what about if i want to enforce all tex codes to rendered as /displaystyle formulas ? _____________ stevem Registered User Posts: 398 Joined: Sun Aug 25, 2002 1:59 pm Re: LaTeX support in phpBB3 After the line Code: Select all $latex_formula = html_entity_decode($tex_matches[1][$i]);

Code: Select all

$latex_formula = "\displaystyle ".$latex_formula;

texasmath
Registered User
Posts: 12
Joined: Tue Feb 19, 2008 2:59 am

Re: LaTeX support in phpBB3

(Sorry about the delay. Flu's been beating me up something fierce.)

Thanks for all the help, I appreciate it.

Now I'm getting [unparseable or potentially dangerous latex formula]. I commented out the unlink commands in class.latexrender.php and it's creating a .aux, .dvi (which appears correct), .log, and .ps file in the tmp folder, but no picture in the pictures folder.

I do have convert installed, and the path is linked to where the which command lists it at.

Any ideas? I appreciate all the help.

TDP.

stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: LaTeX support in phpBB3

As there's no gif in /tmp it looks as if ImageMagick can't find Ghostscript which is not uncommon, particularly if the Ghostscript binary gs is not in /usr/bin. ImageMagick does this behind the scenes so the workaround is to add Ghostscript's directory to the path. Try this solution posted at http://sixthform.info/steve/wordpress/?p=34#comments

Code: Select all

// class.latexrender.php

// begin of workaround
// extending the PATH environmental variable
$oldpath = getenv(”PATH”);$where_gs_is = “/usr/sfw/bin”;
if ($oldpath) {$where_gs_is .= “:$oldpath”;} putenv(”PATH=$where_gs_is”);
// end of workaround

// imagemagick convert ps to image and trim picture
$command =$this->_convert_path.” -density “.$this->_formula_density. ” -trim -transparent “#FFFFFF” “.$this->_tmp_filename.”.ps “.
$this->_tmp_filename.”.”.$this->_image_format;
$status_code = exec($command);

texasmath
Registered User
Posts: 12
Joined: Tue Feb 19, 2008 2:59 am

Re: LaTeX support in phpBB3

...particularly if the Ghostscript binary gs is not in /usr/bin...

Code: Select all

$which gs /usr/bin/gs  Nevertheless, I tried (both) of the suggestions on his page (after changing all the "pretty quotes" to real quotes, and changing my path to /usr/bin/), and still have the [unparsable...] error. I'm now getting these error messages on the top of my page: Code: Select all [phpBB Debug] PHP Notice: in file /var/www/texasmath.org/forum/latexrender/class.latexrender.php on line 281: copy(dd6210eb85556bb9343eca2a99d195ba.gif) [function.copy]: failed to open stream: No such file or directory [phpBB Debug] PHP Notice: in file /includes/functions.php on line 3391: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922) [phpBB Debug] PHP Notice: in file /includes/functions.php on line 3393: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922) [phpBB Debug] PHP Notice: in file /includes/functions.php on line 3394: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922) [phpBB Debug] PHP Notice: in file /includes/functions.php on line 3395: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)  I do appreciate all the help. It's probably something fairly minor that I'm missing out on. TDP stevem Registered User Posts: 398 Joined: Sun Aug 25, 2002 1:59 pm Re: LaTeX support in phpBB3 Basically al the error messages are saying is that it can't find gif so can't copy it, then PHP objects to showing those error messages! If gs in /usr/bin there shouldn't have been a problem. The thing to do now is try a convert from the command line and see what error messages you get. CD to the /tmp diretcory and change the name of one of the long-named .ps files to test.ps. Then use Code: Select all convert -density 120 -trim -transparent #FFFFFF test.ps test.gif If that doesn't work try taking bits of the command out (like -trim etc) to see what is causing the problem. Maybe it is the same as http://sixthform.info/steve/wordpress/?p=34#comments http://sixthform.info/steve/wordpress/?p=34#comments wrote:I was getting the same symptoms and I discovered it was because my convert doesn’t support the -trim option. I was able to get it to work by replacing “-trim” with “-crop 0×0″ in the line defining$command.

texasmath
Registered User
Posts: 12
Joined: Tue Feb 19, 2008 2:59 am

Re: LaTeX support in phpBB3

I tried both commands, and it told me there were problems with the options:

Code: Select all

$convert -density 120 -crop0x0 -transparent #FFFFFF test.ps test.gif convert: unrecognized option -crop0x0'.$ convert -density 120 -trim -transparent #FFFFFF test.ps test.gif
convert: missing an image filename -transparent'.

So I tried a straight convert, with no options, just to see what's going on:

Code: Select all