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 »

mimeTeX gives an inferior qualty image and has less options because it emulates LaTeX - mathTeX is much better.
Le File wrote:Can Latexrender try in localhost?
I'm not sure what you mean in this context. LatexRender is just a PHP program so depends on PHP being installed. However, it requires LaTeX etc which are executables and these must be run as root programs. If you want to run LatexRender on your own private computer you can use LatexRender for Windows. This can be used to create images of mathematical expressions for uploading to wherever you want. It doesn't require PHP but does use MiKTeX, Ghostcsript and ImageMagick.
Le File
Registered User
Posts: 8
Joined: Sun Jun 08, 2008 1:57 pm

Re: math equations (with latex)

Post by Le File »

Can you explain to me, how to get math support in phpBB3 with mimetex? Because i don't understand the tutorial in readme.txt. I can't compile mimetex.c, mimetex.h, etc to mimetex.cgi. Can you give me the file? (mimetex.cgi for windows and linux) Thanx....
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

Since you are using Windows why not download the precompiled binary mimetex.exe at MimeTeX Precompiled BInaries...?
Le File
Registered User
Posts: 8
Joined: Sun Jun 08, 2008 1:57 pm

Re: math equations (with latex)

Post by Le File »

Wow, i use MIMETEX and it's really work in my local computer but i have some question (again)
1. How to convert mimetex.cgi ti CHMOD 755?
2. How to change BBCode from [tex]{bla-bla-bla}[/tex] to $${bla-bla-bla}$$ or %%{bla-bla-bla}%%, etc (i use mimetex not latexrender)? Thanx again....
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

Le File wrote:1. How to convert mimetex.cgi ti CHMOD 755?
You said your server runs Windows so why would you want to do something that is only relevant to a Linux/Unix system?
Le File wrote:2. How to change BBCode from [tex]{bla-bla-bla}[/tex] to $${bla-bla-bla}$$ or %%{bla-bla-bla}%%, etc (i use mimetex not latexrender)?
Just replace $$...$$ or %%...%% by [tex]...[/tex]. Have look on the phpBB forum for more on BBcode tags for the detail on doing this.
Le File
Registered User
Posts: 8
Joined: Sun Jun 08, 2008 1:57 pm

Re: math equations (with latex)

Post by Le File »

@stevem : Thx for your explanation. But one last important thing, I saw some site using '$ formula $' instead of '[tex] formula [/tex]'. Can I use '$ ~ $' in my website using mimetex? I use phpBB2.0.x. I've tried to change

Code: Select all

#--------[open]-----------------------------------------------------
     /includes/bbcode.php
   #--------[find]-----------------------------------------------------
     // Remove our padding from the string..
   #--------[before, add]----------------------------------------------
     $text = preg_replace('/\[tex\](.*?)\[\/tex\]/ie',
     "'<img src=\"/cgi-bin/mimetex.cgi?'.rawurlencode('$1').'\" align=\"middle\" />'",
     $text);
to

Code: Select all

#--------[open]-----------------------------------------------------
     /includes/bbcode.php
   #--------[find]-----------------------------------------------------
     // Remove our padding from the string..
   #--------[before, add]----------------------------------------------
     $text = preg_replace('/\$(.*?)\$/ie',
     "'<img src=\"/cgi-bin/mimetex.cgi?'.rawurlencode('$1').'\" align=\"middle\" />'",
     $text);
But it can't work. Thanx for your explanation
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

You've changed things as you said you wanted to use phpBB3 and $$...$$. But I have the instructions for using $...$ on phpBB2. They are perhaps a bit long for posting here so PM me with an email address and I will send them to you.

The files are for LatexRender but you can easily adapt them to use with mimetex.
Le File
Registered User
Posts: 8
Joined: Sun Jun 08, 2008 1:57 pm

Re: math equations (with latex)

Post by Le File »

Man...... it really work for my forum.... Thanks Steve Mayer (i just realized that is you :shock: )
trashbox
Registered User
Posts: 53
Joined: Wed Aug 22, 2007 9:25 pm

Re: math equations (with latex)

Post by trashbox »

Hello stevem.

When I put this in my post:

Code: Select all

[tex]f'(x)=?[/tex]
I get this in preview, on mouse over:

Code: Select all

f'(x)=?
And in the message it appears:

Code: Select all

f39;(x)=?

Please, how can I handle this red symbol f'(x), instead of using \prime?
Thanks in advance for your attention!
Equipe AjudaMatemática.com
Exercícios, plantão de dúvidas, desafios, problemas curiosos e repositório de materiais IME-USP do curso de licenciatura em Matemática!
Writing mathematical symbols with LaTeX and BBCode (just a bridge):
http://www.ajudamatematica.com/viewtopi ... p=177#p177
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

Sometimes characters are replaced by their code before it gets to LatexRender so LaTeX doesn't get the right information. But it's easily cured.

In phpbb_hook_2.php after the line

Code: Select all

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

Code: Select all

$latex_formula = str_replace("'","'",$latex_formula);
In the middle of that is a double quote, followed by a single quote, followed by a double quote.

You can use a similar line for any other characters that come out peculiarly such as &.
trashbox
Registered User
Posts: 53
Joined: Wed Aug 22, 2007 9:25 pm

Re: math equations (with latex)

Post by trashbox »

stevem, thank you again, it worked!
Equipe AjudaMatemática.com
Exercícios, plantão de dúvidas, desafios, problemas curiosos e repositório de materiais IME-USP do curso de licenciatura em Matemática!
Writing mathematical symbols with LaTeX and BBCode (just a bridge):
http://www.ajudamatematica.com/viewtopi ... p=177#p177
trashbox
Registered User
Posts: 53
Joined: Wed Aug 22, 2007 9:25 pm

Re: math equations (with latex)

Post by trashbox »

Hello Stevem.
Everything was working fine in my remote server, but suddenly, it shows this message just to new formulas, not to that that we already have the png image file created:

Code: Select all

[phpBB Debug] PHP Notice: in file /class.latexrender.php on line 305: copy(1c1a1ba95f06b364f28e62929fcbbdea.png) [function.copy]: failed to open stream: No such file or directory
[Unparseable or potentially dangerous latex formula. Error 6 ]
I have already comment that 6 unlink lines in class.latexrender.php to see in my tmp directory which files was been created, they are:
.tex
.log
.dvi
.aux

I thing this is some server problem with paths, I don't know, but I haven't changed anything and it was working.
Please, what can I check next?

Thanks!
Equipe AjudaMatemática.com
Exercícios, plantão de dúvidas, desafios, problemas curiosos e repositório de materiais IME-USP do curso de licenciatura em Matemática!
Writing mathematical symbols with LaTeX and BBCode (just a bridge):
http://www.ajudamatematica.com/viewtopi ... p=177#p177
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

As there is no ps file the problem could be with dvips. Check that dvips is still at /usr/bin. Also check the other files to see if they are correct - has the tex file got the correct content, is the log file showing any errors and does the dvi file show the correct formula?
trashbox
Registered User
Posts: 53
Joined: Wed Aug 22, 2007 9:25 pm

Re: math equations (with latex)

Post by trashbox »

Stevem, I'm testing with a new formula: [tex]x^{123}[/tex].

This is the tex file content:

Code: Select all

