...a remake of the old latexrender mod. It is based on the great graphviz plugin by Carl-Christian Salvesen.
It consists of amine
Alternatively, see the installation notes by Frisco Rose under http://wiki.splitbrain.org/wiki:debian_notes
$apt-get install tetex-base texlive-latex-recommended texlive-fonts-recommended imagemagick gs-common
should be sufficient to install the required packages$yum install tetex-latex ImageMagick
should be sufficient to install the required packages ($yum install tetex-unicode
for including latex-ucs ??)emerge -av tetex latex-unicode imagemagick ghostscript
$> cd dokuwiki/lib/plugins $> darcs get http://darcs.erazor-zone.de/php/dokuwiki/latex/
Update:
$> darcs pull
$> cd dokuwiki $> mkdir lib/plugins/latex
$> mkdir latexrender $> cd latexrender $> wget http://www.mayer.dial.pipex.com/latexrender.zip
$> unzip latexrender.zip
$> cp otherPHP/latexrender/class.latexrender.php ../lib/plugins/latex $> cd .. $> rm -rd latexrender
If you can not latex the following lines, your latexrender won't work (since this is the kind of file generated by the latexrender script):
\documentclass[14pt]{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{eurosym} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{amssymb} \pagestyle{empty} \begin{document} $a^2+b^2=c^2$ \Latex2e\ ist nett! \end{document}
Some installations may work better (i.e., work, period) with utf8x
→latin1
, though this is not the preferred method.
<latex> \frac{3}{4 \pi} \sqrt{4 \cdot x^2 12}\\ \lim_{n \to \infty} \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{6}\\ \it{f}(x) = \frac{1}{\sqrt{x} x^2}\\ e^{i \pi} + 1 = 0\; </latex>
...that'd be a good way to debug your install. These are the exact commands the plugin uses.
\documentclass[14pt]{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{eurosym} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{amssymb} \pagestyle{empty} \begin{document} $a^2+b^2=c^2$ \end{document}
cat > test.tex
/usr/bin/latex --interaction=nonstopmode test.tex
/usr/bin/dvips -E test.dvi -o test.ps
/usr/bin/convert -density 120 -trim -transparent "#FFFFFF" test.ps test.png
xv test.png
I had some problems with installation. Clearly, the instructions at the page are obsolete and misleading. Here is what I did.
latex.tar.gz
(see the URL above)class.latexrender.php
and syntax.php
from this zip into the directory dokuwiki/lib/plugins/latex/
(create it if you don't have it).class.latexrender.php
:var $_tmp_dir = "c:/temp"; var $_latex_path = "c:/texmf/miktex/bin/latex.exe"; var $_dvips_path = "c:/texmf/miktex/bin/dvips.exe"; var $_convert_path = "c:/soft/imagemagick/convert.exe"; var $_identify_path="c:/soft/imagemagick/identify.exe";
and
var $_tmp_dir='c:/temp';
in line 22 of syntax.php
.
(inserted by Facundo) I had problems with the double quotes. I enclosed the paths in single quotes and it worked fine, e.g. 'c:\textmf\...'
If you have problems, check that the plugin creates a tex file in your temporary directory (in my case, the file had a temporary name d1b4924d687d27239d896aaf8b9a6444.tex
) and run manually latex on this file. I found out that my miktex stuck initially because it required packages
eurosym and utf8x which I did not have. After I downloaded them manually, everything works now.
Adding align=absmiddle
on line 91 of syntax.php
makes much better alignment of inline formulas.
Gennady.
<latex>öäüß</latex>
Note: [space] = ' '
<latex> [space]$ \begin{align*} \int x^2 dx & = \frac{1}{3}x^3 \therefore\quad\int_0^1 x^2 dx &= \frac{1}{3} \end{align*} $[space] </latex>
The space right after and before the latex
tag is compulsory because the latexrender will encode all your stuff with a pair of dollar sign. The idea of my trick is to make the two dollar signs out of effect! I learn this from SQL-injection.
Alternatively, as noted at the bottom of this page, This version of the plugin allows for simple markup, like $\alpha$ directly in the wikitext.Should work with the latest darcs version too, but you've to use $$ latex $$
I tried the today darcs version and the $$ trick does not work![]()
You could also replace line 190 in
class.latexrenderer.php
with$string .= $latex_formula.”\n”;
(then enclose inline equations in $s and displayed equations in $$s).
I'm having problem to generate a *png* file from the *ps* file. However, I do have ImageMagick installed, and the command *convert* works fine. The problem is really strange. At the line 249 of class.latexrender.php :
// imagemagick convert ps to image and trim picture $command = $this->_convert_path." -density ".$this->_formula_density." -trim -transparent white ".$this->_tmp_filename.".ps ".$this->_tmp_filename.".".$this->_image_format; $status_code = exec($command);
The returned value of $status_code is zero, which presumptively means that the command did not execute correctly. However, when I type exactly the same command on terminal, everything works great, and I get the png file.
Any idea what would be the problem?
Thanks.
Nice work! Just started to work on a plugin for LatexRender and then found this! Greets, Jan Tammen.Yeah! I couldn't wait for your release
Also0777-$conf['dmask']
didn't work for me – I had to do achmod x data/media/latex
But now it runs perfectly - thanks for your work!
I'm having trouble getting this to work. I've traced it to execution of latex, which stops immediately with “can't find 'latex.fmt'”. Nonetheless, when I stop the file from being deleted and go into the /tmp directory, I can run latex properly on the .tex file. Permissions are set liberally. Is there something with PHP that I'm not understanding? A safe mode problem, maybe?
The following code doesn't work for me, e.g. transparency for generated images is broken:
class.latexrender.php(line 253):
// imagemagick convert ps to image and trim picture $command = $this->_convert_path." -density ".$this->_formula_density. " -trim -transparent \"#FFFFFF\" ".$this->_tmp_filename.".ps ". $this->_tmp_filename.".".$this->_image_format;
but it works fine if I remove escaped double quotes that surround #FFFFFF, e.g.:
” -trim -transparent #FFFFFF ”.$this→_tmp_filename.”.ps ”.
or even better:
” -trim -transparent white ”.$this→_tmp_filename.”.ps ”.
I am using ImageMagick v.6.2.5
Hi, I'm having un problem with latexrender install: I can't get the file sysntax.php. I get always the message: “Unable to display file “http://darcs.erazor-zone.de/php/dokuwiki/latex/syntax.php”: It may not exist, or permission may be denied.” I'm doing something wrong? Thanks. Joao
→ The file is in http://darcs.erazor-zone.de/php/dokuwiki/latex/latex.tar.gz Érick
→ Hello, first off, thanks a ton for an awsome plugin. 1 question, any idea how to add the syntax rules to the syntax help page (the one linked to from the edit window)? Not a big deal, email to (nicholas-jones@uiowa.edu) would be great. Thanks Nick
Nice work! Thanks for the plugin.
I am trying to install DokuWiki for my class website, which I would like to use your plugin for showing equations on my notes and homeworks pages. I have installed it on my server and receive the errors:
Warning: copy(cd6174dda4b84b998f052ba3e5d9f2fb.png): failed to open stream: No such file or directory in /home/chris/dokuwiki/lib/plugins/latex/class.latexrender.php on line 276 Warning: unlink(/tmp/cd6174dda4b84b998f052ba3e5d9f2fb.aux): No such file or directory in /home/chris/dokuwiki/lib/plugins/latex/class.latexrender.php on line 294 Warning: unlink(/tmp/cd6174dda4b84b998f052ba3e5d9f2fb.dvi): No such file or directory in /home/chris/dokuwiki/lib/plugins/latex/class.latexrender.php on line 296 Warning: unlink(/tmp/cd6174dda4b84b998f052ba3e5d9f2fb.ps): No such file or directory in /home/chris/dokuwiki/lib/plugins/latex/class.latexrender.php on line 297 Warning: unlink(/tmp/cd6174dda4b84b998f052ba3e5d9f2fb.png): No such file or directory in /home/chris/dokuwiki/lib/plugins/latex/class.latexrender.php on line 298
Below the errors shows an invalid image link to fetch.php?cache=&media=latex%3A3ce93eb8fef2cd7a021e88f6651bd559.png
. I have tweaked around with the temporary directory variables in both the class.latexrender.php
and syntax.php
files, but still receive the same errors. To see if my server was the problem, I tried installing everything on my Windows machine (using MikTeX) following the instructions in the previous comment. The error is duplicated exactly, except that the Unix paths are now replaced with Windows paths (ie the line numbers are the same). Unlike the previous comment, I am not seeing any temporary files in the temporary folders; does that mean that something is going wrong before it gets to the point where the warnings are?
Am I overlooking something simple, or what else could I be doing wrong? Thanks so much!
– Chris
This looks an awful lot like a permissions issue. Are you sure that your web server has permission to write in/tmp
? You could configure it (inlib/plugins/latex/syntax.php
) to write to atmp
subdirectory ofdata/latex
. I also had a problem with ridiculous ownership and permissions for thedata/latex
directory when I used the plugin manager to install this.This may be an overall problem with getting images. I had the same trouble. This was because I remade language files. After editing lang.php I saved it in UTF-8 (WScite). It influenced only on fetch.php. At last I saved this file just in 8-Bit format and all became right.
—-
It worked at last!!!
I had exactly the problem mentioned by Chris above and it really went away by installing the unicode package for latex from http://www.tug.ctan.org/tex-archive/macros/latex/contrib/unicode/ ... I must say that I also had several permission problems so I also issued the command:
chmod -R 777 dokuwiki
to get rid of all of them at once. This is of course not advisable from a security perspective, but once latexrender works, you can fine-tune the permissions to a better setting Thanks a lot for the plugin!!!
–map
Some share hosting environments (e.g. DreamHost) have a latex install, without the unicode package.... and don't handle the paths to private user LaTeX packages gracefully in PHP scripts. I think its something to do with $HOME not being parsed correctly. Or that kinda stuff. That is, the helpdul instructions on private package install instructions at http://www.tex.ac.uk/cgi-bin/texfaq2html?label=privinst work only from the shell, not from PHP. Grr. So I brute forced it by editing my conf/local.php to include
putenv('TEXINPUTS=/home/.eulis/bodyworker/texmf/tex/latex/unicode:/home/.eulis/bodyworker/texmf/tex/latex/unicode/data:');
as per their backup ideas at http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tempinst
You might really find it useful to go into class.latexparser.php in the distro and add some extra debug code to the lines near
// create temporary dvi file $command = $this->_latex_path." --interaction=nonstopmode ".$this->_tmp_filename.".tex"; $status_code = exec($command);
the latex rendering class is a bit bad here... the fact that it tries to return a status code makes you think that it is actually doing some form of useful error trapping here. It's not, and latex can throw HEAPS of errors that go undetected. $statuscode
is merely set to the last line of output of the function. a better version would be something like:
// create temporary dvi file $command = $this->_latex_path." --interaction=nonstopmode ".$this->_tmp_filename.".tex"; exec($command,$latex_debug_array,$status_code);
and possibly prints the debug array in case of an error...
I've written a little email to the guy behind class.latexparser.php to express my opinions. I dunno, would you cll it a bug per se?
–dan() 2006-07-20
Hi! I really love the plugin, but I can't get it working (despite all the good hints listed here). * I run apache on a FC4 distro. * dokuwiki works fine, the check delivers DokuWiki version: Release 2006-03-09 PHP version 5.0.4 Changelog is writable Datadir is writable Attic is writable Mediadir is writable Cachedir is writable conf/users.auth.php is writable mb_string extension not available - PHP only replacements will be used Debugging support is disabled Your current permission for this page is 255 The current page is writable by the webserver The current page is writable by you
Can somebody help me ? – Erik
Seems I have the same problem. This is the output in my apache error.log
file, maybe this helps:
This is dvips(k) 5.92b Copyright 2002 Radical Eye Software (www.radicaleye.com) /usr/bin/dvips: ! DVI file can't be opened. convert: unable to open image `d691199f46bff930ababdf3ceb922351.ps': No such file or directory. identify: unable to open image `d691199f46bff930ababdf3ceb922351.png': No such file or directory. This is dvips(k) 5.92b Copyright 2002 Radical Eye Software (www.radicaleye.com) ' TeX output 2006.07.01:1253' -> 1824d7788b50a16fb7b5ac2dd1ad02bd.ps <texc.pro><f7b6d320.enc><aae443f0.enc><bbad153f.enc><0ef0afca.enc><texps.pro> . <cmr5.pfb><cmex10.pfb><cmsy7.pfb><cmmi10.pfb><cmr10.pfb><cmsy10.pfb> <cmmi7.pfb><cmr7.pfb>[1]
— Wonko 2006-07-01
I had the same problem but solved it ...
You dont see any tex Files because there is a clean up funktion in class.latexrender.php (line290). I simple disabled the function call in line 278$status_code = copy($this->_tmp_filename.".".$this->_image_format,$filename); // $this->cleanTemporaryDirectory(); if (!$status_code) { chdir($current_dir); $this->_errorcode = 6; return false; } chdir($current_dir);
after that you find some files in ./tmp. In my case there was a tex and a log file and i found out that i misset the latex-utf package. So i installed it and voila it works
– Fronk - 2006-08-07
Hi!
First of all: Thanks for the Plugin, it's great! (Except one thing )
Example: I would like here in line, but it appears in an “upper” stile. Any suggestions?
–Matthias
I've made some changes to my copy of the plugin so that inline formulas are properly aligned (to within about 1pt). You can find my explanation of how to do this here, or just download my copy of the plugin here. Beware that I've expanded the syntax used for putting latex on the page, so that it can differentiate between inline and display modes. (Specifically, in the wiki text, a user enters math precisely as he/she would in a latex document.) Also, I use a dark red text color, but this can easily be changed. — Mike
Hi there. Love the plugin but can't install it :(. I keep having the error
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in c:\workshop\dokuwiki\lib\plugins\latex\class.latexrender.php on line 180
Parse error: parse error, unexpected T_STRING in c:\workshop\dokuwiki\lib\plugins\latex\class.latexrender.php on line 180
Fatal error: Cannot instantiate non-existent class: latexrender in c:\workshop\dokuwiki\lib\plugins\latex\syntax.php on line 108
Line 180 is ” $string = “\documentclass[”.$this→_font_size.”pt]{”.$this→_latexclass.”}\n”; ” in my code. Any ideas? Thanks in advance.
moonlord@retardchat.org
In my experience, this is exactly what happens when you've forgotten to close a quote (either double or single) somewhere on a previous line. — Mike
I love this plugin.
My wiki is used by physicists, so we use a lot of LaTeX.
We use so much, in fact, that I decided to extend the syntax so that expressions like $\alpha$
are recognized and parsed properly.
I've also added support for displaymath, eqnarray, and eqnarray*. This is the zip file containing my version.
I must admit that dokuwiki's particular species of regex confounds me utterly, so the syntax contained here may be downright stupid, but it works for me. If anyone would like to take this over to improve it, feel free. — Mike
It is incompatible to http://danjer.doudouke.org/tech/dokutexit ? Can you fix this?
Fix to Enable Copy&Paste from Wikipages:
$title=htmlspecialchars(implode("",$data)); $renderer->doc .= '<img src="'.$url.'" class="media" title="'.$title.'" alt="'.$title.'" />';
instead of line 90 in syntax.php
Excellent plugin! However, we ran into trouble because of the line var $_xsize_limit = 500; in class.latexrender.php which simply means that long formulas will not be typeset for, initially, totally mysterious reasons. Just change 500 to a large value and everything will work again. (Petrus)
on which server you can host a DokuWiki with this plugin? Because of the additional package and the enabled exec php-command, I couldn't find a hoster yet
Hi! Thanks for the good work! I am trying to use the latex block to render some tables, because the native dokuwiki syntax does not seem to support rowspan and some features like table size and so on. I have tried the following tables:
<latex> \begin{tabular}{|l|l|p{5cm}|} \hline option & variants & explanation \\ \hline id & unique string & Identifies the user uniquely.\\ \hline logmask & ALL & Log everything \\ \cline{2-3} & DBG & Log only debug \\ \cline{2-3} & WARN & Log only warning messages \\ \hline printTID & flag & Print Thread ID or not.\\ \hline prefix & any string & With this will be prefixed all messages of this user.\\ \hline p & p & p \\ \hline p & p & p \\ \hline p & p & p \\ \hline p & p & p \\ \hline \end{tabular} </latex> <latex> \begin{tabular}{|l|l|p{5cm}|} \hline option & variants & explanation \\ \hline id & unique string & Identifies the user uniquely.\\ \hline logmask & ALL & Log everything \\ \cline{2-3} & DBG & Log only debug \\ \cline{2-3} & WARN & Log only warning messages \\ \hline printTID & flag & Print Thread ID or not.\\ \hline prefix & any string & With this will be prefixed all messages of this user.\\ \hline filename & path string & The whole path to the filename without the date .log suffix, which are set automatically. \\ \hline \end{tabular} </latex>
The second table is not rendering at all. Only the word 'Latex' is printed instead of the table. I have changed _xsize_limit and _ysize_limit to 5000, but still not working.
Th adapt this extention with DokuTeXit (http://danjer.doudouke.org/tech/dokutexit) I add
if($mode == 'latex' && strlen($data[0]) > 1) { $renderer->doc .= "$".$data[0]."$\n"; return true; }
After
if($mode == 'xhtml' && strlen($data[0]) > 1) { if ( !is_dir($conf['mediadir'] . '/latex') ) { mkdir($conf['mediadir'] . '/latex', 0777-$conf['dmask']); } ... return true; }
In the file syntax.php.
added to darcs repository. — Alexander Krause 2007/02/18 19:15
Hello. Thanks for the great plugin and the equally awesome documentation. I have a few issues however:
Any help on these questions would be greatly appreciated, especially about increasing the font size of formulas. Thanks again. — onion mantis 2008/02/04 09:15
If you change the $_formula_density value in the class.latexrender.php file to a value higher than 120, it will increase the size of the formula. It would be nice to be able to edit this dynamically from the dokuwiki code instead of hacking the plug-in with a hard-coded value. David
I'm having trouble getting the PDF to render properly using Debian box (Using DokuTexit). When I hit the Generate PDF button, I get
...Document Class: report 2005/09/16 v1.4f Standard LaTeX document class (/usr/share/texmf-texlive/tex/latex/base/size10.clo)) (/usr/share/texmf-texlive/tex/latex/geometry/geometry.sty (/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty)) (/usr/share/texmf/tex/latex/ucs/ucs.sty (/usr/share/texmf/tex/latex/ucs/data/uni-global.def)) (/usr/share/texmf-texlive/tex/latex/base/inputenc.sty (/usr/share/texmf/tex/latex/ucs/utf8x.def)) (/usr/share/texmf-texlive/tex/latex/pslatex/pslatex.sty) (/usr/share/texmf-texlive/tex/latex/hyperref/hyperref.sty (/usr/share/texmf-texlive/tex/latex/hyperref/pd1enc.def) (/etc/texmf/tex/latex/config/hyperref.cfg) ! LaTeX Error: File `kvoptions.sty' not found.
Methinks something went wrong with the LaTex install. Any ideas? – Jeff
Change in syntax.php lines in 2 places:
$renderer->doc .= '<img src="'.$url.'" class="media" title="Graph" alt="Graph" />';
$renderer->doc .= '<img src="'.$url.'" class="media" title="Latex" alt="Latex" />';
to:
$renderer->doc .= '<img src="'.$url.'" class="media" style="vertical-align: middle;" />';
qwak 2008/05/06 18:59
You should not eliminate the other metadata in the renderer→doc string, consider using instead
$renderer->doc .= '<img src="'.$url.'" class="media" title="Latex" alt="Latex" />';
to:
$renderer->doc .= '<img src="'.$url.'" class="media" style="vertical-align: middle;" title="Latex" alt="Latex" />';
F. Rose
The latex namespace only exists under the data/media/ directory, and it is not shown in the ACL setup page of Dokuwiki. If you do not allow the users group access to all namespaces, they won't be able to see the latex rendering.
The quick and dirty fix is to create a latex directory under the data/pages/ directory so that the latex namespace is shown in the ACL setup.
This is either a Dokuwiki bug (only looks at namespaces in the pages directory), or a plugin bug (should create the namespace in both media and pages directories).