This site is a showcase for using LatexRender for mathematics in WordPress

Using LaTeX in WordPress

LatexRender as a plugin

Monday 9th August 2004

Filed under: — Steve @ 6:02 pm

Up till this weekend WordPress ate backslashes (ie made them disappear) so \LaTeX commands don’t work. This bug has been resolved but if you don’t wish to upgrade your files, you can make the changes yourself:
8. wp-includes/functions-formatting.php
Line 226
After
function format_to_edit($content) {
Remove the line that says:
$content = stripslashes($content);

(ii) wp_includes/functions.php
Line 1081
Change
$content = stripslashes($post->post_content);
to
$content = $post->post_content;
Line 1089
Change
$pages[0] = stripslashes($post->post_content);
to
$pages[0] = $post->post_content;

9. No access to \LaTeX? Then get mimeTeX and download wp-latexrender.zip which contains mimetex.php and mimetex_plugin.php.
You need a latexrender folder inside WordPress and a subfolder called pictures which must be chmod to 777.
In mimetex.php you need to put in your paths for
$mimetex_path = "/home/domain_name/public_html/cgi-bin/mimetex.cgi";
$mimetex_path_http = "http://domain_name/mimetex";
$mimetex_cgi_path_http="http://domain_name/cgi-bin/mimetex.cgi";
$pictures_path = "/home/domain_name/public_html/mimetex/pictures";

Then upload mimetex.php to the latexrender folder. Upload mimetex_plugin.php to the plugins folder and activate it.

169 Comments »

RSS feed for comments on this post. TrackBack URI

  1. It looks as if PHP is not allowed to run LaTeX. You need to ensure that PHP is allowed to run the exec command.

    Comment by Steve — Sunday 11th July 2010 8:32 pm #

  2. Solved. I modified the plugin to output $status_code to a file and figured out that the actual error was: “I can’t find the format file `latex.fmt’!”. So a simple:

    $ texconfig init

    From the command line, fixed it. 🙂

    Comment by George — Sunday 11th July 2010 8:39 pm #

  3. Hello

    I also got same error with images ( gif or png ) in tmp : unlink warning cannot open …

    After commenting 6 lines with unlink, I get in error log
    that .aux file isn’t there ( in tmp dir, but I see it -it is there )

    No file e0be77095f01b0e9fe22c9bb002835c2.aux.
    \openout1 = `e0be77095f01b0e9fe22c9bb002835c2.aux’.

    ls e0be77095f01b0e9fe22c9bb002835c2* in tmp dir returns:

    e0be77095f01b0e9fe22c9bb002835c2.aux e0be77095f01b0e9fe22c9bb002835c2.log e0be77095f01b0e9fe22c9bb002835c2.tex
    e0be77095f01b0e9fe22c9bb002835c2.dvi e0be77095f01b0e9fe22c9bb002835c2.ps

    Comment by anon — Wednesday 9th March 2011 4:17 pm #

  4. There is no gif/png created so try the method given in the first comment at Path Problems in Linux

    Comment by Steve — Wednesday 9th March 2011 6:39 pm #

  5. Hello Steve,

    Great thank you ! My problem is fixed now.

    I’m running FreeBSD box , so my gs path
    $where_gs_is = “/usr/local/bin”;

    Comment by anon — Thursday 10th March 2011 3:43 pm #

  6. Hello again,

    I installed chemfig and latex-tkiz and I’m trying to show chemical graphics thougth this plugin in wordpress.

    I follow example from here : http://en.wikibooks.org/wiki/LaTeX/Creating_Graphics#Chemical_Graphics

    From these examples I can successfully draw : Sketal diagrams and 3rd and 4th Rings, but I cannot draw 1st and 2nd Rings example and any from basic usage ( for example methane molecule or bonds ).

    In erros log again I have there is missing .aux file ( image is created, but it is how to tell “not full” – I see only some parts from example from methane molecule 1/2 letter and one “-“. 3rd and 4th rings are exactly drawn as in the examples.

    I believe this problem may not be related to the plugin and I have to ask in other list ?

    Comment by anon — Friday 11th March 2011 6:43 pm #

  7. Hello again, forgot to tell I wrote the article for mhchem package, but I couldn’t find in it how to use it for drawing chemical structural formulas for example like this one : http://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/Butan_Lewis.svg/150px-Butan_Lewis.svg.png

    Comment by anon — Friday 11th March 2011 6:46 pm #

  8. It’s best to test code on your local computer to see if it compiles properly. Also check the versions of the files on the server to see that they agree. The command \listfiles in the document will do this for you.

    Comment by Steve — Friday 11th March 2011 7:01 pm #

  9. Hello,

    Thank you for your recommendations Steve,

    I made a screenshot of what I mean “not full” letters : http://212.43.51.203:7880/halfletter.jpg

    I tried to add tikz package in class.latexrender.php, but with wrong syntax ( typo error )
    instead of $string .= “\usepackage{tikz}\n”;
    I typed
    $string .= “usepackage{tikz}\n”;

    which reproduced formula on the screen with title “usepackagetikz” : http://212.43.51.203:7880/worngsyntax.jpg

    If I type it correct behaviour is the same – some formulas are ok ( as rings ) , but this one with bonds are as in the pictire 1

    Comment by anon — Friday 11th March 2011 7:25 pm #

  10. Try using png instead of gif to see if it improves the output.

    Comment by Steve — Friday 11th March 2011 7:42 pm #

  11. Hello,

    I’m using png
    Here is compiled code and log with \listfiles : http://212.43.51.203:7880/_lr/

    I believe the problem is No file 6bac4b27ba2ad8ff206bcbd1f0bc27c6.aux.
    \openout1 = `6bac4b27ba2ad8ff206bcbd1f0bc27c6.aux’.

    May be some part of package chemfig cannot see aux file which is created ( also image is created ) .

    There is one warning I see it also without \listfiles, but it seems not be a problem because some parts are shows as drawings, but other not.

    I added usepackage tikz in class.latexrender.php, also I made changes in font size ( 10 -> 11 px ) . I tried without loading tikz and using 10px font size as in the original class, but same error with no .aux file is returned.

    Comment by anon — Saturday 12th March 2011 12:53 am #

  12. The log tells you the problem:

    Package pgf Warning: Your graphic driver pgfsys-dvips.def does not support marking the current position. This warning is given only once on input line 11.

    The TGF manual pages 108-111 will tell you all about pgfsys-dvips.def. Also discussion at http://midtiby.blogspot.com/2008/05/updated-todonotes-package.html suggests you should try a more up-to-date version of TeX.
    Compare results with that on your home computer if that has a more recent version.

    Comment by Steve — Saturday 12th March 2011 10:25 am #

  13. Hello Steve, thank you
    This is only warning, so I believe it is not the problem, but I switched to Texlive 2010 .
    I have already read it this manual .

    There is no more such warning, but still exist error with no aux file and I found this is path variable in some part of tikz library regarding path to latex.
    The output picture is still the same “half letters”.

    \documentclass{article}
    \usepackage[latin1]{inputenc}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{chemfig}
    \pagestyle{empty}
    \begin{document}
    $\chemfig{C=CH-CH}$
    \end{document}

    No file 5412d9ee5997af5cd4b1323e1e157207.aux.
    \openout1 = `5412d9ee5997af5cd4b1323e1e157207.aux’.

    This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010) (format=latex 2011.3.12) 13 MAR 2011 17:43

    After I find where it is placed this path variable I will reply here if somebody else have the same problem .

    Thank you for all your help.

    Comment by anon — Sunday 13th March 2011 3:57 pm #

  14. Hello,

    Switched to Xymtex

    Comment by anon — Monday 14th March 2011 8:29 am #

  15. […] an installation), enabling server side conversion of latex symbols to images is done through theLaTeXRender wordpress plugin. Other ways exist, when server side install oflatex is not possible – see for […]

    Pingback by [RT]using latex for blogging | riding in tech world. — Sunday 25th December 2011 11:51 am #

  16. […] legal Ă© que tem vários plugins. Estou para instalar o plugin do GeSHi e já instalei o plugin do LaTeX Render. Realmente recomendo… […]

    Pingback by Mudança de Servidor » Tiago Madeira — Monday 22nd October 2012 9:32 pm #

  17. […] mathematical notation you see on this site is generated by a WordPress plugin called LatexRender, which uh, renders LaTeX […]

    Pingback by About the Math Notation - Exploring Binary — Sunday 3rd June 2018 2:14 am #

  18. […] you’re able to install ImageMagick and LaTeX on your server, LatexRender might be […]

    Pingback by Recommendations for a LaTeX Plugin? — Wednesday 3rd August 2022 6:25 am #

  19. […] you’re able to install ImageMagick and LaTeX on your server, LatexRender might be […]

    Pingback by Recommendations for a LaTeX Plugin? [closed] – Ten-tools.com — Sunday 9th October 2022 1:38 am #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


 

This site is a showcase for using LatexRender for mathematics in WordPress