math equations (with latex)

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

chrisi99 wrote:

Code: Select all

 }
include("/var/www/virtual/lowping.at/stud/htdocs/latexrender/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
*
It looks as if phpbb_hook_2.php is not being found. It's difficult to know what your path in

Code: Select all

include("/var/www/virtual/lowping.at/stud/htdocs/latexrender/phpbb_hook_2.php");
should be but are you absolutely sure lowping.at is correct? Is that the user name?
chrisi99
Registered User
Posts: 52
Joined: Sat Oct 06, 2007 10:23 pm

Re: math equations (with latex)

Post by chrisi99 »

lowping.at is the domain name. Since it is a virtual host on Apache2 I name the vhosts like the domain.

The absolute path (from the machine root is)

/var/www/virtual/lowping.at/stud/htdocs/latexrender
chrisi99
Registered User
Posts: 52
Joined: Sat Oct 06, 2007 10:23 pm

Re: math equations (with latex)

Post by chrisi99 »

well that actually DID something:

i replaced the absolute path with a path relative to my /board/inlcude/bbcode.php and I am now getting some error msgs (this is the best thing so far though ;) )

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include(../../latexrender/phpbb_hook_2.php) [function.bbcode-include]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include() [function.include]: Failed opening '../../latexrender/phpbb_hook_2.php' for inclusion (include_path='.:/usr/share/php')
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include(../../latexrender/phpbb_hook_2.php) [function.bbcode-include]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include() [function.include]: Failed opening '../../latexrender/phpbb_hook_2.php' for inclusion (include_path='.:/usr/share/php')
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include(../../latexrender/phpbb_hook_2.php) [function.bbcode-include]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include() [function.include]: Failed opening '../../latexrender/phpbb_hook_2.php' for inclusion (include_path='.:/usr/share/php')
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include(../../latexrender/phpbb_hook_2.php) [function.bbcode-include]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include() [function.include]: Failed opening '../../latexrender/phpbb_hook_2.php' for inclusion (include_path='.:/usr/share/php')
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include(../../latexrender/phpbb_hook_2.php) [function.bbcode-include]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 101: bbcode::include() [function.include]: Failed opening '../../latexrender/phpbb_hook_2.php' for inclusion (include_path='.:/usr/share/php')
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4209: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3720)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4211: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3720)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4212: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3720)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4213: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3720)
 
seems the include_path is now pointing to a wrong directory .:/usr/share/php
chrisi99
Registered User
Posts: 52
Joined: Sat Oct 06, 2007 10:23 pm

Re: math equations (with latex)

Post by chrisi99 »

sry, seems as i cant edit my previous post, since it does not display in the edit window!

changed the path back, even restarted Apache... I just cant think of anything else.

Does this mean, that Latex wokrs:

Code: Select all

pdfeTeX using libpoppler 3.141592-1.21a-2.2 (Web2C 7.5.4)
kpathsea version 3.5.4
Copyright (C) 1997-2004 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea is copyright (C) 1997-2004 Free Software Foundation, Inc.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfeTeX using libpoppler copyright and
the GNU General Public License.
For more information about these matters, see the files
named COPYING and the pdfeTeX using libpoppler source.
Primary author of pdfeTeX using libpoppler: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea written by Karl Berry and others.
on the test.php

Ghostscript is also set up (apt-get install gs) as is imagemagick (apt-get install imagemagick)...

am I missing something? Or am I just too stupid? ;)
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

You will almost certainly need the absolute path.
At the beginning of phpbb_hook_2.php put something like
echo "Now in phpbb_hook_2.php<br />";
then that will tell you if the file is being used (it will cause all sorts of error messages about Cannot modify header information but they can be ignored - all they are saying is that they didn't expect a message to have already been shown).
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

If a tex file doesn't appear in /tmp and the [tex]...[/tex] tags are still there then phpbb_hook_2.php is not being processed so LaTeX etc are not being called.

One other thing, check that the paths in phpbb_hook_2.php are correct.
chrisi99
Registered User
Posts: 52
Joined: Sat Oct 06, 2007 10:23 pm

Re: math equations (with latex)

Post by chrisi99 »

the echo shows, so the script definately is being called (see image)

Image

the paths seem to work:

Code: Select all

 // adjust this to match your system configuration
    $latexrender_path = "/var/www/virtual/lowping.at/stud/htdocs/latexrender";
    $latexrender_path_http = "/latexrender";
with this all working, i have to expect the problem to be somewhere between the LateX-PS-Imagemagick triangle....

Dont you think so as well?

And again: Thank you so much for your patience! :)
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

If there is no tex file in /tmp (after commenting out unlink lines in class.latexender.php) then latex has not been run, since there is no file to run it on. So the fault is earlier on.
I wonder if this is it:
In phpbb_hook_2.php you added a couple of spaces so it didn't find any tags to replace:
You put

Code: Select all

preg_match_all("#\[tex:$bbcode_uid \](.*?)\[/tex:$bbcode_uid \]#si",$message,$tex_matches);
but it should be

Code: Select all

preg_match_all("#\[tex:$bbcode_uid\](.*?)\[/tex:$bbcode_uid\]#si",$message,$tex_matches);
You added the spaces after uid and before \] in 2 places.
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

I updated the previous post as I had got it the wrong way round. The problem was that you had added (not lost) 2 spaces that shouldn't have been there.
chrisi99
Registered User
Posts: 52
Joined: Sat Oct 06, 2007 10:23 pm

Re: math equations (with latex)

Post by chrisi99 »

I am proudly handing you over a virtual beer and congratulate you for solving my problem!

it all works now!

if I can help you (backlink to your site...) PLEASE pm me, I would be glad to do so!

