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

Using LaTeX in WordPress

Monday 9th August 2004

Filed under: — Steve @ 6:02 pm

I have now managed to make LatexRender as a plugin (download files here) which means that it won’t be necessary to edit WordPress files. Before you get too excited this assumes

1. You are using at least WordPress 1.2 (which uses plugins)
2. You have the latest files which don’t eat backslashes (detailed on page 2)

If not, you can still use the method in 5th August’s post. Also you will need to put some information about where to find files in the latexrender files.

1. You need to have and ImageMagick installed on your server. If this is not possible, then try mimeTeX (see page 2)

2. latexrender-plugin.php
Ensure that
include_once('/home/path_to/wordpress/latexrender/latex.php');
contains the correct path to where you have put latex.php

3. latex.php
Ensure that
$latexrender_path = "/home/domain_name/public_html/path_to/latexrender"; and $latexrender_path_http = "/path_to/latexrender";
contain the correct path to where your latexrender files are to go

4. class.latexrender.php
Ensure that
var $_latex_path = "/usr/bin/latex"; var$_dvips_path = "/usr/bin/dvips"; var $_convert_path = "/usr/bin/convert"; var$_identify_path = "/usr/bin/identify";
point to the right places.

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";

5. Create a new latexrender folder in your WordPress folder, with sub folders tmp and pictures. These 2 folders must be chmod to 777. Upload latex.php and class.latexrender.php to the latexrender folder

6. If you are happy to let commenters use LaTeX (but beware spammers) then in latexrender-plugin.php remove // from the line:

7. Upload latexrender-plugin.php to WordPress’s plug-in folder (/wp-content/plugins) and activate it in the Plugins menu

should now be enabled! Use [tex ] and [/tex ] (without the space) to surround your maths. There’s a tex button to do this for you.

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 #

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