News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

LATEX Parsing

Started by treo, June 18, 2004, 04:25:16 PM

Previous topic - Next topic

Avinash4

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.
McMaster University's Largest Online Community
http://mac-central.com
Powered by SMF and Mambo

Avinash4

#61
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

McMaster University's Largest Online Community
http://mac-central.com
Powered by SMF and Mambo

Avinash4

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?
McMaster University's Largest Online Community
http://mac-central.com
Powered by SMF and Mambo

jmbr

Hi,

I wrote a small patch to SMF 1.1 to add support for mimetex.  You can fetch it from hxxp:darcs.superadditive.com/smf-mimetex/smf-1.1-mimetex.diff [nonactive]
There's some more information about it at hxxp:blog.superadditive.com/2006/12/03/quick-way-to-use-mimetex-with-smf/ [nonactive]

thylow

What do I do with and ERROR 4.
It says I can't create a DVI File.

hxxp:homeworkdiscussion.com/latexrender/example.php [nonactive]

Here is my demo

scimmiotto

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.
Loop code example:
The following statement is FALSE
The previous statement is TRUE.

apcalculus

thank you Orstio for the instructions.

In the mimetex instructions there is one additional change that asks replacing some text (full instructions here hxxp:physweb.bgu.ac.il/DOWNLOADS/Mimetex/mimetex_phpbb/readme_SMF.txt [nonactive] )
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!

apcalculus


jaccione

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
www.math.net.au for all your math homework needs

AirBeagle1

Would love to know how you made it work...   Thanks! ;D

Advertisement: