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.
Post Reply
atheb
Registered User
Posts: 3
Joined: Sun Apr 20, 2003 2:06 pm
Contact:

math equations (with latex)

Post by atheb » Sun Apr 20, 2003 2:45 pm

For scientific discussions it's would be really useful to write short equations using latex code inside a message, and have them converted to pics (preferably gifs).

Surely latex is not the usual thing to run on a server, but why not ;)

Unfortunately I'm not optimistic that I'll succeed with that myself.
So perhaps someone here likes the idea.

Andy

atheb
Registered User
Posts: 3
Joined: Sun Apr 20, 2003 2:06 pm
Contact:

Post by atheb » Tue Apr 22, 2003 7:14 pm

Ok, I've found the right software and managed to use it through php 8)

So the next thing to do is to write the MOD.
But I get really confused reading the descriptions. :? The only thing I understood is, that this MOD should add another "BBCode" . I've already installed the Multi-bbc.
If someone writes the basics (mainly making a [eq] tag available) and tells me where my code goes, I'll be very thankful :)

Andy

User avatar
Dzien Dobry
Registered User
Posts: 595
Joined: Thu Nov 08, 2001 3:55 pm

LaTeX mathematical typesetting for phpBB

Post by Dzien Dobry » Thu Nov 20, 2003 4:19 am

I see that vBulletin has the capability of LaTeX mathematical typesetting. Click here for an example. I would love to be able to add this feature to my phpBB.

What is the current status, if any, on this wonderful development?

atheb
Registered User
Posts: 3
Joined: Sun Apr 20, 2003 2:06 pm
Contact:

Post by atheb » Thu Nov 20, 2003 8:06 pm

hm, I actually did succeed in manipulating phpBB 2.0.4 to support latex typesetting.
I used a mod available from
http://www.kellnerweg.de/~bzeiss/releas ... _05.tar.gz
but it didn't work. So I hacked the code to make it work on my computer.
There is a little program called gladtex that converts a latex equation to gif
http://www.math.uio.no/~martingu/gladtex/
This also needed modification to make it work with phpBB.

