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.
maurorodas
Registered User
Posts: 10
Joined: Thu Feb 15, 2007 2:02 pm
Location: Manizales/Colombia
Contact:

Post by maurorodas »

in bbcode.php has this

Code: Select all

	// [i] and [/i] for italicizing text.
	$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
	$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);

	// Patterns and replacements for URL and email tags..
	$patterns = array();
	$replacements = array();
        include("/home/www/alkimiya.awardspace.com/forum/mimetex/phpbb_hook_2.php");

	// [img]image_url_here[/img] code..
	// This one gets first-passed..
	$patterns[] = "#\[img:$uid\]([^?](?:[^\[]+|\[(?!url))*?)\[/img:$uid\]#i";
	$replacements[] = $bbcode_tpl['img'];
        include("/home/www/alkimiya.awardspace.com/forum/mimetex/phpbb_hook_1.php");
:?: :?:

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

Post by stevem »

I have downloaded a copy of bbcode.php for 2.0.22 to check. It looks like you have phpbb_hook_2.php in the right place but phpbb_hook_1.php should go after line 286 so you get:

Code: Select all

// [img]image_url_here[/img] code..
$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

include("/home/www/alkimiya.awardspace.com/forum/mimetex/phpbb_hook_1.php");

// Remove our padding from the string..
return substr($text, 1);;

maurorodas
Registered User
Posts: 10
Joined: Thu Feb 15, 2007 2:02 pm
Location: Manizales/Colombia
Contact:

Post by maurorodas »

:oops: , I have already corrected it, apparently every time I am more near the solution, but the equation doesn't still appear, now only it leaves

Code: Select all