\documentclass[12pt]{article}
\usepackage[portuges]{babel}
\usepackage[latin1]{inputenc}
\usepackage[normalem]{ulem}
\usepackage{cancel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\pagestyle{empty}
\begin{document}
$\displaystyle x^{123}$
\end{document}
This is the log file:

Code: Select all

This is TeX, Version 3.14159 (Web2C 7.4.5) (format=latex 2006.1.19)  1 JUL 2008 19:42
**cf4be939105df52c7edb85ed026c72fd.tex
(./cf4be939105df52c7edb85ed026c72fd.tex
LaTeX2e <2001/06/01>
Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, n
ohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size12.clo
File: size12.clo 2001/04/21 v1.4e Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texmf/tex/generic/babel/babel.sty
Package: babel 2001/03/01 v3.7h The Babel package

(/usr/share/texmf/tex/generic/babel/portuges.ldf
Language: portuges 2001/02/16 v1.2o Portuguese support from the babel system

(/usr/share/texmf/tex/generic/babel/babel.def
File: babel.def 2001/03/01 v3.7h Babel common definitions
\babel@savecnt=\count87
\U@D=\dimen103
)

Package babel Warning: No hyphenation patterns were loaded for
(babel)                the language `Portuguese'
(babel)                I will use the patterns loaded for \language=0 instead.

\l@portuges = a dialect from \language0
Package babel Info: Making " an active character on input line 126.
)) (/usr/share/texmf/tex/latex/base/inputenc.sty
Package: inputenc 2001/07/10 v0.99a Input encoding file 

(/usr/share/texmf/tex/latex/base/latin1.def
File: latin1.def 2001/07/10 v0.99a Input encoding file 
))
(/usr/share/texmf/tex/latex/misc/ulem.sty
\UL@box=\box26
\UL@hyphenbox=\box27
\UL@skip=\skip43
\UL@hook=\toks14
\UL@pe=\count88
\UL@pixel=\dimen104
\ULC@box=\box28
Package: ulem 2000/05/26
\ULdepth=\dimen105
)
(/usr/share/texmf/tex/latex/misc/cancel.sty
Package: cancel 2000/03/12 v2.1 Cancel math terms
)
(/usr/share/texmf/tex/latex/amsmath/amsmath.sty
Package: amsmath 2000/07/18 v2.13 AMS math features
\@mathmargin=\skip44

For additional information on amsmath, use the `?' option.
(/usr/share/texmf/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01

(/usr/share/texmf/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0
\@emptytoks=\toks15
\ex@=\dimen106
))
(/usr/share/texmf/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d
\pmbraise@=\dimen107
)
(/usr/share/texmf/tex/latex/amsmath/amsopn.sty
Package: amsopn 1999/12/14 v2.01 operator names
)
\inf@bad=\count89
LaTeX Info: Redefining \frac on input line 211.
\uproot@=\count90
\leftroot@=\count91
LaTeX Info: Redefining \overline on input line 307.
\classnum@=\count92
\DOTSCASE@=\count93
LaTeX Info: Redefining \ldots on input line 379.
LaTeX Info: Redefining \dots on input line 382.
LaTeX Info: Redefining \cdots on input line 467.
\Mathstrutbox@=\box29
\strutbox@=\box30
\big@size=\dimen108
LaTeX Font Info:    Redeclaring font encoding OML on input line 567.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 568.
\macc@depth=\count94
\c@MaxMatrixCols=\count95
\dotsspace@=\muskip10
\c@parentequation=\count96
\dspbrk@lvl=\count97
\tag@help=\toks16
\row@=\count98
\column@=\count99
\maxfields@=\count100
\andhelp@=\toks17
\eqnshift@=\dimen109
\alignsep@=\dimen110
\tagshift@=\dimen111
\tagwidth@=\dimen112
\totwidth@=\dimen113
\lineht@=\dimen114
\@envbody=\toks18
\multlinegap=\skip45
\multlinetaggap=\skip46
\mathdisplay@stack=\toks19
LaTeX Info: Redefining \[ on input line 2666.
LaTeX Info: Redefining \] on input line 2667.
)
(/usr/share/texmf/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2001/10/25 v2.2f
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 132.
)
(/usr/share/texmf/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2002/01/22 v2.2d
)
No file cf4be939105df52c7edb85ed026c72fd.aux.
\openout1 = `cf4be939105df52c7edb85ed026c72fd.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 10.
LaTeX Font Info:    ... okay on input line 10.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 10.
LaTeX Font Info:    ... okay on input line 10.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 10.
LaTeX Font Info:    ... okay on input line 10.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 10.
LaTeX Font Info:    ... okay on input line 10.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 10.
LaTeX Font Info:    ... okay on input line 10.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 10.
LaTeX Font Info:    ... okay on input line 10.
LaTeX Font Info:    Try loading font information for U+msa on input line 11.
(/usr/share/texmf/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2002/01/19 v2.2g AMS font definitions
)
LaTeX Font Info:    Try loading font information for U+msb on input line 11.

(/usr/share/texmf/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2002/01/19 v2.2g AMS font definitions
) [1

]
(./cf4be939105df52c7edb85ed026c72fd.aux) ) 
Here is how much of TeX's memory you used:
 1549 strings out of 95847
 17189 string characters out of 1194789
 66430 words of memory out of 1000001
 4495 multiletter control sequences out of 10000+50000
 8400 words of font info for 33 fonts, out of 500000 for 1000
 14 hyphenation exceptions out of 1000
 27i,4n,24p,249b,165s stack positions out of 1500i,500n,5000p,200000b,5000s

Output written on cf4be939105df52c7edb85ed026c72fd.dvi (1 page, 256 bytes).

I have saved the dvi file to my computer and it's showing correctly!

This is the aux file:

Code: Select all

\relax 
\catcode`"\active
\select@language{portuges}
\@writefile{toc}{\select@language{portuges}}
\@writefile{lof}{\select@language{portuges}}
\@writefile{lot}{\select@language{portuges}}

I have checked the path and the dvips is there /usr/bin.
Equipe AjudaMatemática.com
Exercícios, plantão de dúvidas, desafios, problemas curiosos e repositório de materiais IME-USP do curso de licenciatura em Matemática!
Writing mathematical symbols with LaTeX and BBCode (just a bridge):
http://www.ajudamatematica.com/viewtopi ... p=177#p177
stevem
Registered User
Posts: 398
Joined: Sun Aug 25, 2002 1:59 pm

Re: math equations (with latex)

Post by stevem »

We need more information before deciding what has gone wrong. In class.latexrender.php where it says

Code: Select all

        // convert dvi file to postscript using dvips
        $command = $this->_dvips_path." -E ".$this->_tmp_filename.".dvi"." -o ".$this->_tmp_filename.".ps";
        $status_code = exec($command);
temporarily change

Code: Select all

 $status_code = exec($command);
to

Code: Select all

echo "About to run $command <br>";
exec("$command 2>&1", $output);

foreach($output as $outputline){
   echo("$outputline<br>");
}
Ignore the fact that PHP gets upset about headers and see what information you get.
I haven't tested the code but the first line should tell you what is running and the rest should give the same feedback you get from the command line.
Post Reply

Return to “[2.0.x] MOD Requests”