best wishes
Christoph
User avatar
takufner
Registered User
Posts: 216
Joined: Mon Oct 23, 2006 10:39 am
Location: Rio de Janeiro - Brasil
Name: Prof. Caju
Contact:

Re: math equations (with latex)

Post by takufner »

Hi stevem,

I managed upgrading my forum from 2.0.2.2 to 3.0.0 with the 6000 messages in the old version.

In 2.0.2.2 I had mimetex working fine. And almost all my messages have some sort of equation using mimetex (with the BBCode [tex]).

In my new server I've successfully installed mimetex, it is working properly (the example file can show all the equations and produce the correct cache for those equations written in the example.php).

I've changed the things you instructed in this post (btw, for mimetex there are 8 changes for $text, not just 6).

Now I can use mimetex for my new posts, but without cache for equations in the forum. This is not my biggest problem.
My problem is with the legacy message. No one is showing the equations. The BBcode is not being converted for the old messages. But, if I edit any old message, after saving the equations are ok for this message.

Is there some way to reprocess all messages?

I am using phpBB3 3.0.0 Olympus on a Linux shared server.

Thanks in advance.
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

The code looks for an image in /pictures and if it's there it should show that image otherwise it will reprocess the image. I'm not sure why it isn't showing the images. A couple of things to try:
1. delete images in /pictures to force new ones to be made
and if that doesn't help
2. comment out the first three lines in phpbb_hook_2.php of

Code: Select all

if (is_file($full_path_filename)) {
  $url = $pictures_path_http."/".$filename;
} else {
  $command = "$mimetex_path -e ".$full_path_filename." ".escapeshellarg($mimetex_formula);
which will force new images to be created every time.
miguel-murcia
Registered User
Posts: 5
Joined: Wed Feb 01, 2006 9:33 am

Re: math equations (with latex)

Post by miguel-murcia »

Hi stevem from foro.fisimur.org . Sorry for my english, i'm spanish.

I have a little problem. I found your code on http://www.mayer.dial.pipex.com/tex.htm and i don't found the three lines above. My sistem is well since today when i have phpbb3 upgrade. I am delete all images of latexrender/image directory.

My problem is that some elements isn't rendering. For example [tex]\LaTeX[/tex] and [tex]\LaTeX{}[/tex] give a [unparseable or potentially dangerous latex formula] while [tex]resultado=\frac{Prueba}{Desarrollo}[/tex] or [tex]E=mc^2[/tex] don't give me problem. You can see it in http://foro.fisimur.org/viewtopic.php?p=7998#p7998. I use [tex]\LaTeX[/tex] before upgrade without problems.

i look that i can't write () in formulas, for example [tex]f(x)=3x[/tex] show this Image


My phpbb_hook_2.php is:

Code: Select all

// adjust this to match your system configuration
    $latexrender_path = "/home/fisimur/public_html/foro/latexrender";
    $latexrender_path_http = "/latexrender";

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

    preg_match_all("#\[tex:$bbcode_uid\](.*?)\[/tex:$bbcode_uid\]#si",$message,$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($message, $tex_matches[0][$i]);
        $latex_formula = html_entity_decode($tex_matches[1][$i]);

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

		$alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES);
		$alt_latex_formula = str_replace("\r","&#13;",$alt_latex_formula);
		$alt_latex_formula = str_replace("\n","&#10;",$alt_latex_formula);

        if ($url != false) {
            $message = substr_replace($message, "<img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."' align='absmiddle'>",$pos,strlen($tex_matches[0][$i]));
        } else {
            $message = substr_replace($message, "[unparseable or potentially dangerous latex formula]",$pos,strlen($tex_matches[0][$i]));
        }
    }
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

It looks like something is altering the text before LaTeX can get to it. Comment out using // the 6 lines at the end of class.latexrender.php starting with unlink. Then try [tex]\LaTeX[/tex] and there should be some files in /tmp with long names. Look at .tex and .log to see what has happened.

The problem with ( and ) is easily solved. In phpbb_hook_2.php after

Code: Select all

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

Code: Select all

$latex_formula = str_replace("&#040;","(",$latex_formula)
$latex_formula = str_replace("&#041;",")",$latex_formula)
You can add similar lines for any other symbols that get changed.
miguel-murcia
Registered User
Posts: 5
Joined: Wed Feb 01, 2006 9:33 am

Re: math equations (with latex)

Post by miguel-murcia »

Thank you for solved () problem the correct lines are without 0:

Code: Select all

$latex_formula = str_replace("&#40;","(",$latex_formula);
$latex_formula = str_replace("&#41;",")",$latex_formula);
The problem with \LaTeX can see in log file it, but i don't know how solved:

Code: Select all

Missing character: There is no L in font nullfont!
Missing character: There is no T in font nullfont!

! Font T1/cmr/m/n/7=ecrm0700 at 7.0pt not loadable: Metric (TFM) file not found
.
<to be read again> 
                   relax 
l.22 \begin{eqnarray*}\LaTeX
                             \end{eqnarray*}
I wasn't able to read the size data for this font,
so I will ignore the font specification.
[Wizards can fix TFM files using TFtoPL/PLtoTF.]
You might try inserting a different font spec;
e.g., type `I\font<same font id>=<substitute font name>'.

Missing character: There is no A in font nullfont!
Missing character: There is no T in font nullfont!
Missing character: There is no E in font nullfont!
Missing character: There is no X in font nullfont!
Missing character: There is no L in font nullfont!
Missing character: There is no T in font nullfont!
Missing character: There is no A in font nullfont!
Missing character: There is no T in font nullfont!
Missing character: There is no E in font nullfont!
Missing character: There is no X in font nullfont!
Missing character: There is no L in font nullfont!
Missing character: There is no T in font nullfont!
Post Reply

Return to “[2.0.x] MOD Requests”