x^2
:( :(

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

Post by stevem »

Can you give me the HTML source of the post - or, better still, direct me to the posting?

maurorodas
Registered User
Posts: 10
Joined: Thu Feb 15, 2007 2:02 pm
Location: Manizales/Colombia
Contact:

Post by maurorodas »

I have created you user's bill so that you can enter, looks at your private messages

maurorodas
Registered User
Posts: 10
Joined: Thu Feb 15, 2007 2:02 pm
Location: Manizales/Colombia
Contact:

Post by maurorodas »

Stevem, excuseme to bother you so much, but it doesn't still work

this is the path

Code: Select all

		// --------------------------------------------------------------------------------------------------
		// adjust this to match your system configuration
		$mimetex_path = "/home/www/alkimiya.awardspace.com/mimetex/cgi-bin/mimetex.cgi"; 
		$mimetex_path_http = "http://alkimiya.awardspace.com/forum/mimetex";
		$mimetex_cgi_path_http="http://alkimiya.awardspace.com/forum/mimetex/cgi-bin/mimetex.cgi";
		$pictures_path = "/home/www/alkimiya.awardspace.com/forum/mimetex/pictures";
		// --------------------------------------------------------------------------------------------------
looks at the one post

http://alkimiya.awardspace.com/forum/vi ... hp?p=77#77

will it be that the problem is in the AdvanceBBcode box?

thanks

yll
Registered User
Posts: 14
Joined: Thu Jun 05, 2003 6:41 am

Post by yll »

LatexRender use ImageMagick
http://www.mayer.dial.pipex.com/tex.htm
Can someone change the code to use GD ???

Thx... :D

yll
Registered User
Posts: 14
Joined: Thu Jun 05, 2003 6:41 am

Post by yll »

yll wrote: LatexRender use ImageMagick
http://www.mayer.dial.pipex.com/tex.htm
Can someone change the code to use GD ???

Thx... :D


Can someone help?
Thank u very much...

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

Post by stevem »

I am not an expert in GD but I doubt that it can be done. You need Ghostscript (used behind the scenes by ImageMagick) to convert from ps to gif/png and then ImageMagick to crop the image. As far as I am aware GD cannot convert postscript files which is rather specialised - Ghostscript is one of the few programs that specialises in this.

gemath
Registered User
Posts: 2
Joined: Sun May 20, 2007 8:31 am

Re: math equations (with latex)

Post by gemath »

Hi all members, I am a new memeber I have installed a phpbb forum I want to setup latex for it I download latexrender and I do as readme.txt in that file but I am not still successful the many problems in this file I don't understand
It said

Code: Select all

# Adjust the paths in phpbb_hook_2.php in the 2 lines:
#    $latexrender_path = "/home/domain_name/public_html/phpbb/latexrender";
#    $latexrender_path_http = "/phpbb/latexrender";

# Adjust the paths in class.latexrender.php, if necessary, to point to the latex, dvips and ImageMagick executables
#    var $_latex_path = "/usr/bin/latex";
#    var $_dvips_path = "/usr/bin/dvips";
#    var $_convert_path = "/usr/bin/convert";
#    var $_identify_path="/usr/bin/identify";
# For Windows the paths in class.latexrender.php must use \\ or / not just a single \ 
# For example
#    var $_latex_path = "C:\\texmf\\miktex\\bin\\latex.exe";
# or 
#    var $_latex_path = "C:/texmf/miktex/bin/latex.exe";
I had miktex in my computer but it has latex.exe and dvips.exe but there isn'r any convert and indentify ??

It said

Code: Select all

#-----[ FIND ]---------------------------------------------
# around line 195
// Patterns and replacements for URL and email tags..
$patterns = array();
$replacements = array();

# 
#-----[ AFTER, ADD ]-------------------------------------- 
# 
## replace the path below with your path	
include("/home/domain_name/public_html/phpbb/latexrender/phpbb_hook_2.php");

#
#-----[ FIND ]---------------------------------------------
# around line 288
// [img]image_url_here[/img] code..
$text = preg_replace("#\[img\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

# 
#-----[ AFTER, ADD ]-------------------------------------- 
# 
## replace the path below with your path	
include("/home/domain_name/public_html/phpbb/latexrender/phpbb_hook_1.php");
Does it mean find that code and add the code after??

Code: Select all

include("/home/domain_name/public_html/phpbb/latexrender/phpbb_hook_1.php");
I understand we have change domain_name by my domain but what's "home"
Hope you are help me please thank you very much and best regards

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

Re: math equations (with latex)

Post by stevem »

As the readme.txt says you must install ImageMagick which itself requires Ghostscript . When you have installed both programs you will find convert and identify. Many servers use Linux but if you are using Windows then the programs will be called convert.exe and identify.exe.

A path like home/domain_name/public_html/phpbb/latexrender/phpbb_hook_1.php is used in Linux, so again if you have Windows on your server then use the correct path to where phpbb_hook_1.php is installed - for example, C:/phpbb/latexrender/phpbb_hook_1.php. Note that you must use / or \\ for paths not \ as Windows usually uses.

gemath
Registered User
Posts: 2
Joined: Sun May 20, 2007 8:31 am

Re: math equations (with latex)

Post by gemath »

Thank you very much for your reply stevem , but what do you mean server ? I only unse PC an upload my forum from my PC? I only download the file latexrender.zip an unzip it in the folder, you mean I must use path from my folder on my computer?
Thank you and best regards.

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

Re: math equations (with latex)

Post by stevem »

Are you saying that you are using your computer as a server? By server I mean the computer that shows the website that others can see. So for example this forum is hosted on a server somewhere and the pages appear as a website. Normally you upload the pages from your computer to the server so everyone can see it. Then you use the paths on the server that you upload to.

But if the website with the forum is actually on your computer (which is unusual) then your computer is a server. In that case you will need to use the paths on your computer.

technology
Registered User
Posts: 3
Joined: Sat Jul 07, 2007 6:50 pm

Re: math equations (with latex)

Post by technology »

please help me
my forum is version phpbb 2.0.22
I'm using latexrender for my forum
now, I want to replace [tex][/tex] to $ $ (dollar sign)
I try much times, but not worked.
I don't understand, forum Mathlinks.ro, they could this problem.
They are using latexrender, using it at the same time: [tex]...[/tex], $...$ and \[ ...\].
Who can help me? I'am needing !! :cry:

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

Re: math equations (with latex)

Post by stevem »

mathlinks.ro is heavily customised but they started with the following. There are bound to be undesirable side-effects (like problems with the code tag) which mathlinks.ro will have coded around. What I'm saying is that phpBB is built round the assumption that tags use [...] and [/...] so you need PHP coding expertise to deal with any problems. You may also need to update the code to cope with version 2.0.22. There are no guarantees offered.

Having said that, this is the code that allowed use of $..$ and \[..\]

Code: Select all

####################################################################################### 
## This will allow you to input latex code using $ and $$ as is used in LaTeX documents
## as featured on http://mathlinks.ro
## [tex] formula [/tex] can still be used
## 
## As configured this will give
## [tex] formula [/tex] uses \displaystyle but is not centred
## $ formula $ = inline text
## $$ formula $$ and \[ formula \] both give displayed mathematics which is centred 
## 
## IMPORTANT NOTES
## 1. phpBB expects to use [ ] for tags so using this method can give
##    unexpected results, though it has been tested. Please monitor its use
## 2. Users MUST be warned NOT to use $ in ordinary text as it will give unexpected results
## 3. As $$ formula $$ and \[ formula \] give identical results 
##    $$ formula $$ is converted to \[ formula \] when editing and quoting
## 
## The following code changes assume that you have installed the MOD as in README_phpBB.txt
## Replace phpbb_hook_1.php and phpbb_hook_2.php by the files in this folder

# 
#-----[ OPEN ]--------------------------------------------- 
# 
includes/bbcode.php

#
#-----[ FIND ]---------------------------------------------
#
if (! (strpos($text, "[") && strpos($text, "]")) )

# 
#-----[ REPLACE WITH ]---------------------------------------
#
if (! (strpos($text, "[") && strpos($text, "]")) && ! (strpos($text, "$")) )

#
#-----[ FIND ]---------------------------------------------
#
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#'');
$code_entities_replace = array('<', '>', '"', '&#58;', '&#91;', '&#93;', '&#40;', '&#41;', '&#123;', '&#125;');

# 
#-----[ REPLACE WITH ]---------------------------------------
#
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#', '#\$#');
$code_entities_replace = array('<', '>', '"', '&#58;', '&#91;', '&#93;', '&#40;', '&#41;', '&#123;', '&#125;', '&#36;');

# 
#-----[ OPEN ]--------------------------------------------- 
# 
search.php

#
#-----[ FIND ]---------------------------------------------
#
      $message = strip_tags($message);

# 
#-----[ AFTER, ADD ]-------------------------------------- 
# 
      $message = str_replace("\$:$bbcode_uid",'',$message);
      $message = str_replace("\[:$bbcode_uid",'',$message);
      $message = str_replace("\]:$bbcode_uid",'',$message);

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 

# EoM
phpbb_hook_1.php

Code: Select all

<?php
/**
 * LaTeX Rendering Class - PHPBB Hook
 * Copyright (C) 2003  Benjamin Zeiss <zeiss@math.uni-goettingen.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * --------------------------------------------------------------------
 * @author Benjamin Zeiss <zeiss@math.uni-goettingen.de>
 * @version v0.8
 * @package latexrender
 *
 */

    $text = preg_replace("#\[tex\](.*?)\[/tex\]#si", "[tex:$uid]\\1[/tex:$uid]", $text);
	$text = str_replace("\\\$","dollar:$uid",$text);
	$text = preg_replace("#\\\\\[(.*?)\\\\\]#si", "\\\\\[:$uid\\1\\\\\]:$uid", $text);
	$text = preg_replace("#\\\$\\\$(.*?)\\\$\\\$#si", "\\\\\[:$uid\\1\\\\\]:$uid", $text);
	$text = preg_replace("#\\\$(.*?)\\\$#si", "\\\$:$uid\\1\\\$:$uid", $text);
	$text = str_replace("dollar:$uid","\\\$",$text);

?>
phpbb_hook_2.php

Code: Select all

<?php
/**
 * LaTeX Rendering Class - PHPBB Hook
 * Copyright (C) 2003  Benjamin Zeiss <zeiss@math.uni-goettingen.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * --------------------------------------------------------------------
 * @author Benjamin Zeiss <zeiss@math.uni-goettingen.de>
 * @version v0.8
 * @package latexrender
 *
 */
    // --------------------------------------------------------------------------------------------------
    // adjust this to match your system configuration
    $latexrender_path = "/var/www/phpbb/latexrender";
    $latexrender_path_http = "/phpbb/latexrender";

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

    preg_match_all("#\[tex:$uid\](.*?)\[/tex:$uid\]#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]);
        $alt_latex_formula=$tex_matches[1][$i];;
        $latex_formula = "\displaystyle ".$tex_matches[1][$i];

		$alt_latex_formula = htmlentities($alt_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 (trim($latex_formula)=="") {
			$url=false;
		} else {
	    	$url = $latex->getFormulaURL($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]",$pos,strlen($tex_matches[0][$i]));
        }
    }

    preg_match_all("#\\\$:$uid(.*?)\\\$:$uid#si",$text,$tex_matches2);

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

		$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 (trim($latex_formula)=="") {
			$url=false;
		} else {
	    	$url = $latex->getFormulaURL($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_matches2[0][$i]));
        } else {
            $text = substr_replace($text, "[unparseable or potentially dangerous latex formula]",$pos,strlen($tex_matches2[0][$i]));
        }
    }

    preg_match_all("#\\\\\[:$uid(.*?)\\\\\]:$uid#si",$text,$tex_matches3);

    for ($i=0; $i < count($tex_matches3[0]); $i++) {
        $pos = strpos($text, $tex_matches3[0][$i]);
        $alt_latex_formula=$tex_matches3[1][$i];;
        $latex_formula = "\displaystyle".$tex_matches3[1][$i];

		$alt_latex_formula = htmlentities($alt_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 (trim($latex_formula)=="") {
			$url=false;
		} else {
	    	$url = $latex->getFormulaURL($latex_formula);
		}

        if ($url != false) {
            $text = substr_replace($text, "<center><img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."' align='absmiddle'></center>",$pos,strlen($tex_matches3[0][$i]));
        } else {
            $text = substr_replace($text, "[unparseable or potentially dangerous latex formula]",$pos,strlen($tex_matches3[0][$i]));
        }
    }
?>

Post Reply

Return to “[2.0.x] MOD Requests”