If I had time I would continue development, but my physics studies kind of prohibit this :(

If you want to continue the development I could give you the whole directory and let you find the (uncommented) changes, that I don't remember myself ;)

Andy

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

Post by stevem » Sat Jan 10, 2004 8:28 pm

I have also managed to get http://www.kellnerweg.de/~bzeiss/releas ... _05.tar.gz to work on phpBB 2.0.1

If it helps here are the changes I made to both the download and phpBB files.

Firstly, latexrender
I created a tmp file inside the latexrender folder and pointed to it in class.latexrender.php with
Change

Code: Select all

var $_tmp_dir = "/tmp"; // without ending slash !
To

Code: Select all

var $_tmp_dir = "/full_path_goes_here/latexrender/tmp"; 
It is important to chmod 777 for both pictures and this new tmp directory

Unless you have lpr installed, dvips won't produce the required .ps file so to get round this you need to tell dvips the name of the output file
class.latexrender.php
Change

Code: Select all

        $command = $this->_dvips_path." -E ".$this->_tmp_filename.".dvi";
To

Code: Select all

        $command = $this->_dvips_path." -E ".$this->_tmp_filename.".dvi"." -o ".$this->_tmp_filename.".ps";
There can be problems with transparency as ImageMagick sometimes ignores the -transparent command. If you don't want the background to be white then throughout class.latexrender.php change all .png to .gif and they will be transparent

I find that the mathematical text looks too large compared with the surrounding text as it is in 12pt. It can be reduced to 10pt which looks much better:
class.latexrender.php
Change

Code: Select all

$string  = "\documentclass[12pt]{article}\n";
to

Code: Select all

$string  = "\documentclass[10pt]{article}\n";
Secondly, phpBB files
Add a TeX button which will add the [tex] and [/tex] tags
posting_body.tpl
Add

Code: Select all

,'[tex]','[/tex]'
to the end of the bbtags array to get

Code: Select all

bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','
',
'
  • ','
','
  • ',
','[img]','[/img]','','','[tex]','[/tex]');[/code]
though you may also have other buttons

To make the posting box look better you may wish to change the width of the textboxes from

Code: Select all

width:450px
to

Code: Select all

width:500px
At the end of the section starting with

Code: Select all

<input type="button" class="button" accesskey="b" name="addbbcode0" value=" B " 
style="font-weight:bold; width: 30px" onClick="bbstyle(0)" onMouseOver="helpline('b')" />
Add

Code: Select all

<td><span class="genmed"> 
<input type="button" class="button" accesskey="x" name="addbbcode18" value="TeX" 
style="width: 40px"  onClick="bbstyle(18)" onMouseOver="helpline('x')" />
</span></td>
replacing 18 (twice) with an even number 2 more than the number in the previous lines. Change x (in accesskey="x") if you already have this letter for other buttons

lang_main.php
After

Code: Select all

$lang['bbcode_f_help'] = 'Font size: [size=x-small]small text[/size]';
Add

Code: Select all

$lang['bbcode_x_help'] = 'Formula: [tex]formula[/tex]  (alt+x)';
posting.php

After

Code: Select all

'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
Add

Code: Select all

'L_BBCODE_X_HELP' => $lang['bbcode_x_help'],
If you want (Windows) users to use a WYSIWYG for writing the LaTeX code then Lotus Word Pro produces excellent TeX (just remove $) or use TeXaide from Design Science and remove \[ and \]

Optional additional changes:
1. Still think the text looks too big? You can reduce it to 8pt if you (or your host) install the extsizes package available from CTAN. Add these files to a new extsizes directory in usr/share/texmf/tex/latex. Refresh the database using texhash command assuming you are using tetex.
Finally, in class.latexrender.php change

Code: Select all

$string  = "\documentclass[10pt]{article}\n";
to

Code: Select all

$string  = "\documentclass[8pt]{extarticle}\n";
2. In IE the images with the mathematical text sits above the line which looks odd. You can improve the alignment in by changing the code in phpbb_hook_2.php from

Code: Select all

$text = substr_replace($text, "<img src='".$url."'>",$pos,strlen($tex_matches[0][$i]));
to

Code: Select all

$text = substr_replace($text, "<img src='".$url."' align=absmiddle>",$pos,strlen($tex_matches[0][$i]));
Last edited by stevem on Tue Jan 20, 2004 4:31 pm, edited 3 times in total.

Valentiner
Registered User
Posts: 27
Joined: Wed Sep 03, 2003 8:44 pm

Post by Valentiner » Mon Jan 19, 2004 1:14 pm

okay. so how exactly (that is step by step) one can have latex on his phpBB2 forum?!!

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

Post by stevem » Mon Jan 19, 2004 2:27 pm

The author of latexrender is sceptical about whether the system will work with Windows so the instructions tend to be for Linux systems.

1. Latex
You may need to ask your host for help with this, but you need latex to be installed on your system. tetex is a common such package - have a look in /usr/bin for latex and dvips

You also need ImageMagick - look for /usr/bin/convert and /usr/bin/identify

2. Latexrender
Download http://www.kellnerweg.de/~bzeiss/releas ... _05.tar.gz and follow the instructions in the supplied README file for where to upload the files and the small number of changes you need to make to latexrender files and to phpBB's bbcode.php file.

3. My changes
Now make the changes I have suggested above.

You should now have a latex system that works - if not, I'm sure help will be available here.
Last edited by stevem on Tue Jan 20, 2004 4:29 pm, edited 2 times in total.

Valentiner
Registered User
Posts: 27
Joined: Wed Sep 03, 2003 8:44 pm

Post by Valentiner » Mon Jan 19, 2004 8:37 pm

I run a phpBB2.0.6c and I plan to keep it that way :D I asked the host and he said that he won't install tetex for some security measures, so I guess I have to find myself another host :D:D

bnz
Registered User
Posts: 3
Joined: Thu Feb 06, 2003 10:47 pm

Post by bnz » Sun Jan 25, 2004 3:33 pm

i have updated the modification to include steve's additions.

http://www.kellnerweg.de/~bzeiss/releas ... _06.tar.gz

Valentiner
Registered User
Posts: 27
Joined: Wed Sep 03, 2003 8:44 pm

Post by Valentiner » Mon Jan 26, 2004 2:30 pm

cool tomorrow mornin' I'm givin' it a shot and see how it works out. If i run in any trouble here's the first place I'm gonna post :D thanks guys!

Valentiner
Registered User
Posts: 27
Joined: Wed Sep 03, 2003 8:44 pm

Post by Valentiner » Mon Jan 26, 2004 2:33 pm

just a quick question. is it possible to use the latex tags $ bblabla $ for inline equations and $$ bla bla $$ or \[ bla bla \] for normal equations instead of [tex] and [/tex] ?!!

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

Post by stevem » Mon Jan 26, 2004 4:51 pm

It's important to fit in with phpBB methods which is to use bbcode in the form [tag]...[/tag] then the tags will be dealt with correctly.
Latexrender is set up to use [tex]...[/tex] but it is easy to change these in phpbb_hook_1.php and phpbb_hook_2.php to say [$] and [/$] if you wish.

However, you can't use $ ...$ because there would be no way to distinguish them from ordinary use of $ for a currency.
Since you can use the Tex button or Alt-X shortcut the type of tag doesn't matter, as long as it isn't used for anything else.

You can simulate display style equations by using \displaystyle and the HTML <center> </center> tags.
Last edited by stevem on Tue Jan 27, 2004 9:08 pm, edited 2 times in total.

Valentiner
Registered User
Posts: 27
Joined: Wed Sep 03, 2003 8:44 pm

Post by Valentiner » Mon Jan 26, 2004 9:31 pm

I have seen a site that does use $ $ for inline equations! and the [tex] tag for centered equations so IT IS POSSIBLE! however the admins of that site are very reticent as to say how they did it :(

and if $ ... $ is possible also \[ ... \] should be! (that is to easy insert latex code from a file to the forum) ...

Valentiner
Registered User
Posts: 27
Joined: Wed Sep 03, 2003 8:44 pm

Post by Valentiner » Mon Jan 26, 2004 9:40 pm

actually they also have the \[ and \] tags! cool. it can be done ...

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

Post by stevem » Mon Jan 26, 2004 9:56 pm

I have seen a site that does use $ $ for inline equations

Which site is that? And how does it deal with

Code: Select all

2 cost $2 and so 4 cost $4
where the text between $ ... $ is not a formula to be converted?

I have tried \[ and \] and they are ignored. So you can paste in latex code with them in - just add the tex tags and it's fine.

Post Reply

Return to “[2.0.x] MOD Requests”

Who is online

Users browsing this forum: No registered users and 14 guests

cron